/**
  * @param \Innova\CollecticielBundle\Entity\Dropzone $dropzone
  * @param \Innova\CollecticielBundle\Entity\Drop     $drop
  *
  * @internal param \Innova\CollecticielBundle\Event\Log\Wiki $wiki
  * @internal param \Innova\CollecticielBundle\Event\Log\Section $section
  * @internal param \Innova\CollecticielBundle\Event\Log\Contribution $contribution
  */
 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 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 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);
 }
 public function create($dropzone, $user)
 {
     $drop = new Drop();
     $number = $this->dropRepo->getLastNumber($dropzone) + 1;
     $drop->setNumber($number);
     $drop->setUser($user);
     $drop->setDropzone($dropzone);
     $drop->setFinished(false);
     $this->em->persist($drop);
     $this->em->flush();
     $this->em->refresh($drop);
     return $drop;
 }
 /**
  * @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));
 }
 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);
             }
         }
     }
 }
Esempio n. 10
0
 /**
  * @param Drop $drop
  * @param User $user
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @Route(
  *                                                            "/unlock/drop/{dropId}",
  *                                                            name="innova_collecticiel_unlock_drop",
  *                                                            requirements={"resourceId" = "\d+", "dropId" = "\d+"}
  *                                                            )
  * @ParamConverter("drop", class="InnovaCollecticielBundle:Drop", options={"id" = "dropId"})
  * @ParamConverter("user", options={
  *                                                            "authenticatedUser" = true,
  *                                                            "messageEnabled" = true,
  *                                                            "messageTranslationKey" = "This action requires authentication. Please login.",
  *                                                            "messageTranslationDomain" = "innova_collecticiel"
  *                                                            })
  * @Template()
  */
 public function unlockDropAction(Drop $drop, User $user)
 {
     $em = $this->getDoctrine()->getManager();
     $drop->setUnlockedDrop(true);
     $em->flush();
     $this->getRequest()->getSession()->getFlashBag()->add('success', $this->get('translator')->trans('Drop have been unlocked', [], 'innova_collecticiel'));
     $dropzoneId = $drop->getDropzone()->getId();
     return $this->redirect($this->generateUrl('innova_collecticiel_drops_awaiting', ['resourceId' => $dropzoneId]));
 }
 private function checkUserGradeAvailableByDrop(Drop $drop)
 {
     $user = $drop->getUser();
     $dropzone = $drop->getDropzone();
     $this->checkUserGradeAvailable($dropzone, $drop, $user);
 }
 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);
             }
         }
     }
 }
 /**
  * @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()));
 }
 /**
  * @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);
 }
Esempio n. 15
0
 /**
  * Handle CommentText for Documents.
  *
  * @param Drop $drop drop
  *
  * @return notationCommentTextDocuments
  */
 public function getChoiceTextForDocuments(Drop $drop)
 {
     $notationChoiceTextDocuments = array();
     $dropzone = $drop->getDropzone();
     foreach ($drop->getDocuments() as $document) {
         $documentId = $document->getId();
         // Ajout pour avoir la notation.
         $notations = $this->em->getRepository('InnovaCollecticielBundle:Notation')->findBy(array('document' => $documentId, 'dropzone' => $dropzone->getId()));
         // Nombre de notation pour le document et pour le dropzone
         $countExistNotation = count($notations);
         if ($countExistNotation == 0) {
             $notationCommentTextDocuments[$documentId] = '';
         } else {
             // Parcours des commentaires des documents sélectionnés
             foreach ($notations as $notation) {
                 if (strlen($notation->getCommentText()) == 0) {
                     $notationCommentTextDocuments[$documentId] = '';
                 } else {
                     $notationCommentTextDocuments[$documentId] = $notation->getCommentText();
                 }
             }
         }
     }
     return $notationChoiceTextDocuments;
 }
 /**
  * @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);
 }
 /**
  *
  * 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  \Innova\CollecticielBundle\Entity\Dropzone                                     $dropzone
  * @param  \Innova\CollecticielBundle\Entity\Drop|\Innova\CollecticielBundle\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++;
                 }
             } elseif ($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);
 }