/** * @param \Icap\DropzoneBundle\Entity\Dropzone $dropzone * @param \Icap\DropzoneBundle\Entity\Drop $drop */ public function __construct(Dropzone $dropzone, Drop $drop) { $this->dropzone = $dropzone; $this->drop = $drop; $this->details = array('drop' => $drop, 'dropGrade' => $drop->getCalculatedGrade(), 'resultMax' => 20, 'dropzoneId' => $dropzone->getId(), 'dropId' => $drop->getId()); parent::__construct($dropzone->getResourceNode(), $this->details); }
/** * @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); }
/** * @param Dropzone $dropzone * @param Drop $drop * @param Document $document */ public function __construct(Dropzone $dropzone, Drop $drop, Document $document) { $documentsDetails = array(); foreach ($drop->getDocuments() as $document) { $documentsDetails[] = $document->toArray(); } $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId(), 'documents' => $documentsDetails), 'document' => $document->toArray()); parent::__construct($dropzone->getResourceNode(), $details); }
/** * @param Dropzone $dropzone * @param Drop $drop * @param $roleManager */ public function __construct(Dropzone $dropzone, Drop $drop, $roleManager) { $this->dropzone = $dropzone; $this->role_manager = $roleManager; $documentsDetails = array(); foreach ($drop->getDocuments() as $document) { $documentsDetails[] = $document->toArray(); } $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId(), 'documents' => $documentsDetails)); parent::__construct($dropzone->getResourceNode(), $details); }
/** * @param Dropzone $dropzone * @param Drop $drop * @param string $grade */ public function __construct(Dropzone $dropzone, Drop $drop, $grade) { $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())), 'result' => $grade, 'resultMax' => 20); parent::__construct($dropzone->getResourceNode(), $details); }
/** * @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); }
/** * @param Dropzone $dropzone * @param Drop $drop * @param Document $document */ public function __construct(Dropzone $dropzone, Drop $drop, Document $document) { $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId(), 'owner' => array('id' => $drop->getUser()->getId(), 'lastName' => $drop->getUser()->getLastName(), 'firstName' => $drop->getUser()->getFirstName(), 'username' => $drop->getUser()->getUsername())), 'document' => $document->toArray()); parent::__construct($dropzone->getResourceNode(), $details); }
/** * @Route( * "/{resourceId}/delete/document/{dropId}/{documentId}", * name="icap_dropzone_delete_document", * requirements={"resourceId" = "\d+", "dropId" = "\d+", "documentId" = "\d+"} * ) * @ParamConverter("dropzone", class="IcapDropzoneBundle:Dropzone", options={"id" = "resourceId"}) * @ParamConverter("user", options={"authenticatedUser" = true}) * @ParamConverter("drop", class="IcapDropzoneBundle:Drop", options={"id" = "dropId"}) * @ParamConverter("document", class="IcapDropzoneBundle:Document", options={"id" = "documentId"}) * @Template() */ public function deleteDocumentAction(Request $request, Dropzone $dropzone, $user, Drop $drop, Document $document) { $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone); if ($drop->getId() != $document->getDrop()->getId()) { throw new \HttpInvalidParamException(); } if ($drop->getUser()->getId() != $user->getId()) { throw new AccessDeniedException(); } $form = $this->createForm(new DocumentDeleteType(), $document); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($document); $em->flush(); $event = new LogDocumentDeleteEvent($dropzone, $drop, $document); $this->dispatch($event); return $this->redirect($this->generateUrl('icap_dropzone_drop', array('resourceId' => $dropzone->getId()))); } } $view = 'IcapDropzoneBundle:Document:deleteDocument.html.twig'; if ($request->isXMLHttpRequest()) { $view = 'IcapDropzoneBundle:Document:deleteDocumentModal.html.twig'; } return $this->render($view, array('workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'drop' => $drop, 'document' => $document, 'form' => $form->createView())); }
private function checkUserGradeAvailableByDrop(Drop $drop) { $user = $drop->getUser(); $dropzone = $drop->getDropzone(); $this->checkUserGradeAvailable($dropzone, $drop, $user); }
/** * * STATES FOR NORMAL ARE : * 0 : not started * 1 : Waiting for drop * 2 : Drop received, waiting for correction * 3 : Copy corrected , Evaluation end. * * STATES FOR PEERREVIEW (for X correction ): * 0 : notStarted * 1 : Waiting for drop * 2 : Drop received * 3 : Correction 1/x * 4 : Correction 2/X * 5 : Correction X/X * 6 : Waiting for correction * 7 : copy corrected, Evaluation End. * * WARNING : if a drop has the 'unlockedDrop' property, it will make the drop being at the last state. * currentstate : index of the current state in the stateArray * percent : rounded progress in percent * nbCorrection : corrections made by the user in this evaluation. * * @param \Icap\DropzoneBundle\Entity\Dropzone $dropzone * @param \Icap\DropzoneBundle\Entity\Drop|\Icap\DropzoneBundle\Manager\Drop $drop * @param int $nbCorrection number of correction the user did. * @return array (states, currentState,percent,nbCorrection) */ public function getDrozponeProgress(Dropzone $dropzone, Drop $drop = null, $nbCorrection = 0) { $begin_states = array('Evaluation not started', 'awaiting for drop', 'drop provided'); $end_states = array('waiting for correction', 'corrected copy'); $states = array(); $states = array_merge($states, $begin_states); $expectedCorrections = $dropzone->getExpectedTotalCorrection(); $currentState = 0; // set the states of the dropzone. if ($dropzone->getPeerReview()) { // case of peerReview /* * --------------------- SPECIAL CASE BEGIN ------------------------------ * particular case where the peerReview end whereas the user didnt * had time to make all the expected corrections. * so we make a hack to allow them to see their note and simulate that * they did the expected corrections. */ $allow_user_to_not_have_expected_corrections = $this->isPeerReviewEndedOrManualStateFinished($dropzone, $nbCorrection); /* --------------------- SPECIAL CASE END ------------------------------*/ if (!$allow_user_to_not_have_expected_corrections && $drop != null && !$drop->isUnlockedDrop()) { for ($i = 0; $i < $expectedCorrections; $i++) { array_push($states, 'correction n°%nb_correction%/%expected_correction%'); } } $states = array_merge($states, $end_states); // getting the current state. // if no drop, state is 0 as default. if (!empty($drop)) { $currentState++; if ($drop->getFinished()) { $currentState++; } // @TODO manage invalidated corrections. // update the state with the correction number. if ($nbCorrection > $expectedCorrections) { $nbCorrection = $expectedCorrections; } if (!$allow_user_to_not_have_expected_corrections && !$drop->isUnlockedDrop()) { $currentState += $nbCorrection; if ($nbCorrection >= $expectedCorrections) { $currentState++; } } else { $currentState++; } if ($drop->countFinishedCorrections() >= $expectedCorrections) { $currentState++; if ($allow_user_to_not_have_expected_corrections) { $currentState++; } } else { if ($drop->isUnlockedDrop()) { $currentState++; } } // admin case ( can correct more than expected ) if ($currentState >= count($states)) { $currentState = count($states) - 1; } } } else { // case of normal correction. $states = array_merge($states, $end_states); // if no drop, state is 0 as default. if (!empty($drop)) { $currentState++; if ($drop->getFinished()) { $currentState += 2; } if ($drop->countFinishedCorrections() >= $expectedCorrections) { $currentState++; } } } $percent = round($currentState * 100 / (count($states) - 1)); return array('states' => $states, 'currentState' => $currentState, 'percent' => $percent, 'nbCorrection' => $nbCorrection); }
private function sendFinishedLog(Drop $drop) { if ($drop != null) { if ($drop->getDropzone()->getPeerReview() === false || $drop->countFinishedCorrections() >= $drop->getDropzone()->getExpectedTotalCorrection()) { $finished = false; if ($drop->getDropzone()->getPeerReview() === true) { $nbCorrections = $this->entityManager->getRepository('IcapDropzoneBundle:Correction')->countFinished($drop->getDropzone(), $drop->getUser()); if ($nbCorrections >= $drop->getDropzone()->getExpectedTotalCorrection()) { $finished = true; } } else { $finished = true; } if ($finished === true) { $grade = $drop->getCalculatedGrade(); $event = new LogDropEvaluateEvent($drop->getDropzone(), $drop, $grade); $event->setDoer($drop->getUser()); $this->eventDispatcher->dispatch('log', $event); } } } }
public function testGetLastCorrectionDate() { echo "testing DROP->GetLastCorrection\n"; $date1 = \DateTime::createFromFormat('d-m-Y', '15-02-2009'); $correction1 = $this->createCorrection(10, true); $correction1->setEndDate($date1); $date2 = DateTime::createFromFormat('d-m-Y', '15-02-2010'); $correction2 = $this->createCorrection(20, false, true); $correction2->setEndDate($date2); $date3 = DateTime::createFromFormat('d-m-Y', '15-05-2010'); $correction3 = $this->createCorrection(5, true, false); $correction3->setEndDate($date3); $date4 = DateTime::createFromFormat('d-m-Y', '16-05-2014'); $correction4 = $this->createCorrection(3, false); $correction4->setEndDate($date4); $drop1 = new Drop(); $drop1->setCorrections(array($correction1, $correction2)); $this->assertEquals($date2, $drop1->getLastCorrectionDate()); $drop2 = new Drop(); $drop2->setCorrections(array($correction2, $correction3, $correction4)); $this->assertEquals($date4, $drop2->getLastCorrectionDate()); $drop3 = new Drop(); $drop3->setCorrections(array($correction4, $correction3)); $this->assertEquals($date4, $drop3->getLastCorrectionDate()); }
/** * @param Dropzone $dropzone * @param Drop $drop */ public function __construct(Dropzone $dropzone, Drop $drop) { $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId())); parent::__construct($dropzone->getResourceNode(), $details); }
private function sendFinishedLog(Drop $drop) { // var_dump('sendFinishedLog'); if ($drop != null) { // var_dump('drop not null'); if ($drop->getDropzone()->getPeerReview() === false or $drop->countFinishedCorrections() >= $drop->getDropzone()->getExpectedTotalCorrection()) { // var_dump('pas de peer review ou bien assez de correction'); $finished = false; if ($drop->getDropzone()->getPeerReview() === true) { // var_dump('peer review. mais est ce que le user a corrigé assez de copie'); $nbCorrections = $this->entityManager->getRepository('IcapDropzoneBundle:Correction')->countFinished($drop->getDropzone(), $drop->getUser()); if ($nbCorrections >= $drop->getDropzone()->getExpectedTotalCorrection()) { $finished = true; } } else { // var_dump('pas de peer review donc fini !'); $finished = true; } if ($finished === true) { // var_dump('finish'); $grade = $drop->getCalculatedGrade(); $event = new LogDropEvaluateEvent($drop->getDropzone(), $drop, $grade); $event->setDoer($drop->getUser()); // var_dump('finish grade = '.$grade); $this->eventDispatcher->dispatch('log', $event); } } } }
/** * @param Drop $drop * @param User $user * * @return \Symfony\Component\HttpFoundation\RedirectResponse * @Route( * "/unlock/drop/{dropId}", * name="icap_dropzone_unlock_drop", * requirements={"resourceId" = "\d+", "dropId" = "\d+"} * ) * @ParamConverter("drop", class="IcapDropzoneBundle:Drop", options={"id" = "dropId"}) * @ParamConverter("user", options={ * "authenticatedUser" = true, * "messageEnabled" = true, * "messageTranslationKey" = "This action requires authentication. Please login.", * "messageTranslationDomain" = "icap_dropzone" * }) * @Template() */ public function unlockDropAction(Request $request, Drop $drop, User $user) { $em = $this->getDoctrine()->getManager(); $drop->setUnlockedDrop(true); $em->flush(); $request->getSession()->getFlashBag()->add('success', $this->get('translator')->trans('Drop have been unlocked', [], 'icap_dropzone')); $dropzoneId = $drop->getDropzone()->getId(); return $this->redirect($this->generateUrl('icap_dropzone_drops_awaiting', ['resourceId' => $dropzoneId])); }