2024-07-19 14:52:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace YesWiki\Meeo\Service;
|
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
|
|
use YesWiki\Bazar\Service\EntryManager;
|
|
|
|
use YesWiki\Bazar\Service\ListManager;
|
2024-07-21 09:17:17 +00:00
|
|
|
use YesWiki\Core\Controller\AuthController;
|
2024-08-05 17:02:45 +00:00
|
|
|
use YesWiki\Core\Service\UserManager;
|
2024-07-19 14:52:37 +00:00
|
|
|
use YesWiki\Wiki;
|
2024-07-20 07:15:55 +00:00
|
|
|
use YesWiki\Meeo\Bulletin\Bulletin;
|
2024-07-20 08:13:50 +00:00
|
|
|
use YesWiki\Meeo\Service\EleveManager;
|
2024-11-05 10:05:51 +00:00
|
|
|
use YesWiki\Meeo\Classes\Classe;
|
2024-07-19 14:52:37 +00:00
|
|
|
|
|
|
|
class NoteManager {
|
|
|
|
protected $wiki;
|
|
|
|
protected $params;
|
|
|
|
protected $entryManager;
|
|
|
|
protected $listManager;
|
2024-07-20 18:58:35 +00:00
|
|
|
protected $formId;
|
2024-07-21 09:43:47 +00:00
|
|
|
protected $eleveFormId;
|
2024-08-05 17:02:45 +00:00
|
|
|
protected $eeGroup;
|
2024-07-21 09:17:17 +00:00
|
|
|
protected $authController;
|
2024-08-05 17:02:45 +00:00
|
|
|
protected $userManager;
|
2024-07-19 14:52:37 +00:00
|
|
|
|
2024-08-05 17:02:45 +00:00
|
|
|
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, AuthController $authController, UserManager $userManager)
|
2024-07-19 14:52:37 +00:00
|
|
|
{
|
|
|
|
$this->wiki = $wiki;
|
|
|
|
$this->params = $params;
|
|
|
|
$this->entryManager = $entryManager;
|
|
|
|
$this->listManager = $listManager;
|
2024-07-21 09:17:17 +00:00
|
|
|
$this->authController = $authController;
|
2024-08-05 17:02:45 +00:00
|
|
|
$this->userManager = $userManager;
|
2024-07-20 18:58:35 +00:00
|
|
|
|
|
|
|
$meeo_config = $this->params->get('meeo');
|
|
|
|
$this->formId = $meeo_config['notesFormId'];
|
2024-07-21 09:43:47 +00:00
|
|
|
$this->eleveFormId = $meeo_config['elevesFormId'];
|
2024-08-05 17:02:45 +00:00
|
|
|
$this->eeGroup = $meeo_config['groupeEE'];
|
2024-07-19 14:52:37 +00:00
|
|
|
}
|
|
|
|
|
2024-11-05 10:05:51 +00:00
|
|
|
public function allBulletins() {
|
|
|
|
$eleveManager = $this->wiki->services->get(EleveManager::class);
|
|
|
|
$eleves = $eleveManager->getAll();
|
|
|
|
|
|
|
|
$bulletins = [];
|
|
|
|
foreach ( $eleves as $eleve) {
|
|
|
|
$bulletins[] = new Bulletin($this->wiki, $eleve);
|
|
|
|
}
|
|
|
|
return $bulletins;
|
|
|
|
}
|
|
|
|
|
2024-07-19 14:52:37 +00:00
|
|
|
public function viewBulletins() {
|
2024-07-27 15:19:40 +00:00
|
|
|
$eleveManager = $this->wiki->services->get(EleveManager::class);
|
2024-07-19 14:52:37 +00:00
|
|
|
|
2024-07-21 09:17:17 +00:00
|
|
|
include 'tools/meeo/libs/bulletin/Bulletin.lib.php';
|
2024-11-05 10:05:51 +00:00
|
|
|
include 'tools/meeo/libs/classes/Classe.lib.php';
|
2024-07-19 14:52:37 +00:00
|
|
|
|
2024-08-05 17:02:45 +00:00
|
|
|
$loggedUser = $this->authController->getLoggedUser();
|
2024-11-05 08:22:50 +00:00
|
|
|
|
2024-08-06 06:21:13 +00:00
|
|
|
// echo "<p>".var_dump($loggedUser)."</p>";
|
2024-11-05 10:07:55 +00:00
|
|
|
if ($this->userManager->isInGroup($this->eeGroup, $loggedUser['name'], false)) {
|
2024-07-27 15:19:40 +00:00
|
|
|
// echo "<p>".var_dump($eleves)."</p>";
|
|
|
|
// echo "<p>".var_dump($bulletins)."</p>";
|
2024-11-05 10:05:51 +00:00
|
|
|
$classes = [];
|
|
|
|
$listClasse = $this->listManager->getOne('ListeClasses');
|
|
|
|
foreach ($listClasse['label'] as $id => $classe) {
|
|
|
|
array_push($classes, new Classe($this->wiki, $id, $classe));
|
|
|
|
}
|
|
|
|
// echo "<p>".var_dump($classes)."</p>";
|
2024-07-27 15:19:40 +00:00
|
|
|
return $this->wiki->render('@meeo/edu_notes.twig', [
|
2024-11-05 10:05:51 +00:00
|
|
|
"classes" => $classes,
|
2024-11-05 08:22:50 +00:00
|
|
|
"opened" => ""
|
2024-07-27 15:19:40 +00:00
|
|
|
]);
|
2024-08-05 17:02:45 +00:00
|
|
|
} else {
|
2024-08-06 06:19:59 +00:00
|
|
|
// echo "Eleve";
|
2024-08-05 17:02:45 +00:00
|
|
|
$currentEleve = $eleveManager->getCurrentEleve($loggedUser['name']);
|
|
|
|
if ($currentEleve != null) {
|
|
|
|
$bulletin = new Bulletin($this->wiki, $currentEleve);
|
|
|
|
return $this->wiki->render('@meeo/eleve_notes.twig', [
|
|
|
|
"bulletin" => $bulletin,
|
2024-11-05 08:22:50 +00:00
|
|
|
"opened" => "in"
|
2024-08-05 17:02:45 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2024-07-19 14:52:37 +00:00
|
|
|
}
|
2024-07-20 07:15:55 +00:00
|
|
|
|
2024-07-20 08:13:50 +00:00
|
|
|
public function viewControle() {
|
|
|
|
$eleves = $this->wiki->services->get(EleveManager::class)->getAll();
|
|
|
|
// echo var_dump($eleves);
|
|
|
|
$matieres = $this->listManager->getOne('ListeMatiere');
|
|
|
|
// echo var_dump($matieres);
|
|
|
|
$classes = $this->listManager->getOne('ListeClasses');
|
2024-09-11 06:47:50 +00:00
|
|
|
$notesMax = $this->listManager->getOne('ListeNoteMax');
|
2024-07-20 08:13:50 +00:00
|
|
|
// echo var_dump($classes);
|
2024-09-11 06:47:50 +00:00
|
|
|
return $this->wiki->render('@meeo/edu_controle.twig', [
|
|
|
|
'matieres' => $matieres['label'],
|
|
|
|
'classes' => $classes['label'],
|
|
|
|
'notesMax' => $notesMax['label'],
|
|
|
|
'eleves' => $eleves,
|
|
|
|
]);
|
2024-07-20 07:15:55 +00:00
|
|
|
}
|
2024-07-20 18:58:35 +00:00
|
|
|
|
2024-09-11 06:47:50 +00:00
|
|
|
public function createNote($intitule, $eleve, $matiere, $note, $max, $coef) {
|
2024-07-27 15:37:51 +00:00
|
|
|
if ($note == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$data = [
|
2024-07-21 09:43:47 +00:00
|
|
|
'bf_titre' => "Note : ".$intitule." - ".$eleve." - ".$matiere,
|
|
|
|
'bf_intitule' => $intitule,
|
|
|
|
'listeListeMatierebf_matiere' => $matiere,
|
2024-09-23 14:46:39 +00:00
|
|
|
'listeListeNotemaxbf_notemax' => $max,
|
2024-07-21 09:43:47 +00:00
|
|
|
'listefiche'.$this->eleveFormId.'bf_eleve' => $eleve,
|
|
|
|
'bf_note' => $note,
|
|
|
|
'bf_coef' => $coef,
|
|
|
|
'antispam' => true
|
|
|
|
];
|
2024-07-27 15:37:51 +00:00
|
|
|
$this->entryManager->create($this->formId, $data);
|
2024-07-20 18:58:35 +00:00
|
|
|
}
|
2024-07-21 09:17:17 +00:00
|
|
|
|
|
|
|
public function getNotes($eleveId, $matiereId) {
|
2024-07-27 15:37:51 +00:00
|
|
|
// echo "<p>".$eleveId."</p>";
|
|
|
|
// echo "<p>".$matiereId."</p>";
|
2024-07-21 09:17:17 +00:00
|
|
|
$entries = $this->entryManager->search(['formsIds' => $this->formId,
|
|
|
|
'queries' =>[
|
2024-07-27 15:19:40 +00:00
|
|
|
'listefiche'.$this->eleveFormId.'bf_eleve' => \strtolower($eleveId),
|
2024-07-21 09:17:17 +00:00
|
|
|
'listeListeMatierebf_matiere' => $matiereId
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
// echo "<p>".var_dump($entries)."</p>";
|
|
|
|
return $entries;
|
|
|
|
}
|
2024-08-06 06:19:59 +00:00
|
|
|
}
|