diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index cc1c81d..ee0ae04 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -163,9 +163,8 @@ EOT, "bn_sem_type" => "", "bn_sem_use_template" => "1", "bn_template" => <<yunohostFormId***Liste déroulante*** *** *** ***bf_nom*** ***1*** *** *** * *** * *** *** *** *** liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** *** EOT, "bn_ce_i18n" => "fr-FR", diff --git a/commands/UpdateElevesFromYunohostCommand.php b/commands/UpdateElevesFromYunohostCommand.php index 964d2c6..1ed3921 100644 --- a/commands/UpdateElevesFromYunohostCommand.php +++ b/commands/UpdateElevesFromYunohostCommand.php @@ -53,15 +53,16 @@ class UpdateElevesFromYunohostCommand extends Command { $elevesFormId = $meeo_config['elevesFormId']; $yunohostEntries = $entryManager->search(['formsIds' => $yunohostFormId]); + // echo var_dump($yunohostEntries)."\n"; foreach ($yunohostEntries as $yunohostEntry) { + // echo var_dump($yunohostEntry)."\n"; $eleveEntry = $entryManager->search(['formsIds' => $elevesFormId, 'queries' => [ 'bf_titre' => $yunohostEntry['bf_titre'] ]]); if ($eleveEntry == null) { $entryManager->create($elevesFormId, [ - 'bf_titre' => $yunohostEntry['bf_titre'], - 'bf_nom' => $yunohostEntry['bf_nom'], - 'bf_mail' => $yunohostEntry['bf_mail'], + 'bf_titre' => $yunohostEntry['id_fiche'], + 'listefiche'.$this->yunohostFormId.'Listebf_nom' => $yunohostEntry['id_fiche'], 'antispam' => 1 ]); } diff --git a/libs/eleves/eleve.lib.php b/libs/eleves/eleve.lib.php new file mode 100644 index 0000000..bf76a77 --- /dev/null +++ b/libs/eleves/eleve.lib.php @@ -0,0 +1,30 @@ +data = $data; + $this->classe = $data['listeListeClassesbf_classe']; + $this->user = $entryManager->getOne($data['listeficheListebf_nom']); + // echo "

".var_dump($this)."

"; + } + + public function getId() { + return $this->data['id_fiche']; + } + + public function getNom() { + if (empty($this->user['bf_nom'])) { + return $this->user['bf_titre']; + } else { + return $this->user['bf_nom']; + } + } +} \ No newline at end of file diff --git a/services/EleveManager.php b/services/EleveManager.php index 9fb68c3..0f5f5d0 100644 --- a/services/EleveManager.php +++ b/services/EleveManager.php @@ -6,6 +6,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use YesWiki\Bazar\Service\EntryManager; use YesWiki\Bazar\Service\ListManager; use YesWiki\Wiki; +use YesWiki\Meeo\Eleve\Eleve; class EleveManager { @@ -32,7 +33,21 @@ class EleveManager { } public function getAll() { - return $this->entryManager->search(['formsIds' => $this->formId]); + include 'tools/meeo/libs/eleves/eleve.lib.php'; + + $eleves = []; + foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data) + { + + $eleve = new Eleve($this->entryManager, $data); + // echo "

".var_dump($eleve)."

"; + $eleves[] = $eleve; + } + return $eleves; + } + + public function getCurrentEleve(string $username) { + return $this->entryManager->getOne(str_replace(".","", $username)); } public function view() { @@ -40,7 +55,7 @@ class EleveManager { // echo '

'.var_dump($eleves).'

'; $classes = $this->listManager->getOne('ListeClasses'); - - return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['label']]); + // echo "

".var_dump($classes)."

"; + return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['nodes']]); } } \ No newline at end of file diff --git a/templates/edu_eleves.twig b/templates/edu_eleves.twig index b3f6d43..1c1f751 100644 --- a/templates/edu_eleves.twig +++ b/templates/edu_eleves.twig @@ -6,17 +6,17 @@
{% for eleve in eleves|sort %} -
-
{{ eleve['bf_nom'] }}
+
+
{{ eleve.getNom() }}
- + {% for classe in classes %} + {% endfor %}
- +
{% endfor %}