Compare commits

...

4 commits

Author SHA1 Message Date
mckmonster
166cbfc20b Fix bulletin 2024-07-27 17:37:51 +02:00
mckmonster
8fe95ee094 Fix sur la creation de controle 2024-07-27 17:19:40 +02:00
mckmonster
20f5541d41 [Eleves] Fix sur les élèves 2024-07-27 15:22:09 +02:00
mckmonster
b70cc3dc59 [Eleves] Changement sur la db pour les élèves 2024-07-27 14:14:54 +02:00
12 changed files with 162 additions and 68 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 }} - {{ bf_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'.$yunohostFormId.'Listebf_nom' => $yunohostEntry['id_fiche'],
'bf_mail' => $yunohostEntry['bf_mail'],
'antispam' => 1 'antispam' => 1
]); ]);
} }

View file

@ -25,20 +25,24 @@ class ApiController extends YesWikiController
foreach ($parameters as $cle => $valeur) { foreach ($parameters as $cle => $valeur) {
$clef_action = explode('_', $cle); $clef_action = explode('_', $cle);
if ($clef_action[1] == 'classe' && $valeur != 'aucune') { if ($clef_action[1] == 'classe' && $valeur != 'aucune') {
$datas[] = $eleveController->updateClasse($clef_action[0], $valeur); $eleve = $eleveController->getEleve($clef_action[0]);
// echo var_dump($valeur);
$eleve->setClasse($valeur);
echo var_dump($eleve);
$datas[] = $eleveController->updateEleve($eleve);
} }
if ($clef_action[1] == 'del') { if ($clef_action[1] == 'del') {
$eleveController->del($clef_action[0]); $eleveController->del($clef_action[0]);
} }
} }
// return ApiResponse($data);
return $this->wiki->redirect('?Eleves', 200); return $this->wiki->redirect('?Eleves', 200);
} }
/** /**
* @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}}) * @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}})
*/ */
public function control(Request $request) { public function controle(Request $request) {
$noteManager = $this->getService(NoteManager::class); $noteManager = $this->getService(NoteManager::class);
$content = $request->getContent(); $content = $request->getContent();
@ -52,6 +56,7 @@ class ApiController extends YesWikiController
$controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves); $controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves);
$controle->createNotes($noteManager); $controle->createNotes($noteManager);
return $this->wiki->redirect('?Notes', 200); // return ApiResponse($controle);
return $this->wiki->redirect('?Bulletin', 200);
} }
} }

View file

@ -1,9 +1,19 @@
$(document).ready(function(){ function filterClasse() {
$("#classe").on("change", function() { var value = $("#classe").val().toLowerCase();
var value = $(this).val().toLowerCase(); $("#eleves div.form-group").filter(function() {
$("#eleves div.form-group").filter(function() { var text = $(this).attr('classe').toLowerCase();
var text = $(this).attr('classe').toLowerCase(); $(this).toggle(text.indexOf(value) > -1);
$(this).toggle(text.indexOf(value) > -1); if (text.indexOf(value) > -1)
}); $(this).find('.form-control').removeAttr('required');
else
$(this).find('.form-control').addAttr('required');
}); });
}
jQuery(function(){
$("#classe").on("change", function() {
filterClasse();
});
filterClasse();
}); });

View file

@ -5,34 +5,34 @@ namespace YesWiki\Meeo\Bulletin;
include 'tools/meeo/libs/bulletin/Matiere.lib.php'; include 'tools/meeo/libs/bulletin/Matiere.lib.php';
use YesWiki\Bazar\Service\ListManager; use YesWiki\Bazar\Service\ListManager;
use YesWiki\Meeo\Eleve\Eleve;
class Bulletin { class Bulletin {
private $eleve; private $eleve;
private $classe;
private $matieres = []; private $matieres = [];
public function __construct($wiki, $eleve, $classe) { public function __construct($wiki, Eleve $eleve) {
$this->eleve = $eleve; $this->eleve = $eleve;
// echo var_dump($eleve); // echo var_dump($eleve);
$this->classe = $classe;
$listManager = $wiki->services->get(ListManager::class); $listManager = $wiki->services->get(ListManager::class);
$matieres = $listManager->getOne('ListeMatiere'); $matieres = $listManager->getOne('ListeMatiere');
foreach ($matieres['label'] as $id => $nom) { // echo "<p>".var_dump($matieres)."</p>";
$this->matieres[] = new Matiere($wiki, $this, $id, $nom); foreach ($matieres['nodes'] as $matiere) {
$this->matieres[] = new Matiere($wiki, $this, $matiere["id"], $matiere["label"]);
} }
} }
public function getId() { public function getId() {
return $this->eleve['id_fiche']; return $this->eleve->getId();
} }
public function getNom() { public function getNom() {
return $this->eleve['bf_nom']; return $this->eleve->getNom();
} }
public function getClass() { public function getClasse() {
return $this->classe; return $this->eleve->getClasse();
} }
public function getMoyenne() { public function getMoyenne() {
@ -53,10 +53,10 @@ class Bulletin {
public function isVisible() { public function isVisible() {
foreach ($this->matieres as $matiere) { foreach ($this->matieres as $matiere) {
if ( !$matiere->isVisible() ) { if ( $matiere->isVisible() ) {
return false; return true;
} }
return true; return false;
} }
} }
} }

View file

@ -17,12 +17,14 @@ class Matiere {
$this->nom = $nom; $this->nom = $nom;
$eleveId = $bulletin->getId(); $eleveId = $bulletin->getId();
// echo "<p>".$eleveId."</p>";
$noteManager = $wiki->services->get(NoteManager::class); $noteManager = $wiki->services->get(NoteManager::class);
$entries = $noteManager->getNotes($eleveId, $id); $entries = $noteManager->getNotes($eleveId, $id);
// echo "<p>".var_dump($entries)."</p>"; // echo "<p>".var_dump($entries)."</p>";
foreach ($entries as $entry) { foreach ($entries as $entry) {
if (!empty($entry['bf_note']))
$this->notes[] = new Note($entry['bf_intitule'], $entry['bf_note'], $entry['bf_coef']); $this->notes[] = new Note($entry['bf_intitule'], $entry['bf_note'], $entry['bf_coef']);
} }
} }

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

@ -0,0 +1,51 @@
<?php
namespace YesWiki\Meeo\Eleve;
use YesWiki\Bazar\Service\EntryManager;
class Eleve {
private $data;
private $user;
public function __construct(EntryManager $entryManager, $data) {
$this->data = $data;
// echo "<p>".var_dump($data)."</p>";
//TODO récupérer le bon numéro de liste
if (empty($data['listefiche5Listebf_nom']))
$userId = $data['listefichebf_nom'];
else
$userId = $data['listefiche5Listebf_nom'];
$this->user = $entryManager->getOne($userId);
// 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'];
}
}
public function getClasse() {
if (empty($this->data['listeListeClassesbf_classe'])) {
return $this->data['bf_classe'];
}
return $this->data['listeListeClassesbf_classe'];
}
public function setClasse(string $classe) {
$this->data['listeListeClassesbf_classe'] = $classe;
}
public function getData() {
return $this->data;
}
}

View file

@ -2,10 +2,13 @@
namespace YesWiki\Meeo\Service; namespace YesWiki\Meeo\Service;
include 'tools/meeo/libs/eleves/eleve.lib.php';
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; 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 {
@ -27,12 +30,32 @@ class EleveManager {
$this->entryManager->delete($id); $this->entryManager->delete($id);
} }
public function updateClasse($id, $classe) { public function updateEleve(Eleve $eleve) {
return $this->entryManager->update($id, ['listeListeClassesbf_classe' => $classe, 'antispam' => true]); $id = $eleve->getId();
$data = $eleve->getData();
$data['antispam'] = true;
echo var_dump($data);
return $this->entryManager->update($id, $data);
} }
public function getAll() { public function getAll() {
return $this->entryManager->search(['formsIds' => $this->formId]); $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 getEleve(string $id) {
return new Eleve($this->entryManager, $this->entryManager->getOne($id));
}
public function getCurrentEleve(string $username) {
return $this->entryManager->getOne(str_replace(".","", $username));
} }
public function view() { public function view() {
@ -40,7 +63,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

@ -1,7 +1,6 @@
<?php <?php
namespace YesWiki\Meeo\Service; namespace YesWiki\Meeo\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; 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;
@ -33,28 +32,29 @@ class NoteManager {
} }
public function viewBulletins() { public function viewBulletins() {
$eleveManager = $this->wiki->services->get(EleveManager::class);
$username = $this->authController->getLoggedUserName(); $username = $this->authController->getLoggedUserName();
// echo "<p>".$username."</p>";
$eleves = $this->wiki->services->get(EleveManager::class)->getAll();
// $eleves = $ $this->entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
$entries = $this->entryManager->search(['formsIds' => $this->formId]);
include 'tools/meeo/libs/bulletin/Bulletin.lib.php'; include 'tools/meeo/libs/bulletin/Bulletin.lib.php';
$bulletins = []; $currentEleve = $eleveManager->getCurrentEleve($username);
foreach ( $eleves as $eleve) { // echo "<p>".var_dump($currentEleve)."</p>";
//TODO enlever "Passerelle" // if ($currentEleve == null) {
$bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle"); $eleves = $eleveManager->getAll();
}
// echo "<p>".var_dump($eleves)."</p>";
// echo "<p>".var_dump($entries)."</p>";
// echo "<p>".var_dump($bulletins)."</p>";
return $this->wiki->render('@meeo/edu_notes.twig', [ $bulletins = [];
"bulletins" => $bulletins, foreach ( $eleves as $eleve) {
]); $bulletins[] = new Bulletin($this->wiki, $eleve);
}
// echo "<p>".var_dump($eleves)."</p>";
// echo "<p>".var_dump($bulletins)."</p>";
return $this->wiki->render('@meeo/edu_notes.twig', [
"bulletins" => $bulletins,
]);
// } else { // } else {
// $entries = $entryManager->search(['formsIds' => $this->formId]); // $bulletin = new Bulletin($this->wiki, $currentEleve);
// return $this->wiki->render('@meeo/eleve_notes.twig', [ // return $this->wiki->render('@meeo/eleve_notes.twig', [
// "bulletin" => $bulletin, // "bulletin" => $bulletin,
// ]); // ]);
@ -68,11 +68,14 @@ class NoteManager {
// echo var_dump($matieres); // echo var_dump($matieres);
$classes = $this->listManager->getOne('ListeClasses'); $classes = $this->listManager->getOne('ListeClasses');
// echo var_dump($classes); // echo var_dump($classes);
return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['label'], 'classes' => $classes['label'], 'eleves' => $eleves]); return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['nodes'], 'classes' => $classes['nodes'], 'eleves' => $eleves]);
} }
public function createNote($intitule, $eleve, $matiere, $note, $coef) { public function createNote($intitule, $eleve, $matiere, $note, $coef) {
$note = [ if ($note == 0)
return;
$data = [
'bf_titre' => "Note : ".$intitule." - ".$eleve." - ".$matiere, 'bf_titre' => "Note : ".$intitule." - ".$eleve." - ".$matiere,
'bf_intitule' => $intitule, 'bf_intitule' => $intitule,
'listeListeMatierebf_matiere' => $matiere, 'listeListeMatierebf_matiere' => $matiere,
@ -81,7 +84,7 @@ class NoteManager {
'bf_coef' => $coef, 'bf_coef' => $coef,
'antispam' => true 'antispam' => true
]; ];
$this->entryManager->create($this->formId, $note); $this->entryManager->create($this->formId, $data);
} }
public function getNotes($eleveId, $matiereId) { public function getNotes($eleveId, $matiereId) {
@ -89,7 +92,7 @@ class NoteManager {
// echo "<p>".$matiereId."</p>"; // echo "<p>".$matiereId."</p>";
$entries = $this->entryManager->search(['formsIds' => $this->formId, $entries = $this->entryManager->search(['formsIds' => $this->formId,
'queries' =>[ 'queries' =>[
'listefiche'.$this->eleveFormId.'bf_eleve' => $eleveId, 'listefiche'.$this->eleveFormId.'bf_eleve' => \strtolower($eleveId),
'listeListeMatierebf_matiere' => $matiereId 'listeListeMatierebf_matiere' => $matiereId
] ]
]); ]);

View file

@ -11,8 +11,8 @@
<label class="control-label col-sm-2" for="matiere">Matière:</label> <label class="control-label col-sm-2" for="matiere">Matière:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<select class="form-control" id="matiere" name="matiere" required> <select class="form-control" id="matiere" name="matiere" required>
{% for clef, matiere in matieres %} {% for matiere in matieres %}
<option value="{{ clef }}">{{ matiere }}</option> <option value="{{ matiere['id'] }}">{{ matiere['label'] }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -22,7 +22,7 @@
<div class="col-sm-10"> <div class="col-sm-10">
<select class="form-control" id="classe" name="classe" required> <select class="form-control" id="classe" name="classe" required>
{% for classe in classes %} {% for classe in classes %}
<option>{{ classe }}</option> <option value="{{ classe['id'] }}" >{{ classe['label'] }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -37,10 +37,10 @@
<h2>Eleves</h2> <h2>Eleves</h2>
<div id="eleves" name="eleves"> <div id="eleves" name="eleves">
{% for eleve in eleves %} {% for eleve in eleves %}
<div class="form-group" classe="{{ eleve['listeListeClassesbf_classe'] }}" hidden> <div class="form-group" classe="{{ eleve.getClasse() }}">
<label class="control-label col-sm-2" for="{{ eleve['id_fiche'] }}">{{ eleve['bf_nom'] }}</label> <label class="control-label col-sm-2" for="eleve_{{ eleve.getId() }}">{{ eleve.getNom() }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="number" class="form-control" id="{{ eleve['id_fiche'] }}" name="eleve_{{ eleve['id_fiche'] }}" min="0" max="20" step="0.1" required> <input type="number" class="form-control" id="eleve_{{ eleve.getId() }}" name="eleve_{{ eleve.getId() }}" min="0" max="20" step="0.1" required>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

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 %}

View file

@ -5,7 +5,7 @@
<button id="head_{{ bulletin.getId() }}" class="panel-heading collapsed" data-parent="#accordion_bulletins" data-target="#{{ bulletin.getId() }}" data-toggle="collapse"> <button id="head_{{ bulletin.getId() }}" class="panel-heading collapsed" data-parent="#accordion_bulletins" data-target="#{{ bulletin.getId() }}" data-toggle="collapse">
<h4 class="panel-title">{{ bulletin.getNom() }}</h4> <h4 class="panel-title">{{ bulletin.getNom() }}</h4>
<div class="row"> <div class="row">
<div class="col-sm-9">{{ bulletin.getClass() }}</div> <div class="col-sm-9">{{ bulletin.getClasse() }}</div>
<div class="col-sm-3">Moyenne Générale : {{ bulletin.getMoyenne() }}</div> <div class="col-sm-3">Moyenne Générale : {{ bulletin.getMoyenne() }}</div>
</div> </div>
</button> </button>