/**
  * @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 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 $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
  */
 public function __construct(Dropzone $dropzone, Drop $drop)
 {
     $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId()));
     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="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));
 }
Ejemplo n.º 10
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];
 }
 /**
  * @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()));
 }