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_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 }} - {{ bf_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",

View file

@ -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'.$yunohostFormId.'Listebf_nom' => $yunohostEntry['id_fiche'],
'antispam' => 1
]);
}

View file

@ -25,20 +25,24 @@ class ApiController extends YesWikiController
foreach ($parameters as $cle => $valeur) {
$clef_action = explode('_', $cle);
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') {
$eleveController->del($clef_action[0]);
}
}
// return ApiResponse($data);
return $this->wiki->redirect('?Eleves', 200);
}
/**
* @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}})
*/
public function control(Request $request) {
public function controle(Request $request) {
$noteManager = $this->getService(NoteManager::class);
$content = $request->getContent();
@ -52,6 +56,7 @@ class ApiController extends YesWikiController
$controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves);
$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(){
$("#classe").on("change", function() {
var value = $(this).val().toLowerCase();
function filterClasse() {
var value = $("#classe").val().toLowerCase();
$("#eleves div.form-group").filter(function() {
var text = $(this).attr('classe').toLowerCase();
$(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';
use YesWiki\Bazar\Service\ListManager;
use YesWiki\Meeo\Eleve\Eleve;
class Bulletin {
private $eleve;
private $classe;
private $matieres = [];
public function __construct($wiki, $eleve, $classe) {
public function __construct($wiki, Eleve $eleve) {
$this->eleve = $eleve;
// echo var_dump($eleve);
$this->classe = $classe;
$listManager = $wiki->services->get(ListManager::class);
$matieres = $listManager->getOne('ListeMatiere');
foreach ($matieres['label'] as $id => $nom) {
$this->matieres[] = new Matiere($wiki, $this, $id, $nom);
// echo "<p>".var_dump($matieres)."</p>";
foreach ($matieres['nodes'] as $matiere) {
$this->matieres[] = new Matiere($wiki, $this, $matiere["id"], $matiere["label"]);
}
}
public function getId() {
return $this->eleve['id_fiche'];
return $this->eleve->getId();
}
public function getNom() {
return $this->eleve['bf_nom'];
return $this->eleve->getNom();
}
public function getClass() {
return $this->classe;
public function getClasse() {
return $this->eleve->getClasse();
}
public function getMoyenne() {
@ -53,10 +53,10 @@ class Bulletin {
public function isVisible() {
foreach ($this->matieres as $matiere) {
if ( !$matiere->isVisible() ) {
return false;
}
if ( $matiere->isVisible() ) {
return true;
}
return false;
}
}
}

View file

@ -17,12 +17,14 @@ class Matiere {
$this->nom = $nom;
$eleveId = $bulletin->getId();
// echo "<p>".$eleveId."</p>";
$noteManager = $wiki->services->get(NoteManager::class);
$entries = $noteManager->getNotes($eleveId, $id);
// echo "<p>".var_dump($entries)."</p>";
foreach ($entries as $entry) {
if (!empty($entry['bf_note']))
$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;
include 'tools/meeo/libs/eleves/eleve.lib.php';
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 {
@ -27,12 +30,32 @@ class EleveManager {
$this->entryManager->delete($id);
}
public function updateClasse($id, $classe) {
return $this->entryManager->update($id, ['listeListeClassesbf_classe' => $classe, 'antispam' => true]);
public function updateEleve(Eleve $eleve) {
$id = $eleve->getId();
$data = $eleve->getData();
$data['antispam'] = true;
echo var_dump($data);
return $this->entryManager->update($id, $data);
}
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() {
@ -40,7 +63,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']]);
}
}

View file

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

View file

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

View file

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

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">
<h4 class="panel-title">{{ bulletin.getNom() }}</h4>
<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>
</button>