Compare commits

..

No commits in common. "166cbfc20b7ec5047509457714f959a88c614dbb" and "ca5a094d3526c914e1d42392df381f8b6a69ebb8" have entirely different histories.

12 changed files with 67 additions and 161 deletions

View file

@ -163,8 +163,9 @@ EOT,
"bn_sem_type" => "", "bn_sem_type" => "",
"bn_sem_use_template" => "1", "bn_sem_use_template" => "1",
"bn_template" => <<<EOT "bn_template" => <<<EOT
titre***{{ bf_nom }} - {{ bf_classe }}***Titre Automatique*** texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
listefiche***$this->yunohostFormId***Liste déroulante*** *** *** ***bf_nom*** ***1*** *** *** * *** * *** *** *** *** texte***bf_nom***Nom complet*** *** *** *** ***text***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,16 +53,15 @@ 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['id_fiche'], 'bf_titre' => $yunohostEntry['bf_titre'],
'listefiche'.$yunohostFormId.'Listebf_nom' => $yunohostEntry['id_fiche'], 'bf_nom' => $yunohostEntry['bf_nom'],
'bf_mail' => $yunohostEntry['bf_mail'],
'antispam' => 1 'antispam' => 1
]); ]);
} }

View file

@ -25,24 +25,20 @@ 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') {
$eleve = $eleveController->getEleve($clef_action[0]); $datas[] = $eleveController->updateClasse($clef_action[0], $valeur);
// 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 controle(Request $request) { public function control(Request $request) {
$noteManager = $this->getService(NoteManager::class); $noteManager = $this->getService(NoteManager::class);
$content = $request->getContent(); $content = $request->getContent();
@ -56,7 +52,6 @@ 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 ApiResponse($controle); return $this->wiki->redirect('?Notes', 200);
return $this->wiki->redirect('?Bulletin', 200);
} }
} }

View file

@ -1,19 +1,9 @@
function filterClasse() { $(document).ready(function(){
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() { $("#classe").on("change", function() {
filterClasse(); var value = $(this).val().toLowerCase();
$("#eleves div.form-group").filter(function() {
var text = $(this).attr('classe').toLowerCase();
$(this).toggle(text.indexOf(value) > -1);
});
}); });
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 $eleve) { public function __construct($wiki, $eleve, $classe) {
$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');
// echo "<p>".var_dump($matieres)."</p>"; foreach ($matieres['label'] as $id => $nom) {
foreach ($matieres['nodes'] as $matiere) { $this->matieres[] = new Matiere($wiki, $this, $id, $nom);
$this->matieres[] = new Matiere($wiki, $this, $matiere["id"], $matiere["label"]);
} }
} }
public function getId() { public function getId() {
return $this->eleve->getId(); return $this->eleve['id_fiche'];
} }
public function getNom() { public function getNom() {
return $this->eleve->getNom(); return $this->eleve['bf_nom'];
} }
public function getClasse() { public function getClass() {
return $this->eleve->getClasse(); return $this->classe;
} }
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 true; return false;
} }
return false; return true;
} }
} }
} }

View file

@ -17,14 +17,12 @@ 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']);
} }
} }

View file

@ -1,51 +0,0 @@
<?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,13 +2,10 @@
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 {
@ -30,32 +27,12 @@ class EleveManager {
$this->entryManager->delete($id); $this->entryManager->delete($id);
} }
public function updateEleve(Eleve $eleve) { public function updateClasse($id, $classe) {
$id = $eleve->getId(); return $this->entryManager->update($id, ['listeListeClassesbf_classe' => $classe, 'antispam' => true]);
$data = $eleve->getData();
$data['antispam'] = true;
echo var_dump($data);
return $this->entryManager->update($id, $data);
} }
public function getAll() { public function getAll() {
$eleves = []; return $this->entryManager->search(['formsIds' => $this->formId]);
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() {
@ -63,7 +40,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['nodes']]); return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['label']]);
} }
} }

View file

@ -1,6 +1,7 @@
<?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;
@ -32,29 +33,28 @@ 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';
$currentEleve = $eleveManager->getCurrentEleve($username); $bulletins = [];
// echo "<p>".var_dump($currentEleve)."</p>"; foreach ( $eleves as $eleve) {
// if ($currentEleve == null) { //TODO enlever "Passerelle"
$eleves = $eleveManager->getAll(); $bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle");
}
// echo "<p>".var_dump($eleves)."</p>";
// echo "<p>".var_dump($entries)."</p>";
// echo "<p>".var_dump($bulletins)."</p>";
$bulletins = []; return $this->wiki->render('@meeo/edu_notes.twig', [
foreach ( $eleves as $eleve) { "bulletins" => $bulletins,
$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 {
// $bulletin = new Bulletin($this->wiki, $currentEleve); // $entries = $entryManager->search(['formsIds' => $this->formId]);
// return $this->wiki->render('@meeo/eleve_notes.twig', [ // return $this->wiki->render('@meeo/eleve_notes.twig', [
// "bulletin" => $bulletin, // "bulletin" => $bulletin,
// ]); // ]);
@ -68,14 +68,11 @@ 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['nodes'], 'classes' => $classes['nodes'], 'eleves' => $eleves]); return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['label'], 'classes' => $classes['label'], 'eleves' => $eleves]);
} }
public function createNote($intitule, $eleve, $matiere, $note, $coef) { public function createNote($intitule, $eleve, $matiere, $note, $coef) {
if ($note == 0) $note = [
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,
@ -84,7 +81,7 @@ class NoteManager {
'bf_coef' => $coef, 'bf_coef' => $coef,
'antispam' => true 'antispam' => true
]; ];
$this->entryManager->create($this->formId, $data); $this->entryManager->create($this->formId, $note);
} }
public function getNotes($eleveId, $matiereId) { public function getNotes($eleveId, $matiereId) {
@ -92,7 +89,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' => \strtolower($eleveId), 'listefiche'.$this->eleveFormId.'bf_eleve' => $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 matiere in matieres %} {% for clef, matiere in matieres %}
<option value="{{ matiere['id'] }}">{{ matiere['label'] }}</option> <option value="{{ clef }}">{{ matiere }}</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 value="{{ classe['id'] }}" >{{ classe['label'] }}</option> <option>{{ classe }}</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.getClasse() }}"> <div class="form-group" classe="{{ eleve['listeListeClassesbf_classe'] }}" hidden>
<label class="control-label col-sm-2" for="eleve_{{ eleve.getId() }}">{{ eleve.getNom() }}</label> <label class="control-label col-sm-2" for="{{ eleve['id_fiche'] }}">{{ eleve['bf_nom'] }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="number" class="form-control" id="eleve_{{ eleve.getId() }}" name="eleve_{{ eleve.getId() }}" min="0" max="20" step="0.1" required> <input type="number" class="form-control" id="{{ eleve['id_fiche'] }}" name="eleve_{{ eleve['id_fiche'] }}" 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.getId() }}" name="{{ eleve.getId() }}"> <div class="row form-group" id="{{eleve['id_fiche']}}" name="{{eleve['id_fiche']}}">
<div class="col-sm-8">{{ eleve.getNom() }}</div> <div class="col-sm-8">{{ eleve['bf_nom'] }}</div>
<div class="col-sm-3"> <div class="col-sm-3">
<select id="{{ eleve.getId() }}_classe" name="{{ eleve.getId() }}_classe" class="form-control"> <select id="{{eleve['id_fiche']}}_classe" name="{{eleve['id_fiche']}}_classe" class="form-control">
{% for classe in classes %} {% for identifier, classe in classes %}
<option value="{{classe['id']}}" {% if eleve.classe == classe['id'] %}selected{% endif %} >{{classe['label']}}</option> <option value="{{identifier}}" {% if eleve['listeListeClassesbf_classe'] == identifier %}selected{% endif %} >{{classe}}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="col-sm-1 text-center"> <div class="col-sm-1 text-center">
<input id="{{eleve.getId()}}_del" name="{{eleve.getId()}}_del" class="form-check-input" type="checkbox" value=""/> <input id="{{eleve['id_fiche']}}_del" name="{{eleve['id_fiche']}}_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.getClasse() }}</div> <div class="col-sm-9">{{ bulletin.getClass() }}</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>