ynh_extension_meeo/libs/bulletin/Bulletin.lib.php
mckmonster 0664776352 - Fix pour afficher les bulletins
- Redirection vers la page Notes après l'enregistrement d'un controle
2024-07-21 11:17:17 +02:00

62 lines
No EOL
1.3 KiB
PHP

<?php
namespace YesWiki\Meeo\Bulletin;
include 'tools/meeo/libs/bulletin/Matiere.lib.php';
use YesWiki\Bazar\Service\ListManager;
class Bulletin {
private $eleve;
private $classe;
private $matieres = [];
public function __construct($wiki, $eleve, $classe) {
$this->eleve = $eleve;
// echo var_dump($eleve);
$this->classe = $classe;
$listManager = $wiki->services->get(ListManager::class);
$matieres = $listManager->getOne('ListeMatiere');
foreach ($matieres['label'] as $id => $nom) {
$this->matieres[] = new Matiere($wiki, $this, $id, $nom);
}
}
public function getId() {
return $this->eleve['id_fiche'];
}
public function getNom() {
return $this->eleve['bf_nom'];
}
public function getClass() {
return $this->classe;
}
public function getMoyenne() {
$total = 0;
$totalMatieres = 0;
foreach ( $this->matieres as $matiere) {
if ($matiere->isVisible()) {
$total += $matiere->getMoyenne();
++$totalMatieres;
}
}
return $total / $totalMatieres;
}
public function getMatieres() {
return $this->matieres;
}
public function isVisible() {
foreach ($this->matieres as $matiere) {
if ( !$matiere->isVisible() ) {
return false;
}
return true;
}
}
}