コード例 #1
0
 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('InnovaCollecticielBundle: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);
             }
         }
     }
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #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
 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('InnovaCollecticielBundle: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);
             }
         }
     }
 }
コード例 #5
0
 /**
  * @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);
 }
コード例 #6
0
 /**
  * @Route(
  *      "/{resourceId}/delete/document/{dropId}/{documentId}",
  *      name="innova_collecticiel_delete_document",
  *      requirements={"resourceId" = "\d+", "dropId" = "\d+", "documentId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("user", options={"authenticatedUser" = true})
  * @ParamConverter("drop", class="InnovaCollecticielBundle:Drop", options={"id" = "dropId"})
  * @ParamConverter("document", class="InnovaCollecticielBundle:Document", options={"id" = "documentId"})
  * @Template()
  */
 public function deleteDocumentAction(Dropzone $dropzone, $user, Drop $drop, Document $document)
 {
     $dropzoneManager = $this->get('innova.manager.dropzone_manager');
     $this->get('innova.manager.dropzone_voter')->isAllowToOpen($dropzone);
     $canEdit = $this->get('innova.manager.dropzone_voter')->checkEditRight($dropzone);
     if ($drop->getId() != $document->getDrop()->getId()) {
         throw new \HttpInvalidParamException();
     }
     if ($drop->getUser()->getId() != $user->getId() && !$canEdit) {
         throw new AccessDeniedException();
     }
     $form = $this->createForm(new DocumentDeleteType(), $document);
     if ($this->getRequest()->isMethod('POST')) {
         $form->handleRequest($this->getRequest());
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             // InnovaERV : vu avec Axel car souci lors de la suppression
             if ('url' !== $document->getType()) {
                 // There is no ResourceNode for URL
                 $this->container->get('claroline.manager.resource_manager')->delete($document->getResourceNode());
             }
             $em->remove($document);
             $em->flush();
             $event = new LogDocumentDeleteEvent($dropzone, $drop, $document);
             $this->dispatch($event);
             return $this->redirect($this->generateUrl('innova_collecticiel_drop_switch', array('resourceId' => $dropzone->getId(), 'userId' => $drop->getUser()->getId())));
         }
     }
     $collecticielOpenOrNot = $dropzoneManager->collecticielOpenOrNot($dropzone);
     $view = 'InnovaCollecticielBundle:Document:deleteDocument.html.twig';
     if ($this->getRequest()->isXMLHttpRequest()) {
         $view = 'InnovaCollecticielBundle:Document:deleteDocumentModal.html.twig';
     }
     return $this->render($view, array('workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'drop' => $drop, 'document' => $document, 'form' => $form->createView(), 'collecticielOpenOrNot' => $collecticielOpenOrNot));
 }
コード例 #7
0
 /**
  * @Route(
  *      "/{resourceId}/drop/detail/{dropId}",
  *      name="innova_collecticiel_drop_detail_by_user",
  *      requirements={"resourceId" = "\d+", "dropId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("drop", class="InnovaCollecticielBundle:Drop", options={"id" = "dropId"})
  * @Template()
  */
 public function dropDetailAction(Dropzone $dropzone, Drop $drop)
 {
     // check  if the User is allowed to open the dropZone.
     $this->get('innova.manager.dropzone_voter')->isAllowToOpen($dropzone);
     // getting the userId to check if the current drop owner match with the loggued user.
     $userId = $this->get('security.context')->getToken()->getUser()->getId();
     $collection = new ResourceCollection([$dropzone->getResourceNode()]);
     $isAllowedToEdit = $this->get('security.context')->isGranted('EDIT', $collection);
     // getting the data
     $dropSecure = $this->getDoctrine()->getRepository('InnovaCollecticielBundle: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('InnovaCollecticielBundle: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];
 }
コード例 #8
0
 private function checkUserGradeAvailableByDrop(Drop $drop)
 {
     $user = $drop->getUser();
     $dropzone = $drop->getDropzone();
     $this->checkUserGradeAvailable($dropzone, $drop, $user);
 }
コード例 #9
0
 /**
  * @Route(
  *      "/{resourceId}/delete/document/{dropId}/{documentId}",
  *      name="innova_collecticiel_delete_document",
  *      requirements={"resourceId" = "\d+", "dropId" = "\d+", "documentId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("user", options={"authenticatedUser" = true})
  * @ParamConverter("drop", class="InnovaCollecticielBundle:Drop", options={"id" = "dropId"})
  * @ParamConverter("document", class="InnovaCollecticielBundle:Document", options={"id" = "documentId"})
  * @Template()
  */
 public function deleteDocumentAction(Dropzone $dropzone, $user, Drop $drop, Document $document)
 {
     $this->get('innova.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 ($this->getRequest()->isMethod('POST')) {
         $form->handleRequest($this->getRequest());
         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('innova_collecticiel_drop', array('resourceId' => $dropzone->getId())));
         }
     }
     $view = 'InnovaCollecticielBundle:Document:deleteDocument.html.twig';
     if ($this->getRequest()->isXMLHttpRequest()) {
         $view = 'InnovaCollecticielBundle:Document:deleteDocumentModal.html.twig';
     }
     return $this->render($view, array('workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'drop' => $drop, 'document' => $document, 'form' => $form->createView()));
 }