Commit d044bd31 authored by therealwa3er's avatar therealwa3er Committed by Mikael Salson
Browse files

Issue 6 solution

parent 180cfac0
......@@ -59,12 +59,20 @@ class NotesExporterController extends AlecsiaController {
return new RedirectResponse($this->getRequest()->headers->get('referer'));
}
$notes = $ue_obj->getNotes();
//si certtain sujet ne sont pas gelé
if(!$ue_obj->isAllSujetFrozen()){
$this->setSuccess("certains sujets ne sont pas gelés!");
}
else{
$this->setSuccess("tout les sujets sont gelés!");
}
//Meme les si les notes sont pas gelé on prend les notes avec la fonction getFrozenAndNonFrozenNotes,
$notes = $ue_obj->getFrozenAndNonFrozenNotes();
if (empty($notes['student'])) {
return $this->noNoteToExport();
}
return $this->createCSVFile('notes_ue.csv.twig', 'notes_' . $ue_obj->getNomCourt() . '.csv', array('notes' => $notes));
}
......
......@@ -93,6 +93,38 @@ class UE extends AlecsiaEntity {
return $notes;
}
//this function allow to get note from frozen and nonfrozen subject
public function getFrozenAndNonFrozenNotes() {
$notes = array();
$notes['student'] = array();
$notes['group'] = array();
foreach ($this->sujets as $sujet) {
$notes_tp = $sujet->getFrozenAndNonFrozenNotes();
$notes['notes'][$sujet->getId()] = array();
$notes['sujet'][] = $sujet;
foreach ($notes_tp as $info) {
$notes['student'] += array($info['student']->getId() => $info['student']);
$notes['group'] += array($info['student']->getId() => $info['group']);
$notes['notes'][$sujet->getId()] += array($info['student']->getId() => $info['note']);
}
}
return $notes;
}
//retunr boolean
// check retun False if one subjet not frozen yet
public function isAllSujetFrozen(){
$frozen = true;
foreach ($this->sujets as $sujet) {
if (!$sujet->isFrozen()) {
$frozen = false;
}
}
return $frozen;
}
/* ============================== */
/* Right managements */
/* ============================== */
......
......@@ -41,7 +41,11 @@ But we just call that template once, even if there are several groups
data-assign='' href="{{ path('AlecsiaPopularModelsUE', {ue_id : ue.id}) }}">Modèles populaires</a></li>
{% endif %}
<li><a href="{{ path('AnnotationBundle_exportCSVNotesUE', {ue_id : ue.id}) }}"><strong>Exporter les notes</strong></a></li>
<li><a href="{{ path('AnnotationBundle_exportCSVNotesUE', {ue_id : ue.id}) }}"
data-confirm-h="Êtes-vous sûr ?"
data-confirm-p="Cette action va exporter les notes de l'UE &quot;{{ue.nom}}&quot;, Il se peut que certains sujets ne sont pas geler."
data-confirm-l="Exporter les notes">
<strong>Exporter les notes</strong></a></li>
</ul>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment