/** * @Route( * "/{resourceId}/drops/detail/{dropId}/add/correction", * name="innova_collecticiel_drops_detail_add_correction", * requirements={"resourceId" = "\d+", "dropId" = "\d+"} * ) * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "resourceId"}) * @ParamConverter("user", options={ * "authenticatedUser" = true, * "messageEnabled" = true, * "messageTranslationKey" = "Correct an evaluation requires authentication. Please login.", * "messageTranslationDomain" = "innova_collecticiel" * }) * @ParamConverter("drop", class="InnovaCollecticielBundle:Drop", options={"id" = "dropId"}) * @Template() */ public function dropsDetailAddCorrectionAction($dropzone, $user, $drop) { $this->get('innova.manager.dropzone_voter')->isAllowToOpen($dropzone); $this->get('innova.manager.dropzone_voter')->isAllowToEdit($dropzone); $em = $this->getDoctrine()->getManager(); $correction = new Correction(); $correction->setUser($user); $correction->setDropzone($dropzone); $correction->setDrop($drop); //Allow admins to edit this correction $correction->setEditable(true); $em->persist($correction); $em->flush(); $event = new LogCorrectionStartEvent($dropzone, $drop, $correction); $this->dispatch($event); return $this->redirect($this->generateUrl('innova_collecticiel_drops_detail_correction', array('resourceId' => $dropzone->getId(), 'state' => 'edit', 'correctionId' => $correction->getId()))); }
/** * @Route( * "/dropzone/comments", * name="innova_collecticiel_add_more_comments", * options={"expose"=true} * ) * @Template() * * @return \Symfony\Component\HttpFoundation\Response */ public function ajaxDropzoneAddMoreCommentsAction() { $em = $this->getDoctrine()->getManager(); // Récupération de l'utilisateur $user = $this->get('security.token_storage')->getToken()->getUser(); // Récupération de l'ID du dropzone choisi $dropzoneId = $this->get('request')->query->get('dropzoneId'); $dropzone = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Dropzone')->find($dropzoneId); $this->get('innova.manager.dropzone_voter')->isAllowToOpen($dropzone); // Récupération des documents sélectionnés $arrayDocsId = $this->get('request')->query->get('arrayDocsId'); $arrayDocsToView = []; $arrayDropsId = $this->get('request')->query->get('arrayDropsId'); $arrayDropsToView = []; $cpt = 0; // Parcours des documents sélectionnés et insertion en base de données if (!empty($arrayDocsToView)) { foreach ($arrayDocsId as $documentId) { // Par le JS, le document est transmis sous la forme "document_id_XX" $docIdS = explode('_', $documentId); $docId = $docIdS[2]; if ($docId > 0) { $arrayDocsToView[] = $docId; $dropId = $arrayDropsId[$cpt]; $drop = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Drop')->find($dropId); $arrayDropsToView[] = $dropId; $correction = new Correction(); $correction->setUser($user); $correction->setDropzone($dropzone); $correction->setDrop($drop); //Allow admins to edit this correction $correction->setEditable(true); $em->persist($correction); $em->flush(); $event = new LogCorrectionStartEvent($dropzone, $drop, $correction); $this->dispatch($event); } ++$cpt; } } $edit = 'edit'; $oldData = []; $page = 1; $pager = $this->getCriteriaPager($dropzone); try { $pager->setCurrentPage($page); } catch (NotValidCurrentPageException $e) { throw new NotFoundHttpException(); } $this->createForm(new CommentType(new Comment(), null)); $this->createForm(new CorrectionCriteriaPageType(), $oldData, ['edit' => $edit, 'criteria' => $pager->getCurrentPageResults(), 'totalChoice' => $dropzone->getTotalCriteriaColumn()]); $redirectRoot = $this->generateUrl('innova_collecticiel_add_more_comments_view', ['dropzoneId' => $dropzoneId, 'arrayDocsId' => $arrayDocsId, 'arrayDropsId' => $arrayDropsId]); return new JsonResponse(['link' => $redirectRoot]); }