ynh_extension_meeo/libs/Bulletin.lib.php

59 lines
1.2 KiB
PHP
Raw Normal View History

2024-07-13 18:39:43 +00:00
<?php
namespace YesWiki\Meeo;
include 'tools/meeo/libs/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['bf_titre'];
}
public function getNom() {
return $this->eleve['bf_nom'];
}
public function getClass() {
return $this->classe;
}
public function getMoyenne() {
$total = 0;
foreach ( $this->matieres as $matiere) {
$total += $matiere->getMoyenne();
}
return $total / count($this->matieres);
}
public function getMatieres() {
return $this->matieres;
}
public function isVisible() {
foreach ($this->matieres as $matiere) {
if ( !$matiere->isVisible() ) {
return false;
}
return true;
}
}
}