コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
 /**
  * @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);
 }
コード例 #6
0
 /**
  * @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);
 }
コード例 #7
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);
 }
コード例 #8
0
 /**
  * @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()));
 }
コード例 #9
0
 /**
  * @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);
 }
コード例 #10
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];
 }