- Fix pour afficher les bulletins

- Redirection vers la page Notes après l'enregistrement d'un controle
This commit is contained in:
mckmonster 2024-07-21 11:17:17 +02:00
parent 573d5753b2
commit 0664776352
6 changed files with 58 additions and 42 deletions

View file

@ -15,6 +15,6 @@ class NotesAction extends YesWikiAction
public function run() public function run()
{ {
$noteManager = $this->getService(NoteManager::class); $noteManager = $this->getService(NoteManager::class);
$noteManager->viewBulletins(); return $noteManager->viewBulletins();
} }
} }

View file

@ -53,8 +53,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);
$eleveController->addNotes($controle->getNotes()); $eleveController->addNotes($controle->getNotes());
return $this->wiki->redirect('?Notes', 200);
return new ApiResponse(['parameters' => $controle->getNotes()]);
// return $this->wiki->redirect('?Notes', 200);
} }
} }

View file

@ -24,7 +24,7 @@ class Bulletin {
} }
public function getId() { public function getId() {
return $this->eleve['bf_titre']; return $this->eleve['id_fiche'];
} }
public function getNom() { public function getNom() {
@ -37,11 +37,14 @@ class Bulletin {
public function getMoyenne() { public function getMoyenne() {
$total = 0; $total = 0;
$totalMatieres = 0;
foreach ( $this->matieres as $matiere) { foreach ( $this->matieres as $matiere) {
if ($matiere->isVisible()) {
$total += $matiere->getMoyenne(); $total += $matiere->getMoyenne();
++$totalMatieres;
} }
}
return $total / count($this->matieres); return $total / $totalMatieres;
} }
public function getMatieres() { public function getMatieres() {

View file

@ -5,6 +5,7 @@ namespace YesWiki\Meeo\Bulletin;
include 'tools/meeo/libs/bulletin/Note.lib.php'; include 'tools/meeo/libs/bulletin/Note.lib.php';
use YesWiki\Bazar\Service\EntryManager; use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Meeo\Service\NoteManager;
class Matiere { class Matiere {
private $id; private $id;
@ -17,12 +18,10 @@ class Matiere {
$eleveId = $bulletin->getId(); $eleveId = $bulletin->getId();
$entryManager = $wiki->services->get(EntryManager::class); $noteManager = $wiki->services->get(NoteManager::class);
$entries = $entryManager->search(['formsIds' => 7, 'queries' =>[ $entries = $noteManager->getNotes($eleveId, $id);
'listefiche5bf_eleve' => $eleveId,
'listeListeMatièrebf_matiere' => $id // echo "<p>".var_dump($entries)."</p>";
]]);
// echo var_dump($entries)."\n\n";
foreach ($entries as $entry) { foreach ($entries as $entry) {
$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

@ -5,7 +5,7 @@ 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;
use YesWiki\Core\Service\UserManager; use YesWiki\Core\Controller\AuthController;
use YesWiki\Wiki; use YesWiki\Wiki;
use YesWiki\Meeo\Bulletin\Bulletin; use YesWiki\Meeo\Bulletin\Bulletin;
use YesWiki\Meeo\Service\EleveManager; use YesWiki\Meeo\Service\EleveManager;
@ -15,30 +15,30 @@ class NoteManager {
protected $params; protected $params;
protected $entryManager; protected $entryManager;
protected $listManager; protected $listManager;
protected $userManager;
protected $formId; protected $formId;
protected $authController;
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, UserManager $userManager) public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, AuthController $authController)
{ {
$this->wiki = $wiki; $this->wiki = $wiki;
$this->params = $params; $this->params = $params;
$this->entryManager = $entryManager; $this->entryManager = $entryManager;
$this->listManager = $listManager; $this->listManager = $listManager;
$this->userManager = $userManager; $this->authController = $authController;
$meeo_config = $this->params->get('meeo'); $meeo_config = $this->params->get('meeo');
$this->formId = $meeo_config['notesFormId']; $this->formId = $meeo_config['notesFormId'];
} }
public function viewBulletins() { public function viewBulletins() {
// $eleveIdentifier = 'listefiche'.$meeo_config['elevesFormId'].'bf_eleve';
// $groupeEE = $meeo_config['groupeEE'];
$eleveIdentifier = 'listefiche'.$meeo_config['elevesFormId'].'bf_eleve'; $username = $this->authController->getLoggedUserName();
$groupeEE = $meeo_config['groupeEE'];
if ( $this->userManager->isInGroup($groupeEE, admincheck: false) ) { $eleves = $this->wiki->services->get(EleveManager::class)->getAll();
$eleves = $this->entryManager->search(['formsIds' => $meeo_config['elevesFormId']]); // $eleves = $ $this->entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
$entries = $this->entryManager->search(['formsIds' => $this->formId]); $entries = $this->entryManager->search(['formsIds' => $this->formId]);
include 'tools/meeo/libs/bulletin/Bulletin.lib.php'; include 'tools/meeo/libs/bulletin/Bulletin.lib.php';
$bulletins = []; $bulletins = [];
@ -46,19 +46,20 @@ class NoteManager {
//TODO enlever "Passerelle" //TODO enlever "Passerelle"
$bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle"); $bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle");
} }
// echo var_dump($eleves); // echo "<p>".var_dump($eleves)."</p>";
// echo var_dump($entries); // echo "<p>".var_dump($entries)."</p>";
// echo var_dump($matieres); // echo "<p>".var_dump($bulletins)."</p>";
return $this->wiki->render('@meeo/edu_notes.twig', [ return $this->wiki->render('@meeo/edu_notes.twig', [
"bulletins" => $bulletins, "bulletins" => $bulletins,
]); ]);
} else { // } else {
$entries = $entryManager->search(['formsIds' => $this->formId]); // $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,
]); // ]);
} // }
} }
public function viewControle() { public function viewControle() {
@ -77,4 +78,17 @@ class NoteManager {
$this->entryManager->create($this->formId, $note); $this->entryManager->create($this->formId, $note);
} }
} }
public function getNotes($eleveId, $matiereId) {
// echo "<p>".$eleveId."</p>";
// echo "<p>".$matiereId."</p>";
$entries = $this->entryManager->search(['formsIds' => $this->formId,
'queries' =>[
'listefiche6bf_eleve' => $eleveId,
'listeListeMatierebf_matiere' => $matiereId
]
]);
// echo "<p>".var_dump($entries)."</p>";
return $entries;
}
} }

View file

@ -1,5 +1,6 @@
<div id="accordion_{{ bulletin.getId() }}_matiere" class="panel-group"> <div id="accordion_{{ bulletin.getId() }}_matiere" class="panel-group">
{% for matiere in bulletin.getMatieres() %} {% for matiere in bulletin.getMatieres() %}
{% if matiere.isVisible() %}
<div class="panel panel-primary"> <div class="panel panel-primary">
<button id="head_{{ bulletin.getId() }}_{{ matiere.getId() }}" class="panel-heading collapsed" data-parent="#accordion_{{ bulletin.getId() }}_matiere" data-target="#{{ bulletin.getId() }}_{{ matiere.getId() }}" data-toggle="collapse"> <button id="head_{{ bulletin.getId() }}_{{ matiere.getId() }}" class="panel-heading collapsed" data-parent="#accordion_{{ bulletin.getId() }}_matiere" data-target="#{{ bulletin.getId() }}_{{ matiere.getId() }}" data-toggle="collapse">
<h4 class="panel-title">{{ matiere.getNom() }}</h4> <h4 class="panel-title">{{ matiere.getNom() }}</h4>
@ -34,5 +35,6 @@
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endif %}
{% endfor %} {% endfor %}
</div> </div>