1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/* Rend le rendu d'id donné en paramètre */
public function indexAction($rendu_id, $lecture_etudiant=false)
{
// Recup BDD des infos rendu, ses fichiers, leurs annotations
$em = $this->getDoctrine()->getEntityManager();
$rendu = $this->get('alecsia.workService')->get($rendu_id, $this->getUser());
if (!$rendu) {throw new NotFoundHttpException(sprintf('Rendu #%s introuvable.', $rendu_id));}
$fichiers = $em->getRepository("AnnotationBundle:Fichier")->findBy(
array("rendu" => $rendu->getId()),
array("dossier" => "asc",
"nom_fichier" => "asc")
);
$annotations = $em->getRepository("AnnotationBundle:Annotation")->findByRendu($rendu->getId());
$exercices = $em->getRepository("AnnotationBundle:Exercice")->findBySujet($rendu->getSujet()->getId());
$langages = $em->getRepository("AnnotationBundle:Langage")->findBy(array(),array("nom" => "asc"));
// Classement des annotations par fichier
// TODO Peut peut être être optimisé en faisant faire ce tri à la BDD
$annotArray = array();
foreach ($fichiers as $f) {
$annotArray[(string) $f->getId()] = array();
}
foreach ($annotations as $a) {
$fichier = $a->getFichier();
if ($fichier != null) {
$id_fichier = (string) $fichier->getId();
} else {
$id_fichier = "entete";
}
$annotArray[$id_fichier][] = $a;
}
// Calcul du barème
$calculeur = $this->get('annotation.calculnotes');
$bareme = $calculeur -> getBareme($rendu,true);
return $this->render('AnnotationBundle:Correction:correction.html.twig', array(
'rendu' => $rendu,
'fichiers' => $fichiers,
'liste_annotations' => $annotArray,
'exercices' => $exercices,
'langages' => $langages,
'bareme' => $bareme,
'lectureseule' => $rendu->getSujet()->getNotesGelees()
|| $lecture_etudiant,
'lectureetudiant' => $lecture_etudiant
));
} |
Partager