コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 private function createCorrection($grade = null, $valid = true, $finished = true)
 {
     $correction = new Correction();
     $correction->setFinished($finished);
     $correction->setValid($valid);
     $correction->setTotalGrade($grade);
     return $correction;
 }
コード例 #3
0
 /**
  * @param Dropzone   $dropzone
  * @param Drop       $drop
  * @param Correction $correction
  */
 public function __construct(Dropzone $dropzone, Drop $drop, Correction $correction)
 {
     $documentsDetails = array();
     foreach ($drop->getDocuments() as $document) {
         $documentsDetails[] = $document->toArray();
     }
     $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId(), 'documents' => $documentsDetails, 'owner' => array('id' => $drop->getUser()->getId(), 'lastName' => $drop->getUser()->getLastName(), 'firstName' => $drop->getUser()->getFirstName(), 'username' => $drop->getUser()->getUsername())), 'correction' => $correction->toArray(false));
     parent::__construct($dropzone->getResourceNode(), $details);
 }
コード例 #4
0
 /**
  *  Calculate the grad of a copy
  *
  * @param Dropzone $dropzone
  * @param Correction $correction
  * @return float|int
  */
 public function calculateCorrectionTotalGrade(Dropzone $dropzone, Correction $correction)
 {
     $nbCriteria = count($dropzone->getPeerReviewCriteria());
     $maxGrade = $dropzone->getTotalCriteriaColumn() - 1;
     $sumGrades = 0;
     foreach ($correction->getGrades() as $grade) {
         $grade->getValue() > $maxGrade ? $sumGrades += $maxGrade : ($sumGrades += $grade->getValue());
     }
     $totalGrade = 0;
     if ($nbCriteria != 0) {
         $totalGrade = $sumGrades / $nbCriteria;
         $totalGrade = $totalGrade * 20 / $maxGrade;
     }
     return $totalGrade;
 }
コード例 #5
0
 /**
  * @Route(
  *      "/{resourceId}/recalculate/score/{correctionId}",
  *      name="icap_dropzone_recalculate_score",
  *      requirements={"resourceId" = "\d+", "correctionId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="IcapDropzoneBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("correction", class="IcapDropzoneBundle:Correction", options={"id" = "correctionId"})
  * @Template()
  */
 public function recalculateScoreAction(Dropzone $dropzone, Correction $correction)
 {
     $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone);
     $this->get('icap.manager.dropzone_voter')->isAllowToEdit($dropzone);
     if (!$dropzone->getPeerReview()) {
         throw new AccessDeniedException();
     }
     $oldTotalGrade = $correction->getTotalGrade();
     $totalGrade = $this->get('icap.manager.correction_manager')->calculateCorrectionTotalGrade($dropzone, $correction);
     $correction->setTotalGrade($totalGrade);
     $em = $this->getDoctrine()->getManager();
     $em->persist($correction);
     $em->flush();
     if ($oldTotalGrade != $totalGrade) {
         $event = new LogCorrectionUpdateEvent($dropzone, $correction->getDrop(), $correction);
         $this->dispatch($event);
     }
     return $this->redirect($this->generateUrl('icap_dropzone_drops_detail', array('resourceId' => $dropzone->getId(), 'dropId' => $correction->getDrop()->getId())));
 }
コード例 #6
0
 /**
  * @Route(
  *      "/{resourceId}/remove/report/{dropId}/{correctionId}/{invalidate}",
  *      name="icap_dropzone_remove_report",
  *      requirements={"resourceId" = "\d+", "dropId" = "\d+", "correctionId" = "\d+", "invalidate" = "0|1"}
  * )
  * @ParamConverter("dropzone", class="IcapDropzoneBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("drop", class="IcapDropzoneBundle:Drop", options={"id" = "dropId"})
  * @ParamConverter("correction", class="IcapDropzoneBundle:Correction", options={"id" = "correctionId"})
  * @Template()
  */
 public function removeReportAction(Dropzone $dropzone, Drop $drop, Correction $correction, $invalidate)
 {
     $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone);
     $this->get('icap.manager.dropzone_voter')->isAllowToEdit($dropzone);
     $em = $this->getDoctrine()->getManager();
     $correction->setReporter(false);
     if ($invalidate === 1) {
         $correction->setValid(false);
     }
     $em->persist($correction);
     $em->flush();
     $correctionRepo = $this->getDoctrine()->getRepository('IcapDropzoneBundle:Correction');
     if ($correctionRepo->countReporter($dropzone, $drop) === 0) {
         $drop->setReported(false);
         $em->persist($drop);
         $em->flush();
     }
     $event = new LogCorrectionUpdateEvent($dropzone, $drop, $correction);
     $this->dispatch($event);
     return $this->redirect($this->generateUrl('icap_dropzone_drops_detail', ['resourceId' => $dropzone->getId(), 'dropId' => $drop->getId()]));
 }