コード例 #1
0
 /**
  * Export a Collecticiel.
  *
  * @param Workspace $workspace
  * @param array     $files
  * @param Dropzone  $dropzone
  *
  * @return array
  */
 public function export(Workspace $workspace, array &$files, Dropzone $dropzone)
 {
     $data = [];
     $uid = uniqid() . '.txt';
     $tmpPath = $this->ch->getParameter('tmp_dir') . DIRECTORY_SEPARATOR . $uid;
     file_put_contents($tmpPath, $dropzone->getInstruction());
     $files[$uid] = $tmpPath;
     $data['instruction'] = $uid;
     $data['allow_workspace_resource'] = $dropzone->getAllowWorkspaceResource();
     $data['allow_upload'] = $dropzone->getAllowUpload();
     $data['allow_url'] = $dropzone->getAllowUrl();
     $data['allow_rich_text'] = $dropzone->getAllowRichText();
     $data['manual_planning'] = $dropzone->getManualPlanning();
     $data['manual_state'] = $dropzone->getManualState();
     $startDate = $dropzone->getStartAllowDrop();
     if (!empty($startDate)) {
         $data['start_allow_drop'] = $startDate->format('Y-m-d H:i:s');
     }
     $endDate = $dropzone->getEndAllowDrop();
     if (!empty($endDate)) {
         $data['end_allow_drop'] = $endDate->format('Y-m-d H:i:s');
     }
     return $data;
 }
コード例 #2
0
 /**
  * @Route(
  *      "/add/comments/{userId}/{dropzoneId}",
  *      name="innova_collecticiel_add_comment_for_docs",
  *      requirements={"userId" = "\d+", "dropzoneId" = "\d+"}
  * )
  * @ParamConverter("user",class="ClarolineCoreBundle:User",options={"id" = "userId"})
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "dropzoneId"})
  * @Method("POST")
  * @Template()
  */
 public function addCommentForDocsInnovaAction(User $user, Dropzone $dropzone)
 {
     // Saisie des commentaires à la volée.
     // Récupération de l'USER
     $user = $this->get('security.context')->getToken()->getUser();
     $em = $this->getDoctrine()->getManager();
     $comment = new Comment();
     $form = $this->get('form.factory')->createBuilder(new CommentType(), $comment)->getForm();
     // Récupération de la saisie du commentaire
     $request = $this->get('request');
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             // Récupération du commentaire
             $commentText = $comment->getCommentText();
             // Récupération des documents sur lesquels porte le commentaire saisi
             $docs = $this->getRequest()->request->get('docs');
             // Récupération des ID des documents
             $explodeDocIdS = explode('|', $docs);
             // Parcours du tableau des documents
             foreach ($explodeDocIdS as $documentId) {
                 // Je ne prends pas le dernier élément du tableau
                 if (is_numeric($documentId)) {
                     // Création du nouveau commentaire
                     $document = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Document')->find($documentId);
                     // Valorisation du commentaire
                     $comment = new Comment();
                     $comment->setDocument($document);
                     $comment->setCommentText($commentText);
                     $comment->setUser($user);
                     // Insertion en base du commentaire
                     $em->persist($comment);
                     // Envoi notification. InnovaERV
                     $usersIds = [];
                     // Ici, on récupère le créateur du collecticiel = l'admin
                     if ($document->getType() === 'url') {
                         $userCreator = $document->getDrop()->getDropzone()->getResourceNode()->getCreator()->getId();
                     } else {
                         $userCreator = $document->getResourceNode()->getCreator()->getId();
                     }
                     // Ici, on récupère celui qui vient de déposer le nouveau document
                     $userDropDocument = $document->getDrop()->getUser()->getId();
                     $userSenderDocument = $document->getSender()->getId();
                     if ($userCreator === $userSenderDocument) {
                         // Ici avertir l'étudiant qui a travaillé sur ce collecticiel
                         $usersIds[] = $userDropDocument;
                     } else {
                         // Ici avertir celui a qui créé le collecticiel
                         $usersIds[] = $userCreator;
                     }
                     $event = new LogDropzoneAddCommentEvent($dropzone, $dropzone->getManualState(), $usersIds, $comment);
                     $this->get('event_dispatcher')->dispatch('log', $event);
                 }
             }
             $em->flush();
         }
     }
     // Ajouter la création du log de la création du commentaire. InnovaERV.
     $unitOfWork = $em->getUnitOfWork();
     $unitOfWork->computeChangeSets();
     $dropzoneChangeSet = $unitOfWork->getEntityChangeSet($dropzone);
     $event = new LogCommentCreateEvent($dropzone, $dropzoneChangeSet, $comment);
     $this->dispatch($event);
     // Redirection vers les demandes adressées. InnovaERV.
     return $this->redirect($this->generateUrl('innova_collecticiel_drops_awaiting', ['resourceId' => $dropzone->getId()]));
 }
コード例 #3
0
 /**
  * @Route(
  *      "/{documentId}/add/comments/{userId}/{dropzoneId}/{correctionId}",
  *      name="innova_collecticiel_add_comment",
  *      requirements={"documentId" = "\d+", "userId" = "\d+", "dropzoneId" = "\d+", "correctionId" = "\d+"}
  * )
  * @ParamConverter("document", class="InnovaCollecticielBundle:Document", options={"id" = "documentId"})
  * @ParamConverter("user",class="ClarolineCoreBundle:User",options={"id" = "userId"})
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "dropzoneId"})
  * @ParamConverter("correction", class="InnovaCollecticielBundle:Correction", options={"id" = "correctionId"})
  * @Method("POST")
  * @Template()
  */
 public function AddCommentsInnovaAction(Document $document, User $user, Dropzone $dropzone, Correction $correction)
 {
     $em = $this->getDoctrine()->getManager();
     // Valorisation du commentaire
     $comment = new Comment();
     $comment->setDocument($document);
     $comment->setUser($user);
     $form = $this->get('form.factory')->createBuilder(new CommentType(), $comment)->getForm();
     // Récupération de la saisie du commentaire
     $request = $this->get('request');
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             // Insertion en base du commentaire
             $em->persist($comment);
             $em->flush();
             $dropzoneManager = $this->get('innova.manager.dropzone_manager');
             // Envoi notification. InnovaERV
             //                $usersIds = $dropzoneManager->getDropzoneUsersIds($dropzone);
             $usersIds = array();
             $usersIds[] = $dropzone->getResourceNode()->getCreator()->getId();
             $usersIds[] = $document->getSender()->getId();
             $event = new LogDropzoneAddCommentEvent($dropzone, $dropzone->getManualState(), $usersIds);
             $this->get('event_dispatcher')->dispatch('log', $event);
         }
     }
     // Ajouter la création du log de la création du commentaire. InnovaERV.
     $unitOfWork = $em->getUnitOfWork();
     $unitOfWork->computeChangeSets();
     $dropzoneChangeSet = $unitOfWork->getEntityChangeSet($dropzone);
     $event = new LogCommentCreateEvent($dropzone, $dropzoneChangeSet, $comment);
     $this->dispatch($event);
     // Redirection vers la page des commentaires. InnovaERV.
     return $this->redirect($this->generateUrl('innova_collecticiel_drops_detail_comment', array('resourceId' => $dropzone->getId(), 'state' => 'edit', 'correctionId' => $correction->getId(), 'documentId' => $document->getId())));
 }
コード例 #4
0
 /**
  * To know if a collecticiel is open or not (close) InnovaERV
  */
 public function collecticielOpenOrNot(Dropzone $dropzone)
 {
     $open = false;
     /**
      * "Manuellement" InnovaERV
      */
     if ($dropzone->getManualPlanning() == 1 && $dropzone->getManualState() == Dropzone::MANUAL_STATE_ALLOW_DROP) {
         $open = true;
     }
     /**
      * "Par dates" InnovaERV
      */
     if ($dropzone->getManualPlanning() == 0) {
         $now = new \DateTime();
         if ($dropzone->getStartAllowDrop()->getTimestamp() < $now->getTimestamp() && $now->getTimestamp() < $dropzone->getEndAllowDrop()->getTimestamp()) {
             $open = true;
         }
     }
     return $open;
 }
コード例 #5
0
 /**
  *  Test to detect the special case where the peerReview end whereas user didnt had time to make the expected
  *  number of correction.
  *
  * @param Dropzone $dropzone
  * @param $nbCorrection
  * @return bool
  */
 public function isPeerReviewEndedOrManualStateFinished(Dropzone $dropzone, $nbCorrection)
 {
     $specialCase = false;
     if ($dropzone->getManualPlanning() && $dropzone->getManualState() == Dropzone::MANUAL_STATE_FINISHED || !$dropzone->getManualPlanning() && $dropzone->getTimeRemaining($dropzone->getEndReview()) <= 0) {
         if ($dropzone->getExpectedTotalCorrection() > $nbCorrection) {
             $specialCase = true;
         }
     }
     return $specialCase;
 }