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 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);
 }
 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);
             }
         }
     }
 }
 /**
  * @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);
 }
Ejemplo n.º 8
0
 /**
  * @Route(
  *      "/{resourceId}/drop/detail/{dropId}",
  *      name="icap_dropzone_drop_detail_by_user",
  *      requirements={"resourceId" = "\d+", "dropId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="IcapDropzoneBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("drop", class="IcapDropzoneBundle:Drop", options={"id" = "dropId"})
  * @Template()
  */
 public function dropDetailAction(Dropzone $dropzone, Drop $drop)
 {
     // check  if the User is allowed to open the dropZone.
     $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone);
     // getting the userId to check if the current drop owner match with the loggued user.
     $userId = $this->get('security.token_storage')->getToken()->getUser()->getId();
     $collection = new ResourceCollection([$dropzone->getResourceNode()]);
     $isAllowedToEdit = $this->get('security.authorization_checker')->isGranted('EDIT', $collection);
     // getting the data
     $dropSecure = $this->getDoctrine()->getRepository('IcapDropzoneBundle:Drop')->getDropAndValidEndedCorrectionsAndDocumentsByUser($dropzone, $drop->getId(), $userId);
     // if there is no result ( user is not the owner, or the drop has not ended Corrections , show 404)
     if (count($dropSecure) === 0) {
         if ($drop->getUser()->getId() !== $userId) {
             throw new AccessDeniedException();
         }
     } else {
         $drop = $dropSecure[0];
     }
     $showCorrections = false;
     // if drop is complete and corrections needed were made  and dropzone.showCorrection is true.
     $user = $drop->getUser();
     $em = $this->getDoctrine()->getManager();
     $nbCorrections = $em->getRepository('IcapDropzoneBundle:Correction')->countFinished($dropzone, $user);
     if ($dropzone->getDiplayCorrectionsToLearners() && $drop->countFinishedCorrections() >= $dropzone->getExpectedTotalCorrection() && $dropzone->getExpectedTotalCorrection() <= $nbCorrections || ($dropzone->isFinished() && $dropzone->getDiplayCorrectionsToLearners() || $drop->getUnlockedUser())) {
         $showCorrections = true;
     }
     return ['workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'drop' => $drop, 'isAllowedToEdit' => $isAllowedToEdit, 'showCorrections' => $showCorrections];
 }