ynh_extension_meeo/libs/bulletin/Bulletin.lib.php

62 lines
1.3 KiB
PHP
Raw Normal View History

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