ynh_extension_meeo/libs/bulletin/Bulletin.lib.php
2024-07-27 17:19:40 +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;
use YesWiki\Meeo\Eleve\Eleve;
class Bulletin {
private $eleve;
private $matieres = [];
public function __construct($wiki, Eleve $eleve) {
$this->eleve = $eleve;
// echo var_dump($eleve);
$listManager = $wiki->services->get(ListManager::class);
$matieres = $listManager->getOne('ListeMatiere');
// echo "<p>".var_dump($matieres)."</p>";
foreach ($matieres['nodes'] as $matiere) {
$this->matieres[] = new Matiere($wiki, $this, $matiere["id"], $matiere["label"]);
}
}
public function getId() {
return $this->eleve->getId();
}
public function getNom() {
return $this->eleve->getNom();
}
public function getClass() {
return $this->eleve->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;
}
}
}