Prendre en compte l'info dans la config pour la liste des élèves

This commit is contained in:
mckmonster 2024-07-21 11:43:47 +02:00
parent 0664776352
commit 4b0e9c3d1f
4 changed files with 25 additions and 25 deletions

View file

@ -16,11 +16,14 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class CreateFormsCommand extends Command
{
protected $wiki;
protected $eleveFormId;
public function __construct(Wiki &$wiki)
{
parent::__construct();
$this->wiki = $wiki;
$meeo_config = $this->wiki->params->get('meeo');
$this->eleveFormId = $meeo_config['elevesFormId'];
}
protected function configure()
@ -73,7 +76,7 @@ class CreateFormsCommand extends Command
"bn_sem_use_template" => "1",
"bn_template" => <<<EOT
titre***Absence : {{bf_eleve}} - {{bf_date_debut_evenement}}***Titre Automatique***
listefiche***6***Elève*** *** *** *** *** ***1*** *** *** * *** * *** *** *** ***
listefiche***$this->eleveFormId***Elève*** *** *** *** *** ***1*** *** *** * *** * *** *** *** ***
listedatedeb***bf_date_debut***Debut*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** ***
listedatedeb***bf_date_fin***Fin*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** ***
textelong***bf_commentaire***Commentaire*** *** *** *** ***wiki***0*** *** *** * *** * *** *** *** ***
@ -118,7 +121,7 @@ EOT,
titre***Note : {{bf_intitule}} - {{bf_eleve}} - {{bf_matiere}}***Titre Automatique***
texte***bf_intitule***Intitulé*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
liste***ListeMatiere***Matière*** *** *** ***bf_matiere*** ***1*** *** *** * *** * *** *** *** ***
listefiche***6***Elève*** *** *** ***bf_eleve*** ***1*** *** *** * *** * *** *** *** ***
listefiche***$this->eleveFormId***Elève*** *** *** ***bf_eleve*** ***1*** *** *** * *** * *** *** *** ***
texte***bf_note***Note***0***20*** *** ***number***1*** *** *** * *** * *** *** *** ***
texte***bf_coef***Coefficient***0.5***10***1*** ***number***0*** *** *** * *** * *** *** *** ***
EOT,

View file

@ -39,7 +39,7 @@ class ApiController extends YesWikiController
* @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}})
*/
public function control(Request $request) {
$eleveController = $this->getService(NoteManager::class);
$noteManager = $this->getService(NoteManager::class);
$content = $request->getContent();
parse_str($content, $parameters);
@ -51,8 +51,7 @@ class ApiController extends YesWikiController
}, ARRAY_FILTER_USE_KEY);
$controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves);
$eleveController->addNotes($controle->getNotes());
$controle->createNotes($noteManager);
return $this->wiki->redirect('?Notes', 200);
}
}

View file

@ -2,6 +2,8 @@
namespace YesWiki\MeeO\Controle;
use YesWiki\Meeo\Service\NoteManager;
class Controle {
public $intitule;
public $matiere;
@ -28,18 +30,9 @@ class Controle {
return $outputArray;
}
public function getNotes() {
$notes = [];
public function createNotes(NoteManager $noteManager) {
foreach ($this->eleves as $eleve => $note) {
$notes[] = [
'bf_titre' => "Note : ".$this->intitule." - ".$eleve." - ".$this->matiere,
'bf_intitule' => $this->intitule,
'listeListeMatierebf_matiere' => $this->matiere,
'listefiche6bf_eleve' => $eleve,
'bf_note' => $note,
'bf_coef' => $this->coef,
];
$noteManager->createNote($this->intitule, $eleve, $this->matiere, $note, $this->coef);
};
return $notes;
}
}

View file

@ -16,6 +16,7 @@ class NoteManager {
protected $entryManager;
protected $listManager;
protected $formId;
protected $eleveFormId;
protected $authController;
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, AuthController $authController)
@ -28,12 +29,10 @@ class NoteManager {
$meeo_config = $this->params->get('meeo');
$this->formId = $meeo_config['notesFormId'];
$this->eleveFormId = $meeo_config['elevesFormId'];
}
public function viewBulletins() {
// $eleveIdentifier = 'listefiche'.$meeo_config['elevesFormId'].'bf_eleve';
// $groupeEE = $meeo_config['groupeEE'];
$username = $this->authController->getLoggedUserName();
$eleves = $this->wiki->services->get(EleveManager::class)->getAll();
@ -72,11 +71,17 @@ class NoteManager {
return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['label'], 'classes' => $classes['label'], 'eleves' => $eleves]);
}
public function addNotes($notes) {
foreach ($notes as $note) {
$note['antispam'] = true;
$this->entryManager->create($this->formId, $note);
}
public function createNote($intitule, $eleve, $matiere, $note, $coef) {
$note = [
'bf_titre' => "Note : ".$intitule." - ".$eleve." - ".$matiere,
'bf_intitule' => $intitule,
'listeListeMatierebf_matiere' => $matiere,
'listefiche'.$this->eleveFormId.'bf_eleve' => $eleve,
'bf_note' => $note,
'bf_coef' => $coef,
'antispam' => true
];
$this->entryManager->create($this->formId, $note);
}
public function getNotes($eleveId, $matiereId) {
@ -84,7 +89,7 @@ class NoteManager {
// echo "<p>".$matiereId."</p>";
$entries = $this->entryManager->search(['formsIds' => $this->formId,
'queries' =>[
'listefiche6bf_eleve' => $eleveId,
'listefiche'.$this->eleveFormId.'bf_eleve' => $eleveId,
'listeListeMatierebf_matiere' => $matiereId
]
]);