From 3f328d55a6d9d4a613fdb975eed7a09e96834101 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Wed, 11 Sep 2024 08:47:50 +0200 Subject: [PATCH] [Notes] Add note max --- controllers/ApiController.php | 2 +- libs/bulletin/Matiere.lib.php | 2 +- libs/bulletin/Note.lib.php | 8 +++++++- libs/controle/Controle.lib.php | 6 ++++-- services/NoteManager.php | 11 +++++++++-- templates/edu_controle.twig | 14 ++++++++++++++ 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/controllers/ApiController.php b/controllers/ApiController.php index 38afded..78039f2 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -73,7 +73,7 @@ class ApiController extends YesWikiController return strpos($key, 'eleve_') === 0; }, ARRAY_FILTER_USE_KEY); - $controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves); + $controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['max'], $parameters['coef'], $eleves); $controle->createNotes($noteManager); // return new ApiResponse($controle); return $this->wiki->redirect($redirectParams['controle'], 200); diff --git a/libs/bulletin/Matiere.lib.php b/libs/bulletin/Matiere.lib.php index c630e10..ba5d9a8 100644 --- a/libs/bulletin/Matiere.lib.php +++ b/libs/bulletin/Matiere.lib.php @@ -25,7 +25,7 @@ class Matiere { // echo "

".var_dump($entries)."

"; foreach ($entries as $entry) { if (!empty($entry['bf_note'])) - $this->notes[] = new Note($entry['bf_intitule'], $entry['bf_note'], $entry['bf_coef']); + $this->notes[] = new Note($entry['bf_intitule'], $entry['bf_note'], $entry['listeListeNotemaxbf_notemax'], $entry['bf_coef']); } } diff --git a/libs/bulletin/Note.lib.php b/libs/bulletin/Note.lib.php index c9eabf6..3cf7b5e 100644 --- a/libs/bulletin/Note.lib.php +++ b/libs/bulletin/Note.lib.php @@ -6,11 +6,13 @@ class Note { private $intitule; private $note; private $coef; + private $max; - public function __construct(string $intitule, int $note, float $coef = 1.0) { + public function __construct(string $intitule, int $note, int $max, float $coef = 1.0) { $this->intitule = $intitule; $this->note = $note; $this->coef = $coef; + $this->max = $max; } public function getIntitule() { @@ -24,4 +26,8 @@ class Note { public function getCoef() { return $this->coef; } + + public function getMax() { + return $this->max; + } } \ No newline at end of file diff --git a/libs/controle/Controle.lib.php b/libs/controle/Controle.lib.php index 7f26949..15823b1 100644 --- a/libs/controle/Controle.lib.php +++ b/libs/controle/Controle.lib.php @@ -7,12 +7,14 @@ use YesWiki\Meeo\Service\NoteManager; class Controle { public $intitule; public $matiere; + public $max; public $coef; public $eleves; - public function __construct($intitule, $matiere, $coef, $eleves) { + public function __construct($intitule, $matiere, $max, $coef, $eleves) { $this->intitule = $intitule; $this->matiere = $matiere; + $this->max = $max; $this->coef = $coef; $this->eleves = $this->removePrefixFromKeys($eleves, "eleve_"); } @@ -33,7 +35,7 @@ class Controle { public function createNotes(NoteManager $noteManager) { foreach ($this->eleves as $eleve => $note) { if (!empty($note)) - $noteManager->createNote($this->intitule, $eleve, $this->matiere, $note, $this->coef); + $noteManager->createNote($this->intitule, $eleve, $this->matiere, $note, $this->max, $this->coef); }; } } \ No newline at end of file diff --git a/services/NoteManager.php b/services/NoteManager.php index a9632cb..fb0f0fb 100644 --- a/services/NoteManager.php +++ b/services/NoteManager.php @@ -76,11 +76,17 @@ class NoteManager { $matieres = $this->listManager->getOne('ListeMatiere'); // echo var_dump($matieres); $classes = $this->listManager->getOne('ListeClasses'); + $notesMax = $this->listManager->getOne('ListeNoteMax'); // echo var_dump($classes); - return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['label'], 'classes' => $classes['label'], 'eleves' => $eleves]); + return $this->wiki->render('@meeo/edu_controle.twig', [ + 'matieres' => $matieres['label'], + 'classes' => $classes['label'], + 'notesMax' => $notesMax['label'], + 'eleves' => $eleves, + ]); } - public function createNote($intitule, $eleve, $matiere, $note, $coef) { + public function createNote($intitule, $eleve, $matiere, $note, $max, $coef) { if ($note == 0) return; @@ -88,6 +94,7 @@ class NoteManager { 'bf_titre' => "Note : ".$intitule." - ".$eleve." - ".$matiere, 'bf_intitule' => $intitule, 'listeListeMatierebf_matiere' => $matiere, + 'listListeNotemaxbf_notemax' => $max, 'listefiche'.$this->eleveFormId.'bf_eleve' => $eleve, 'bf_note' => $note, 'bf_coef' => $coef, diff --git a/templates/edu_controle.twig b/templates/edu_controle.twig index ed38f13..0ed5b33 100644 --- a/templates/edu_controle.twig +++ b/templates/edu_controle.twig @@ -27,6 +27,20 @@ +
+ +
+ +
+