diff --git a/libs/classes/Classe.lib.php b/libs/classes/Classe.lib.php new file mode 100644 index 0000000..d320c55 --- /dev/null +++ b/libs/classes/Classe.lib.php @@ -0,0 +1,40 @@ +id = $id; + $this->name = $name; + + $noteManager = $wiki->services->get(NoteManager::class); + foreach ($noteManager->allBulletins() as $bulletin) { + if ($bulletin->getClasse() == $this->id) { + array_push($this->bulletins, $bulletin); + } + } + } + + public function getId() { + return $this->id; + } + + public function getName() { + return $this->name; + } + + public function getBulletins() { + return $this->bulletins; + } + + public function haveBulletins(){ + return sizeof($this->bulletins) > 0; + } +} \ No newline at end of file diff --git a/services/NoteManager.php b/services/NoteManager.php index 920580b..c211f63 100644 --- a/services/NoteManager.php +++ b/services/NoteManager.php @@ -9,6 +9,7 @@ use YesWiki\Core\Service\UserManager; use YesWiki\Wiki; use YesWiki\Meeo\Bulletin\Bulletin; use YesWiki\Meeo\Service\EleveManager; +use YesWiki\Meeo\Classes\Classe; class NoteManager { protected $wiki; @@ -36,26 +37,37 @@ class NoteManager { $this->eeGroup = $meeo_config['groupeEE']; } + public function allBulletins() { + $eleveManager = $this->wiki->services->get(EleveManager::class); + $eleves = $eleveManager->getAll(); + + $bulletins = []; + foreach ( $eleves as $eleve) { + $bulletins[] = new Bulletin($this->wiki, $eleve); + } + return $bulletins; + } + public function viewBulletins() { $eleveManager = $this->wiki->services->get(EleveManager::class); include 'tools/meeo/libs/bulletin/Bulletin.lib.php'; + include 'tools/meeo/libs/classes/Classe.lib.php'; $loggedUser = $this->authController->getLoggedUser(); // echo "
".var_dump($loggedUser)."
"; if (true) {//($this->userManager->isInGroup($this->eeGroup, $loggedUser['name'], false)) { - $eleves = $eleveManager->getAll(); - - $bulletins = []; - foreach ( $eleves as $eleve) { - $bulletins[] = new Bulletin($this->wiki, $eleve); - } // echo "".var_dump($eleves)."
"; // echo "".var_dump($bulletins)."
"; - + $classes = []; + $listClasse = $this->listManager->getOne('ListeClasses'); + foreach ($listClasse['label'] as $id => $classe) { + array_push($classes, new Classe($this->wiki, $id, $classe)); + } + // echo "".var_dump($classes)."
"; return $this->wiki->render('@meeo/edu_notes.twig', [ - "bulletins" => $bulletins, + "classes" => $classes, "opened" => "" ]); } else { diff --git a/templates/edu_notes.twig b/templates/edu_notes.twig index bb1470c..4c6fdb9 100644 --- a/templates/edu_notes.twig +++ b/templates/edu_notes.twig @@ -1,7 +1,18 @@ -