Add Eleves listing

This commit is contained in:
mckmonster 2024-07-17 09:01:25 +02:00
parent 450836cac5
commit 18b0707ffd
2 changed files with 73 additions and 30 deletions

View file

@ -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) private function absencesForm(FormManager $formManager, $meeo_config)
{ {
$formId = $meeo_config['absences']['formId'];
$data = [ $data = [
"bn_id_nature" => $meeo_config['absences']['formId'], "bn_id_nature" => $formId,
"bn_label_nature" => "Absences", "bn_label_nature" => "Absences",
"bn_description" => "Absences des élèves", "bn_description" => "Absences des élèves",
"bn_condition" => "", "bn_condition" => "",
@ -64,7 +73,7 @@ class CreateFormsCommand extends Command
"bn_sem_use_template" => "1", "bn_sem_use_template" => "1",
"bn_template" => <<<EOT "bn_template" => <<<EOT
titre***Absence : {{bf_eleve}} - {{bf_date_debut_evenement}}***Titre Automatique*** titre***Absence : {{bf_eleve}} - {{bf_date_debut_evenement}}***Titre Automatique***
listefiche***5***Elève*** *** *** *** *** ***1*** *** *** * *** * *** *** *** *** listefiche***6***Elève*** *** *** *** *** ***1*** *** *** * *** * *** *** *** ***
listedatedeb***bf_date_debut***Debut*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** *** listedatedeb***bf_date_debut***Debut*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** ***
listedatedeb***bf_date_fin***Fin*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** *** listedatedeb***bf_date_fin***Fin*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** ***
textelong***bf_commentaire***Commentaire*** *** *** *** ***wiki***0*** *** *** * *** * *** *** *** *** textelong***bf_commentaire***Commentaire*** *** *** *** ***wiki***0*** *** *** * *** * *** *** *** ***
@ -74,11 +83,7 @@ EOT,
"bn_only_one_entry_message" => null "bn_only_one_entry_message" => null
]; ];
$existingForm = $formManager->getOne($meeo_config['absences']['formId']); $this->createOrUpdate($formManager, $formId, $data);
if ($existingForm)
return $formManager->update($data);
return $formManager->create($data);
} }
private function matiereList() private function matiereList()
@ -87,24 +92,22 @@ EOT,
$tripleStore = $this->wiki->services->get(TripleStore::class); $tripleStore = $this->wiki->services->get(TripleStore::class);
if (!$pageManager->getOne('ListeMatiere')) { 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 // 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 // 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) private function notesForm(FormManager $formManager, $meeo_config)
{ {
$existingForm = $formManager->getOne($meeo_config['notes']['formId']); $formId = $meeo_config['notes']['formId'];
if ($existingForm)
return false;
$this->matiereList(); $this->matiereList();
$data = [ $data = [
"bn_id_nature" => $meeo_config['notes']['formId'], "bn_id_nature" => $formId,
"bn_label_nature" => "Notes", "bn_label_nature" => "Notes",
"bn_description" => "Notes des élèves", "bn_description" => "Notes des élèves",
"bn_condition" => "", "bn_condition" => "",
@ -115,7 +118,7 @@ EOT,
titre***Note : {{bf_intitule}} - {{bf_eleve}} - {{bf_matiere}}***Titre Automatique*** titre***Note : {{bf_intitule}} - {{bf_eleve}} - {{bf_matiere}}***Titre Automatique***
texte***bf_intitule***Intitulé*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** texte***bf_intitule***Intitulé*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
liste***ListeMatière***Matière*** *** *** ***bf_matiere*** ***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_note***Note***0***20*** *** ***number***1*** *** *** * *** * *** *** *** ***
texte***bf_coef***Coefficient***0.5***10***1*** ***number***0*** *** *** * *** * *** *** *** *** texte***bf_coef***Coefficient***0.5***10***1*** ***number***0*** *** *** * *** * *** *** *** ***
EOT, EOT,
@ -124,32 +127,63 @@ EOT,
"bn_only_one_entry_message" => null "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" => <<<EOT
texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
texte***bf_nom***Nom complet*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
champs_mail***bf_mail***Email*** *** % *** ***form*** ***1***0*** *** * *** % *** *** *** ***
liste***ListeClasse***Liste déroulante*** *** *** ***bf_classe*** ***1*** *** *** * *** * *** *** *** ***
EOT,
"bn_ce_i18n" => "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) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$formManager = $this->wiki->services->get(FormManager::class); $formManager = $this->wiki->services->get(FormManager::class);
$params = $this->wiki->services->get(ParameterBagInterface::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->absencesForm($formManager, $meeo_config);
$this->notesForm($formManager, $meeo_config); $this->notesForm($formManager, $meeo_config);
$this->elevesForms($formManager, $meeo_config);
echo 'Succeed\n'; echo 'Succeed\n';
return Command::SUCCESS; return Command::SUCCESS;
} }

View file

@ -1,4 +1,13 @@
parameters: parameters:
meeo:
eleves:
formId: 6
absences:
formId: 7
notes:
formId: 8
elevesFormId: 5
groupeEE: 'EquipeEducative'
services: services:
_defaults: _defaults:
autowire: true autowire: true