[Eleves] Changement sur la db pour les élèves
This commit is contained in:
parent
ca5a094d35
commit
b70cc3dc59
5 changed files with 60 additions and 15 deletions
|
@ -163,9 +163,8 @@ EOT,
|
|||
"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*** *** * *** % *** *** *** ***
|
||||
titre***{{ bf_nom }} - {{ classe }}***Titre Automatique***
|
||||
listefiche***$this->yunohostFormId***Liste déroulante*** *** *** ***bf_nom*** ***1*** *** *** * *** * *** *** *** ***
|
||||
liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** ***
|
||||
EOT,
|
||||
"bn_ce_i18n" => "fr-FR",
|
||||
|
|
|
@ -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
|
||||
]);
|
||||
}
|
||||
|
|
30
libs/eleves/eleve.lib.php
Normal file
30
libs/eleves/eleve.lib.php
Normal 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'];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 "<p>".var_dump($eleve)."</p>";
|
||||
$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 '<p>'.var_dump($eleves).'</p>';
|
||||
|
||||
$classes = $this->listManager->getOne('ListeClasses');
|
||||
|
||||
return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['label']]);
|
||||
// echo "<p>".var_dump($classes)."</p>";
|
||||
return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['nodes']]);
|
||||
}
|
||||
}
|
|
@ -6,17 +6,17 @@
|
|||
</div>
|
||||
<form action="?api/meeo/eleves" method="post" enctype="application/json">
|
||||
{% for eleve in eleves|sort %}
|
||||
<div class="row form-group" id="{{eleve['id_fiche']}}" name="{{eleve['id_fiche']}}">
|
||||
<div class="col-sm-8">{{ eleve['bf_nom'] }}</div>
|
||||
<div class="row form-group" id="{{ eleve.getId() }}" name="{{ eleve.getId() }}">
|
||||
<div class="col-sm-8">{{ eleve.getNom() }}</div>
|
||||
<div class="col-sm-3">
|
||||
<select id="{{eleve['id_fiche']}}_classe" name="{{eleve['id_fiche']}}_classe" class="form-control">
|
||||
{% for identifier, classe in classes %}
|
||||
<option value="{{identifier}}" {% if eleve['listeListeClassesbf_classe'] == identifier %}selected{% endif %} >{{classe}}</option>
|
||||
<select id="{{ eleve.getId() }}_classe" name="{{ eleve.getId() }}_classe" class="form-control">
|
||||
{% for classe in classes %}
|
||||
<option value="{{classe['id']}}" {% if eleve.classe == classe['id'] %}selected{% endif %} >{{classe['label']}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<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>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue