Ajout d'un fonction permettant de créer les notes à partir d'un bulletin
This commit is contained in:
parent
43d586f57b
commit
573d5753b2
5 changed files with 83 additions and 21 deletions
|
@ -117,7 +117,7 @@ EOT,
|
|||
"bn_template" => <<<EOT
|
||||
titre***Note : {{bf_intitule}} - {{bf_eleve}} - {{bf_matiere}}***Titre Automatique***
|
||||
texte***bf_intitule***Intitulé*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
|
||||
liste***ListeMatière***Matière*** *** *** ***bf_matiere*** ***1*** *** *** * *** * *** *** *** ***
|
||||
liste***ListeMatiere***Matière*** *** *** ***bf_matiere*** ***1*** *** *** * *** * *** *** *** ***
|
||||
listefiche***6***Elève*** *** *** ***bf_eleve*** ***1*** *** *** * *** * *** *** *** ***
|
||||
texte***bf_note***Note***0***20*** *** ***number***1*** *** *** * *** * *** *** *** ***
|
||||
texte***bf_coef***Coefficient***0.5***10***1*** ***number***0*** *** *** * *** * *** *** *** ***
|
||||
|
|
|
@ -6,7 +6,9 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use YesWiki\Core\ApiResponse;
|
||||
use YesWiki\Core\YesWikiController;
|
||||
use YesWiki\Meeo\Controle\Controle;
|
||||
use YesWiki\Meeo\Service\EleveManager;
|
||||
use YesWiki\Meeo\Service\NoteManager;
|
||||
|
||||
class ApiController extends YesWikiController
|
||||
{
|
||||
|
@ -32,4 +34,27 @@ class ApiController extends YesWikiController
|
|||
|
||||
return $this->wiki->redirect('?Eleves', 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}})
|
||||
*/
|
||||
public function control(Request $request) {
|
||||
$eleveController = $this->getService(NoteManager::class);
|
||||
$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);
|
||||
|
||||
$eleveController->addNotes($controle->getNotes());
|
||||
|
||||
return new ApiResponse(['parameters' => $controle->getNotes()]);
|
||||
// return $this->wiki->redirect('?Notes', 200);
|
||||
}
|
||||
}
|
|
@ -1,18 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace YesWiki\MeeO\Controle\Controle;
|
||||
namespace YesWiki\MeeO\Controle;
|
||||
|
||||
class Control {
|
||||
private $wiki;
|
||||
private $intitule;
|
||||
private $matiere;
|
||||
private $coef;
|
||||
private $eleves;
|
||||
class Controle {
|
||||
public $intitule;
|
||||
public $matiere;
|
||||
public $coef;
|
||||
public $eleves;
|
||||
|
||||
public function __construct($wiki, $intitule, $matiere, $coef) {
|
||||
$this->wiki = $wiki;
|
||||
public function __construct($intitule, $matiere, $coef, $eleves) {
|
||||
$this->intitule = $intitule;
|
||||
$this->matiere = $matiere;
|
||||
$this->coef = $coef;
|
||||
$this->eleves = $this->removePrefixFromKeys($eleves, "eleve_");
|
||||
}
|
||||
|
||||
function removePrefixFromKeys($inputArray, $prefix) {
|
||||
$outputArray = array();
|
||||
foreach ($inputArray as $key => $value) {
|
||||
if (strpos($key, $prefix) === 0) {
|
||||
$newKey = substr($key, strlen($prefix)); // Remove the prefix
|
||||
$outputArray[$newKey] = $value;
|
||||
} else {
|
||||
$outputArray[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $outputArray;
|
||||
}
|
||||
|
||||
public function getNotes() {
|
||||
$notes = [];
|
||||
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,
|
||||
];
|
||||
};
|
||||
return $notes;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ class NoteManager {
|
|||
protected $entryManager;
|
||||
protected $listManager;
|
||||
protected $userManager;
|
||||
protected $formId;
|
||||
|
||||
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, UserManager $userManager)
|
||||
{
|
||||
|
@ -24,17 +25,19 @@ class NoteManager {
|
|||
$this->entryManager = $entryManager;
|
||||
$this->listManager = $listManager;
|
||||
$this->userManager = $userManager;
|
||||
|
||||
$meeo_config = $this->params->get('meeo');
|
||||
$this->formId = $meeo_config['notesFormId'];
|
||||
}
|
||||
|
||||
public function viewBulletins() {
|
||||
$meeo_config = $this->params->get('meeo');
|
||||
$formId = $meeo_config['notesFormId'];
|
||||
|
||||
$eleveIdentifier = 'listefiche'.$meeo_config['elevesFormId'].'bf_eleve';
|
||||
$groupeEE = $meeo_config['groupeEE'];
|
||||
|
||||
if ( $this->userManager->isInGroup($groupeEE, admincheck: false) ) {
|
||||
$eleves = $this->entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
|
||||
$entries = $this->entryManager->search(['formsIds' => $formId]);
|
||||
$entries = $this->entryManager->search(['formsIds' => $this->formId]);
|
||||
|
||||
include 'tools/meeo/libs/bulletin/Bulletin.lib.php';
|
||||
|
||||
|
@ -50,7 +53,7 @@ class NoteManager {
|
|||
"bulletins" => $bulletins,
|
||||
]);
|
||||
} else {
|
||||
$entries = $entryManager->search(['formsIds' => $formId]);
|
||||
$entries = $entryManager->search(['formsIds' => $this->formId]);
|
||||
|
||||
return $this->wiki->render('@meeo/eleve_notes.twig', [
|
||||
"bulletin" => $bulletin,
|
||||
|
@ -67,4 +70,11 @@ class NoteManager {
|
|||
// echo var_dump($classes);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
{{ include_javascript('tools/meeo/javascripts/edu_controle_filter.js') }}
|
||||
|
||||
<form class="form-horizontal">
|
||||
<form class="form-horizontal" action="?api/meeo/controle" method="post">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="intitule">Intitulé:</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="intitule" required>
|
||||
<input type="text" class="form-control" id="intitule" name="intitule" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="matiere">Matière:</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" id="matiere" required>
|
||||
<select class="form-control" id="matiere" name="matiere" required>
|
||||
{% for clef, matiere in matieres %}
|
||||
<option value="{{ clef }}">{{ matiere }}</option>
|
||||
{% endfor %}
|
||||
|
@ -20,7 +20,7 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="classe">Classe:</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" id="classe" required>
|
||||
<select class="form-control" id="classe" name="classe" required>
|
||||
{% for classe in classes %}
|
||||
<option>{{ classe }}</option>
|
||||
{% endfor %}
|
||||
|
@ -30,17 +30,17 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="coef">Coefficient:</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" id="coef" value="1" min="0.5" max="10" step="0.5">
|
||||
<input type="number" class="form-control" id="coef" name="coef" value="1" min="0.5" max="10" step="0.5">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Eleves</h2>
|
||||
<div id="eleves">
|
||||
<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="col-sm-10">
|
||||
<input type="number" class="form-control" id="{{ eleve['id_fiche'] }}" min="0" max="20" step="0.1" required>
|
||||
<input type="number" class="form-control" id="{{ eleve['id_fiche'] }}" name="eleve_{{ eleve['id_fiche'] }}" min="0" max="20" step="0.1" required>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue