From 18b0707ffd9d239542e98d730eb6d4098b9f1c09 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Wed, 17 Jul 2024 09:01:25 +0200 Subject: [PATCH] Add Eleves listing --- commands/CreateFormsCommand.php | 94 ++++++++++++++++++++++----------- config.yaml | 9 ++++ 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index dd288cb..774e5d5 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -52,10 +52,19 @@ class CreateFormsCommand extends Command ; } + private function createOrUpdate($formManager, $formId, $data) { + $existingForm = $formManager->getOne($formId); + if ($existingForm) + return $formManager->update($data); + + return $formManager->create($data); + } + private function absencesForm(FormManager $formManager, $meeo_config) { + $formId = $meeo_config['absences']['formId']; $data = [ - "bn_id_nature" => $meeo_config['absences']['formId'], + "bn_id_nature" => $formId, "bn_label_nature" => "Absences", "bn_description" => "Absences des élèves", "bn_condition" => "", @@ -64,7 +73,7 @@ class CreateFormsCommand extends Command "bn_sem_use_template" => "1", "bn_template" => << null ]; - $existingForm = $formManager->getOne($meeo_config['absences']['formId']); - if ($existingForm) - return $formManager->update($data); - - return $formManager->create($data); + $this->createOrUpdate($formManager, $formId, $data); } private function matiereList() @@ -87,24 +92,22 @@ EOT, $tripleStore = $this->wiki->services->get(TripleStore::class); if (!$pageManager->getOne('ListeMatiere')) { - $pageManager->save('ListeMatière', '{"label":{"francais":"Français","math":"Math"},"titre_liste":"Matieres"}'); + $pageManager->save('ListeMatiere', '{"label":{"francais":"Français","math":"Math"},"titre_liste":"Matieres"}'); // in case, there is already some triples for 'ListOuinonLms', delete them - $tripleStore->delete('ListeMatière', 'http://outils-reseaux.org/_vocabulary/type', null); + $tripleStore->delete('ListeMatiere', 'http://outils-reseaux.org/_vocabulary/type', null); // create the triple to specify this page is a list - $tripleStore->create('ListeMatière', 'http://outils-reseaux.org/_vocabulary/type', 'liste', '', ''); + $tripleStore->create('ListeMatiere', 'http://outils-reseaux.org/_vocabulary/type', 'liste', '', ''); } } private function notesForm(FormManager $formManager, $meeo_config) { - $existingForm = $formManager->getOne($meeo_config['notes']['formId']); - if ($existingForm) - return false; + $formId = $meeo_config['notes']['formId']; $this->matiereList(); $data = [ - "bn_id_nature" => $meeo_config['notes']['formId'], + "bn_id_nature" => $formId, "bn_label_nature" => "Notes", "bn_description" => "Notes des élèves", "bn_condition" => "", @@ -115,7 +118,7 @@ EOT, titre***Note : {{bf_intitule}} - {{bf_eleve}} - {{bf_matiere}}***Titre Automatique*** texte***bf_intitule***Intitulé*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** liste***ListeMatière***Matière*** *** *** ***bf_matiere*** ***1*** *** *** * *** * *** *** *** *** -listefiche***5***Elève*** *** *** ***bf_eleve*** ***1*** *** *** * *** * *** *** *** *** +listefiche***6***Elève*** *** *** ***bf_eleve*** ***1*** *** *** * *** * *** *** *** *** texte***bf_note***Note***0***20*** *** ***number***1*** *** *** * *** * *** *** *** *** texte***bf_coef***Coefficient***0.5***10***1*** ***number***0*** *** *** * *** * *** *** *** *** EOT, @@ -124,32 +127,63 @@ EOT, "bn_only_one_entry_message" => null ]; - return $formManager->create($data); + $this->createOrUpdate($formManager, $formId, $data); + } + + private function classeList() + { + $pageManager = $this->wiki->services->get(PageManager::class); + $tripleStore = $this->wiki->services->get(TripleStore::class); + + if (!$pageManager->getOne('ListeClasses')) { + $pageManager->save('ListeClasses', '{"label":{},"titre_liste":"Classe"}'); + // in case, there is already some triples for 'ListOuinonLms', delete them + $tripleStore->delete('ListeClasses', 'http://outils-reseaux.org/_vocabulary/type', null); + // create the triple to specify this page is a list + $tripleStore->create('ListeClasses', 'http://outils-reseaux.org/_vocabulary/type', 'liste', '', ''); + } + } + + private function elevesForms(FormManager $formManager, $meeo_config) { + + $formId = $meeo_config['eleves']['formId']; + + $this->classeList(); + + $data = [ + "bn_id_nature" => $formId, + "bn_label_nature" => "Eleves", + "bn_description" => "Liste des élèves", + "bn_condition" => "", + "bn_sem_context" => "", + "bn_sem_type" => "", + "bn_sem_use_template" => "1", + "bn_template" => << "fr-FR", + "bn_only_one_entry" => "N", + "bn_only_one_entry_message" => null + ]; + + $this->createOrUpdate($formManager, $formId, $data); } protected function execute(InputInterface $input, OutputInterface $output) { $formManager = $this->wiki->services->get(FormManager::class); $params = $this->wiki->services->get(ParameterBagInterface::class); - if (!$params->has('meeo')) { - $result = $formManager->getAll(); - $lastFormId = array_key_last($result); - $meeo_config = [ - 'absences' => [ - 'formId' => $lastFormId + 1, - ], - 'notes' => [ - 'formId' => $lastFormId + 2, - ] - ]; - } else { - $meeo_config = $params->get('meeo'); - } + $meeo_config = $params->get('meeo'); $this->absencesForm($formManager, $meeo_config); $this->notesForm($formManager, $meeo_config); + $this->elevesForms($formManager, $meeo_config); + echo 'Succeed\n'; return Command::SUCCESS; } diff --git a/config.yaml b/config.yaml index 5563891..37bd821 100644 --- a/config.yaml +++ b/config.yaml @@ -1,4 +1,13 @@ parameters: + meeo: + eleves: + formId: 6 + absences: + formId: 7 + notes: + formId: 8 + elevesFormId: 5 + groupeEE: 'EquipeEducative' services: _defaults: autowire: true