Fix sur la creation de controle

This commit is contained in:
mckmonster 2024-07-27 17:19:40 +02:00
parent 20f5541d41
commit 8fe95ee094
6 changed files with 62 additions and 44 deletions

View file

@ -42,7 +42,7 @@ class ApiController extends YesWikiController
/**
* @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();
@ -56,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;
return $this->eleve->classe;
}
public function getMoyenne() {

View file

@ -17,6 +17,7 @@ class Matiere {
$this->nom = $nom;
$eleveId = $bulletin->getId();
// echo "<p>".$eleveId."</p>";
$noteManager = $wiki->services->get(NoteManager::class);
$entries = $noteManager->getNotes($eleveId, $id);

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,17 +32,25 @@ 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();
// $eleves = $ $this->entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
// $entries = $this->entryManager->search(['formsIds' => $this->formId]);
$bulletins = [];
foreach ( $eleves as $eleve) {
//TODO enlever "Passerelle"
$bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle");
$bulletin = new Bulletin($this->wiki, $eleve, "Passerelle");
if ($bulletin->isVisible())
$bulletins[] = $bulletin;
}
// echo "<p>".var_dump($eleves)."</p>";
// echo "<p>".var_dump($entries)."</p>";
@ -53,8 +60,7 @@ class NoteManager {
"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,7 +74,7 @@ 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) {
@ -85,11 +91,11 @@ class NoteManager {
}
public function getNotes($eleveId, $matiereId) {
// echo "<p>".$eleveId."</p>";
// echo "<p>".$matiereId."</p>";
echo "<p>".$eleveId."</p>";
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 %}