Commit 5c0260bb authored by Mikael Salson's avatar Mikael Salson
Browse files

Merge branch 'Notes_realclean' into 'master'

Solve issue #6

See merge request !5
parents 180cfac0 78dffacb
......@@ -22,7 +22,7 @@ class NotesExporterController extends AlecsiaController {
}
private function noNoteToExport() {
$this->setError("Impossible d'exporter les notes", "Il n'y a aucune note à exporter (il faut commencer par les geler).");
$this->setError("Impossible d'exporter les notes", "Il n'y a aucune note à exporter.");
return new RedirectResponse($this->getRequest()->headers->get('referer'));
}
......@@ -59,12 +59,13 @@ class NotesExporterController extends AlecsiaController {
return new RedirectResponse($this->getRequest()->headers->get('referer'));
}
$notes = $ue_obj->getNotes();
//Meme les si les notes sont pas gelé on prend toutes les notes (true)
$notes = $ue_obj->getNotes(true);
if (empty($notes['student'])) {
return $this->noNoteToExport();
}
return $this->createCSVFile('notes_ue.csv.twig', 'notes_' . $ue_obj->getNomCourt() . '.csv', array('notes' => $notes));
}
......
......@@ -233,11 +233,12 @@ class Sujet {
* @pre The marks must have been frozen.
* @param group_id an array of group_ids, from which the marks must be taken.
* the array can be null
* @param all_marks: get all marks even if the subject is not frozen
*/
public function getNotes($group_id = null) {
public function getNotes($group_id = null, $all_marks = false) {
$notes = array();
if ($this->getStatus() == self::STATUS_FROZEN) {
if ($all_marks || $this->getStatus() == self::STATUS_FROZEN) {
$rendus = $this->getRendus();
foreach ($rendus as $rendu) {
......
......@@ -73,13 +73,17 @@ class UE extends AlecsiaEntity {
$this->addGroup(Group::getDefaultGroup());
}
public function getNotes() {
/**
* @return marks for all the subjects
* @param all_marks: return also marks for not frozen subjects
*/
public function getNotes($all_marks = false) {
$notes = array();
$notes['student'] = array();
$notes['group'] = array();
foreach ($this->sujets as $sujet) {
if ($sujet->isFrozen()) {
$notes_tp = $sujet->getNotes();
if ($all_marks || $sujet->isFrozen()) {
$notes_tp = $sujet->getNotes(null, $all_marks);
$notes['notes'][$sujet->getId()] = array();
$notes['sujet'][] = $sujet;
......@@ -93,6 +97,17 @@ class UE extends AlecsiaEntity {
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,13 @@ 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}) }}"
{% if not ue.isAllSujetFrozen() %}
data-confirm-h="Êtes-vous sûr⋅e ?"
data-confirm-p="Cette action va exporter les notes de l'UE &quot;{{ue.nom}}&quot;, Les notes de certains sujets ne sont pas gelées, cela signifie qu'elles sont encore susceptibles de changer en modifiant des modèles."
data-confirm-l="Exporter les notes">
{% endif %}
<strong>Exporter les notes</strong></a></li>
</ul>
......
Markdown is supported
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