2024-07-17 17:15:22 +00:00
|
|
|
<?php
|
|
|
|
namespace YesWiki\Meeo\Controller;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
use YesWiki\Core\ApiResponse;
|
|
|
|
use YesWiki\Core\YesWikiController;
|
2024-07-20 18:58:35 +00:00
|
|
|
use YesWiki\Meeo\Controle\Controle;
|
2024-07-18 19:18:59 +00:00
|
|
|
use YesWiki\Meeo\Service\EleveManager;
|
2024-07-20 18:58:35 +00:00
|
|
|
use YesWiki\Meeo\Service\NoteManager;
|
2024-07-17 17:15:22 +00:00
|
|
|
|
|
|
|
class ApiController extends YesWikiController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}})
|
|
|
|
*/
|
|
|
|
public function eleveUpdate(Request $request) {
|
2024-07-18 19:18:59 +00:00
|
|
|
$eleveController = $this->getService(EleveManager::class);
|
2024-07-17 17:15:22 +00:00
|
|
|
$content = $request->getContent();
|
|
|
|
|
|
|
|
parse_str($content, $parameters);
|
|
|
|
|
2024-07-18 19:18:59 +00:00
|
|
|
$datas = [];
|
2024-07-17 17:15:22 +00:00
|
|
|
foreach ($parameters as $cle => $valeur) {
|
|
|
|
$clef_action = explode('_', $cle);
|
|
|
|
if ($clef_action[1] == 'classe' && $valeur != 'aucune') {
|
2024-07-18 19:18:59 +00:00
|
|
|
$datas[] = $eleveController->updateClasse($clef_action[0], $valeur);
|
2024-07-17 17:15:22 +00:00
|
|
|
}
|
|
|
|
if ($clef_action[1] == 'del') {
|
2024-07-18 19:18:59 +00:00
|
|
|
$eleveController->del($clef_action[0]);
|
2024-07-17 17:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-18 19:18:59 +00:00
|
|
|
return $this->wiki->redirect('?Eleves', 200);
|
2024-07-17 17:15:22 +00:00
|
|
|
}
|
2024-07-20 18:58:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}})
|
|
|
|
*/
|
|
|
|
public function control(Request $request) {
|
2024-07-21 09:43:47 +00:00
|
|
|
$noteManager = $this->getService(NoteManager::class);
|
2024-07-20 18:58:35 +00:00
|
|
|
$content = $request->getContent();
|
|
|
|
|
|
|
|
parse_str($content, $parameters);
|
|
|
|
|
|
|
|
include 'tools/meeo/libs/controle/Controle.lib.php';
|
|
|
|
|
|
|
|
$eleves = array_filter($parameters, function($key) {
|
|
|
|
return strpos($key, 'eleve_') === 0;
|
|
|
|
}, ARRAY_FILTER_USE_KEY);
|
|
|
|
|
|
|
|
$controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves);
|
2024-07-21 09:43:47 +00:00
|
|
|
$controle->createNotes($noteManager);
|
2024-07-21 09:17:17 +00:00
|
|
|
return $this->wiki->redirect('?Notes', 200);
|
2024-07-20 18:58:35 +00:00
|
|
|
}
|
2024-07-17 17:15:22 +00:00
|
|
|
}
|