[Eleves] Changement sur la db pour les élèves

This commit is contained in:
mckmonster 2024-07-27 14:14:54 +02:00
parent ca5a094d35
commit b70cc3dc59
5 changed files with 60 additions and 15 deletions

View file

@ -163,9 +163,8 @@ EOT,
"bn_sem_type" => "", "bn_sem_type" => "",
"bn_sem_use_template" => "1", "bn_sem_use_template" => "1",
"bn_template" => <<<EOT "bn_template" => <<<EOT
texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** titre***{{ bf_nom }} - {{ classe }}***Titre Automatique***
texte***bf_nom***Nom complet*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** listefiche***$this->yunohostFormId***Liste déroulante*** *** *** ***bf_nom*** ***1*** *** *** * *** * *** *** *** ***
champs_mail***bf_mail***Email*** *** % *** ***form*** ***1***0*** *** * *** % *** *** *** ***
liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** *** liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** ***
EOT, EOT,
"bn_ce_i18n" => "fr-FR", "bn_ce_i18n" => "fr-FR",

View file

@ -53,15 +53,16 @@ class UpdateElevesFromYunohostCommand extends Command {
$elevesFormId = $meeo_config['elevesFormId']; $elevesFormId = $meeo_config['elevesFormId'];
$yunohostEntries = $entryManager->search(['formsIds' => $yunohostFormId]); $yunohostEntries = $entryManager->search(['formsIds' => $yunohostFormId]);
// echo var_dump($yunohostEntries)."\n";
foreach ($yunohostEntries as $yunohostEntry) { foreach ($yunohostEntries as $yunohostEntry) {
// echo var_dump($yunohostEntry)."\n";
$eleveEntry = $entryManager->search(['formsIds' => $elevesFormId, 'queries' => [ $eleveEntry = $entryManager->search(['formsIds' => $elevesFormId, 'queries' => [
'bf_titre' => $yunohostEntry['bf_titre'] 'bf_titre' => $yunohostEntry['bf_titre']
]]); ]]);
if ($eleveEntry == null) { if ($eleveEntry == null) {
$entryManager->create($elevesFormId, [ $entryManager->create($elevesFormId, [
'bf_titre' => $yunohostEntry['bf_titre'], 'bf_titre' => $yunohostEntry['id_fiche'],
'bf_nom' => $yunohostEntry['bf_nom'], 'listefiche'.$this->yunohostFormId.'Listebf_nom' => $yunohostEntry['id_fiche'],
'bf_mail' => $yunohostEntry['bf_mail'],
'antispam' => 1 'antispam' => 1
]); ]);
} }

30
libs/eleves/eleve.lib.php Normal file
View file

@ -0,0 +1,30 @@
<?php
namespace YesWiki\Meeo\Eleve;
use YesWiki\Bazar\Service\EntryManager;
class Eleve {
public $data;
public $classe;
public $user;
public function __construct(EntryManager $entryManager, $data) {
$this->data = $data;
$this->classe = $data['listeListeClassesbf_classe'];
$this->user = $entryManager->getOne($data['listeficheListebf_nom']);
// echo "<p>".var_dump($this)."</p>";
}
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'];
}
}
}

View file

@ -6,6 +6,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YesWiki\Bazar\Service\EntryManager; use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Bazar\Service\ListManager; use YesWiki\Bazar\Service\ListManager;
use YesWiki\Wiki; use YesWiki\Wiki;
use YesWiki\Meeo\Eleve\Eleve;
class EleveManager { class EleveManager {
@ -32,7 +33,21 @@ class EleveManager {
} }
public function getAll() { 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 "<p>".var_dump($eleve)."</p>";
$eleves[] = $eleve;
}
return $eleves;
}
public function getCurrentEleve(string $username) {
return $this->entryManager->getOne(str_replace(".","", $username));
} }
public function view() { public function view() {
@ -40,7 +55,7 @@ class EleveManager {
// echo '<p>'.var_dump($eleves).'</p>'; // echo '<p>'.var_dump($eleves).'</p>';
$classes = $this->listManager->getOne('ListeClasses'); $classes = $this->listManager->getOne('ListeClasses');
// echo "<p>".var_dump($classes)."</p>";
return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['label']]); return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['nodes']]);
} }
} }

View file

@ -6,17 +6,17 @@
</div> </div>
<form action="?api/meeo/eleves" method="post" enctype="application/json"> <form action="?api/meeo/eleves" method="post" enctype="application/json">
{% for eleve in eleves|sort %} {% for eleve in eleves|sort %}
<div class="row form-group" id="{{eleve['id_fiche']}}" name="{{eleve['id_fiche']}}"> <div class="row form-group" id="{{ eleve.getId() }}" name="{{ eleve.getId() }}">
<div class="col-sm-8">{{ eleve['bf_nom'] }}</div> <div class="col-sm-8">{{ eleve.getNom() }}</div>
<div class="col-sm-3"> <div class="col-sm-3">
<select id="{{eleve['id_fiche']}}_classe" name="{{eleve['id_fiche']}}_classe" class="form-control"> <select id="{{ eleve.getId() }}_classe" name="{{ eleve.getId() }}_classe" class="form-control">
{% for identifier, classe in classes %} {% for classe in classes %}
<option value="{{identifier}}" {% if eleve['listeListeClassesbf_classe'] == identifier %}selected{% endif %} >{{classe}}</option> <option value="{{classe['id']}}" {% if eleve.classe == classe['id'] %}selected{% endif %} >{{classe['label']}}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="col-sm-1 text-center"> <div class="col-sm-1 text-center">
<input id="{{eleve['id_fiche']}}_del" name="{{eleve['id_fiche']}}_del" class="form-check-input" type="checkbox" value=""/> <input id="{{eleve.getId()}}_del" name="{{eleve.getId()}}_del" class="form-check-input" type="checkbox" value=""/>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}