diff --git a/actions/NotesAction.php b/actions/NotesAction.php index 7e64d9d..50c4527 100644 --- a/actions/NotesAction.php +++ b/actions/NotesAction.php @@ -5,7 +5,6 @@ namespace YesWiki\Meeo; use YesWiki\Core\YesWikiAction; use YesWiki\Bazar\Service\EntryManager; use YesWiki\Core\Service\UserManager; -use YesWiki\Bazar\Service\ListManager; class NotesAction extends YesWikiAction { @@ -23,27 +22,28 @@ class NotesAction extends YesWikiAction $entryManager = $this->getService(EntryManager::class); $userManager = $this->getService(UserManager::class); - $listManager = $this->getService(ListManager::class); if ( $userManager->isInGroup($groupeEE, admincheck: false) ) { $eleves = $entryManager->search(['formsIds' => $meeo_config['elevesFormId']]); $entries = $entryManager->search(['formsIds' => $formId]); - $matieres = $listManager->getOne('ListeMatiere'); + + include 'tools/meeo/libs/Bulletin.lib.php'; + + $bulletins = []; + foreach ( $eleves as $eleve) { + $bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle"); + } // echo var_dump($eleves); // echo var_dump($entries); // echo var_dump($matieres); return $this->render('@meeo/edu_notes.twig', [ - "eleves" => $eleves, - "entries" => $entries, - "matieres" => $matieres, + "bulletins" => $bulletins, ]); } else { $entries = $entryManager->search(['formsIds' => $formId]); - $matieres = $listManager->getOne('ListeMatiere'); - + return $this->render('@meeo/eeleve_notes.twig', [ - "entries" => $entries, - "matieres" => $matieres, + "bulletin" => $bulletin, ]); } } diff --git a/libs/Bulletin.lib.php b/libs/Bulletin.lib.php new file mode 100644 index 0000000..11a25f8 --- /dev/null +++ b/libs/Bulletin.lib.php @@ -0,0 +1,59 @@ +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; + } + } +} \ No newline at end of file diff --git a/libs/Matiere.lib.php b/libs/Matiere.lib.php new file mode 100644 index 0000000..7845e66 --- /dev/null +++ b/libs/Matiere.lib.php @@ -0,0 +1,56 @@ +id = $id; + $this->nom = $nom; + + $eleveId = $bulletin->getId(); + + $entryManager = $wiki->services->get(EntryManager::class); + $entries = $entryManager->search(['formsIds' => 7, 'queries' =>[ + 'listefiche5bf_eleve' => $eleveId, + 'listeListeMatièrebf_matiere' => $id + ]]); + // echo var_dump($entries)."\n\n"; + foreach ($entries as $entry) { + $this->notes[] = new Note($entry['bf_intitule'], $entry['bf_note'], $entry['bf_coef']); + } + } + + public function getId() { + return $this->id; + } + + public function getNom() { + return $this->nom; + } + + public function getMoyenne() { + $total = 0; + $totalCoef = 0.0; + foreach ($this->notes as $note) { + $total += $note->getNote() * $note->getCoef(); + $totalCoef += $note->getCoef(); + } + return $total / $totalCoef; + } + + public function getNotes() { + return $this->notes; + } + + public function isVisible() { + return $this->notes; + } +} \ No newline at end of file diff --git a/libs/Note.lib.php b/libs/Note.lib.php new file mode 100644 index 0000000..1d86651 --- /dev/null +++ b/libs/Note.lib.php @@ -0,0 +1,27 @@ +intitule = $intitule; + $this->note = $note; + $this->coef = $coef; + } + + public function getIntitule() { + return $this->intitule; + } + + public function getNote() { + return $this->note; + } + + public function getCoef() { + return $this->coef; + } +} \ No newline at end of file diff --git a/templates/edu_notes.twig b/templates/edu_notes.twig index e74cf5a..3ceb30e 100644 --- a/templates/edu_notes.twig +++ b/templates/edu_notes.twig @@ -1,14 +1,16 @@