/** * @param Wiki $wiki * @param Section $section * @param Contribution $contribution */ public function __construct(Dropzone $dropzone, Drop $drop, Correction $correction, $roleManager) { $this->dropzone = $dropzone; $this->role_manager = $roleManager; $this->details = array('report' => array('drop' => $drop, 'correction' => $correction, 'report_comment' => $correction->getReportComment(), 'dropzoneId' => $dropzone->getId(), 'dropId' => $drop->getId(), 'correctionId' => $correction->getId())); parent::__construct($dropzone->getResourceNode(), $this->details); }
/** * @Route( * "/report/drop/{correctionId}", * name="icap_dropzone_report_drop", * requirements={"resourceId" = "\d+", "dropId" = "\d+", "correctionId" = "\d+"} * ) * @ParamConverter("correction", class="IcapDropzoneBundle:Correction", options={"id" = "correctionId"}) * @ParamConverter("user", options={ * "authenticatedUser" = true, * "messageEnabled" = true, * "messageTranslationKey" = "Participate in an evaluation requires authentication. Please login.", * "messageTranslationDomain" = "icap_dropzone" * }) * @Template() */ public function reportDropAction(Request $request, Correction $correction, User $user) { $dropzone = $correction->getDropzone(); $drop = $correction->getDrop(); $em = $this->getDoctrine()->getManager(); $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone); try { $curent_user_correction = $em->getRepository('IcapDropzoneBundle:Correction')->getNotFinished($dropzone, $user); } catch (NotFoundHttpException $e) { throw new AccessDeniedException(); } if ($curent_user_correction === null || $curent_user_correction->getId() !== $correction->getId()) { throw new AccessDeniedException(); } $form = $this->createForm(new CorrectionReportType(), $correction); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isValid()) { $drop->setReported(true); $correction->setReporter(true); $correction->setEndDate(new \DateTime()); $correction->setFinished(true); $correction->setTotalGrade(0); $em->persist($drop); $em->persist($correction); $em->flush(); $this->dispatchDropReportEvent($dropzone, $drop, $correction); $this->getRequest()->getSession()->getFlashBag()->add('success', $this->get('translator')->trans('Your report has been saved', [], 'icap_dropzone')); return $this->redirect($this->generateUrl('icap_dropzone_open', ['resourceId' => $dropzone->getId()])); } } $view = 'IcapDropzoneBundle:Drop:reportDrop.html.twig'; if ($request->isXmlHttpRequest()) { $view = 'IcapDropzoneBundle:Drop:reportDropModal.html.twig'; } return $this->render($view, ['workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'drop' => $drop, 'correction' => $correction, 'form' => $form->createView()]); }