public function onCopy(CopyResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $resource = $event->getResource();
     $event->setCopy($this->container->get('claroline.manager.forum_manager')->copy($resource));
     $event->stopPropagation();
 }
 public function onCopy(CopyResourceEvent $event)
 {
     $simupoll = $event->getResource();
     $loggedUser = $this->container->get('security.token_storage')->getToken()->getUser();
     $newSimupoll = null;
     $newSimupoll = $this->container->get('cpasimusante.simupoll.simupoll_manager')->copySimupoll($simupoll, $loggedUser);
     $event->setCopy($newSimupoll);
     $event->stopPropagation();
 }
 public function onCopy(CopyResourceEvent $event)
 {
     $entityManager = $this->container->get('doctrine.orm.entity_manager');
     $lesson = $event->getResource();
     $newLesson = new Lesson();
     $newLesson->setName($lesson->getResourceNode()->getName());
     $entityManager->persist($newLesson);
     $entityManager->flush($newLesson);
     //$chapterRepository = $entityManager->getRepository('IcapLessonBundle:Chapter');
     $chapter_manager = $this->container->get('icap.lesson.manager.chapter');
     $chapter_manager->copyRoot($lesson->getRoot(), $newLesson->getRoot());
     $event->setCopy($newLesson);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_icap_website")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $website = $event->getResource();
     $newWebsite = $this->container->get('icap.website.manager')->copyWebsite($website);
     $event->setCopy($newWebsite);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_claroline_chat_room")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $chatRoom = $event->getResource();
     $copy = $this->chatManager->copyChatRoom($chatRoom);
     $event->setCopy($copy);
     $event->stopPropagation();
 }
 public function onCopy(CopyResourceEvent $event)
 {
     $entityManager = $this->container->get('claroline.persistence.object_manager');
     /** @var \Icap\BlogBundle\Entity\Blog $blog */
     $blog = $event->getResource();
     $user = $this->container->get('security.token_storage')->getToken()->getUser();
     $newBlog = new Blog();
     $entityManager->persist($newBlog);
     $entityManager->flush($newBlog);
     foreach ($blog->getPosts() as $post) {
         /** @var \Icap\BlogBundle\Entity\Post $newPost */
         $newPost = new Post();
         $newPost->setTitle($post->getTitle())->setContent($post->getContent())->setAuthor($post->getAuthor())->setStatus($post->getStatus())->setBlog($newBlog);
         $newTags = $post->getTags();
         foreach ($newTags as $tag) {
             $newPost->addTag($tag);
         }
         $entityManager->persist($newPost);
         $entityManager->flush($newPost);
         foreach ($post->getComments() as $comment) {
             /** @var \Icap\BlogBundle\Entity\Comment $newComment */
             $newComment = new Comment();
             $newComment->setAuthor($comment->getAuthor())->setMessage($comment->getMessage())->setPost($newPost);
         }
     }
     $entityManager->persist($newBlog);
     $event->setCopy($newBlog);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_claroline_survey")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $workspace = $event->getParent()->getWorkspace();
     $survey = $event->getResource();
     $copy = new Survey();
     $copy->setPublished($survey->isPublished());
     $copy->setClosed($survey->isClosed());
     $copy->setHasPublicResult($survey->getHasPublicResult());
     $copy->setAllowAnswerEdition($survey->getAllowAnswerEdition());
     $copy->setStartDate($survey->getStartDate());
     $copy->setEndDate($survey->getEndDate());
     $this->om->persist($copy);
     $relations = $survey->getQuestionRelations();
     foreach ($relations as $relation) {
         $question = $relation->getQuestion();
         $type = $question->getType();
         $copyQuestion = new Question();
         $copyQuestion->setTitle($question->getTitle());
         $copyQuestion->setQuestion($question->getQuestion());
         $copyQuestion->setWorkspace($workspace);
         $copyQuestion->setType($type);
         $copyQuestion->setCommentAllowed($question->isCommentAllowed());
         $copyQuestion->setCommentLabel($question->getCommentLabel());
         $this->om->persist($copyQuestion);
         switch ($type) {
             case 'multiple_choice_single':
             case 'multiple_choice_multiple':
                 $multiChoiceQuestion = $this->surveyManager->getMultipleChoiceQuestionByQuestion($question);
                 $choices = $multiChoiceQuestion->getChoices();
                 $copyMultiQuestion = new MultipleChoiceQuestion();
                 $copyMultiQuestion->setHorizontal($multiChoiceQuestion->getHorizontal());
                 $copyMultiQuestion->setQuestion($copyQuestion);
                 foreach ($choices as $choice) {
                     $copyChoice = new Choice();
                     $copyChoice->setContent($choice->getContent());
                     $copyChoice->setOther($choice->isOther());
                     $copyChoice->setChoiceQuestion($copyMultiQuestion);
                     $this->om->persist($copyChoice);
                 }
                 $this->om->persist($copyMultiQuestion);
                 break;
             case 'open-ended':
             default:
                 break;
         }
         $copyRelation = new SurveyQuestionRelation();
         $copyRelation->setSurvey($copy);
         $copyRelation->setQuestion($copyQuestion);
         $copyRelation->setQuestionOrder($relation->getQuestionOrder());
         $this->om->persist($copyRelation);
     }
     $event->setCopy($copy);
     $event->stopPropagation();
 }
 public function onCopy(CopyResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $resource = $event->getResource();
     $exerciseToCopy = $em->getRepository('UJMExoBundle:Exercise')->find($resource->getId());
     $listQuestionsExoToCopy = $em->getRepository('UJMExoBundle:ExerciseQuestion')->findBy(array('exercise' => $exerciseToCopy->getId()));
     $newExercise = new Exercise();
     $newExercise->setName($resource->getName());
     $newExercise->setTitle($exerciseToCopy->getTitle());
     $newExercise->setDescription($exerciseToCopy->getDescription());
     $newExercise->setShuffle($exerciseToCopy->getShuffle());
     $newExercise->setNbQuestion($exerciseToCopy->getNbQuestion());
     $newExercise->setDateCreate($exerciseToCopy->getDateCreate());
     $newExercise->setDuration($exerciseToCopy->getDuration());
     $newExercise->setNbQuestionPage($exerciseToCopy->getNbQuestionPage());
     $newExercise->setDoprint($exerciseToCopy->getDoprint());
     $newExercise->setMaxAttempts($exerciseToCopy->getMaxAttempts());
     $newExercise->setCorrectionMode($exerciseToCopy->getCorrectionMode());
     $newExercise->setDateCorrection($exerciseToCopy->getDateCorrection());
     $newExercise->setMarkMode($exerciseToCopy->getMarkMode());
     $newExercise->setStartDate($exerciseToCopy->getStartDate());
     $newExercise->setUseDateEnd($exerciseToCopy->getUseDateEnd());
     $newExercise->setEndDate($exerciseToCopy->getEndDate());
     $newExercise->setDispButtonInterrupt($exerciseToCopy->getDispButtonInterrupt());
     $newExercise->setLockAttempt($exerciseToCopy->getLockAttempt());
     $newExercise->setPublished($exerciseToCopy->getPublished());
     $em->persist($newExercise);
     $em->flush();
     foreach ($listQuestionsExoToCopy as $eq) {
         $questionToAdd = $em->getRepository('UJMExoBundle:Question')->find($eq->getQuestion());
         $exerciseQuestion = new ExerciseQuestion($newExercise, $questionToAdd);
         $exerciseQuestion->setOrdre($eq->getOrdre());
         $em->persist($exerciseQuestion);
     }
     $user = $this->container->get('security.token_storage')->getToken()->getUser();
     $subscription = new Subscription($user, $newExercise);
     $subscription->setAdmin(true);
     $subscription->setCreator(true);
     $em->persist($subscription);
     $em->flush();
     $event->setCopy($newExercise);
     $event->stopPropagation();
 }
Beispiel #9
0
 /**
  * @DI\Observe("copy_file")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $newFile = $this->copy($event->getResource(), $event->getParent());
     $event->setCopy($newFile);
     $event->stopPropagation();
 }
 /**
  * @Observe("copy_activity")
  *
  * @todo: Do the resources need to be copied ?
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $activity = $this->activityManager->copyActivity($event->getResource());
     $this->persistence->persist($activity);
     $event->setCopy($activity);
     $event->stopPropagation();
 }
Beispiel #11
0
 /**
  * @DI\Observe("copy_icap_wiki")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $wiki = $event->getResource();
     $loggedUser = $this->container->get('security.token_storage')->getToken()->getUser();
     $newWiki = $this->container->get('icap.wiki.manager')->copyWiki($wiki, $loggedUser);
     $event->setCopy($newWiki);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_icap_dropzone")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     /** @var Dropzone $resource */
     $resource = $event->getResource();
     $newDropzone = new Dropzone();
     $newDropzone->setName($resource->getName());
     $newDropzone->setAllowCommentInCorrection($resource->getAllowCommentInCorrection());
     $newDropzone->setAllowRichText($resource->getAllowRichText());
     $newDropzone->setAllowUpload($resource->getAllowUpload());
     $newDropzone->setAllowUrl($resource->getAllowUrl());
     $newDropzone->setAllowWorkspaceResource($resource->getAllowWorkspaceResource());
     $newDropzone->setDisplayNotationMessageToLearners($resource->getDisplayNotationMessageToLearners());
     $newDropzone->setDisplayNotationToLearners($resource->getDisplayNotationToLearners());
     $newDropzone->setEditionState($resource->getEditionState());
     $newDropzone->setEndAllowDrop($resource->getEndAllowDrop());
     $newDropzone->setEndReview($resource->getEndReview());
     $newDropzone->setExpectedTotalCorrection($resource->getExpectedTotalCorrection());
     $newDropzone->setInstruction($resource->getInstruction());
     $newDropzone->setManualPlanning($resource->getManualPlanning());
     $newDropzone->setManualState($resource->getManualState());
     $newDropzone->setMinimumScoreToPass($resource->getMinimumScoreToPass());
     $newDropzone->setPeerReview($resource->getPeerReview());
     $newDropzone->setStartAllowDrop($resource->getStartAllowDrop());
     $newDropzone->setStartReview($resource->getStartReview());
     $newDropzone->setTotalCriteriaColumn($resource->getTotalCriteriaColumn());
     $oldCriteria = $resource->getPeerReviewCriteria();
     foreach ($oldCriteria as $oldCriterion) {
         $newCriterion = new Criterion();
         $newCriterion->setInstruction($oldCriterion->getInstruction());
         $newDropzone->addCriterion($newCriterion);
     }
     $em->persist($newDropzone);
     $event->setCopy($newDropzone);
     $event->stopPropagation();
 }
 /**
  * Fired when a ResourceNode of type Path is duplicated
  * @param \Claroline\CoreBundle\Event\CopyResourceEvent $event
  * @throws \Exception
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $om = $this->container->get('claroline.persistence.object_manager');
     // Start the transaction. We'll copy every resource in one go that way.
     $om->startFlushSuite();
     // Get Path to duplicate
     $pathToCopy = $event->getResource();
     // Create new Path
     $path = new Path();
     // Set up new Path properties
     $path->setName($pathToCopy->getName());
     $path->setDescription($pathToCopy->getDescription());
     $parent = $event->getParent();
     $structure = json_decode($pathToCopy->getStructure());
     // Process steps
     $processedNodes = array();
     foreach ($structure->steps as $step) {
         $processedNodes = $this->copyStepContent($step, $parent, $processedNodes);
     }
     // End the transaction
     $om->endFlushSuite();
     // We need the resources ids
     $om->forceFlush();
     //update the structure tree
     foreach ($structure->steps as $step) {
         $this->updateStep($step, $processedNodes);
     }
     $path->setStructure(json_encode($structure));
     $event->setCopy($path);
     // Force the unpublished state (the publication will recreate the correct links, and create new Activities)
     // If we directly copy all the published Entities we can't remap some relations
     $event->setPublish(false);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_claroline_announcement_aggregate")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $aggregate = $event->getResource();
     $copy = new AnnouncementAggregate();
     $this->om->persist($copy);
     $announcements = $aggregate->getAnnouncements();
     foreach ($announcements as $announcement) {
         $newAnnouncement = new Announcement();
         $newAnnouncement->setAggregate($copy);
         $newAnnouncement->setAnnouncer($announcement->getAnnouncer());
         $newAnnouncement->setContent($announcement->getContent());
         $newAnnouncement->setCreationDate($announcement->getCreationDate());
         $newAnnouncement->setCreator($announcement->getCreator());
         $newAnnouncement->setPublicationDate($announcement->getPublicationDate());
         $newAnnouncement->setTitle($announcement->getTitle());
         $newAnnouncement->setVisible($announcement->isVisible());
         $newAnnouncement->setVisibleFrom($announcement->getVisibleFrom());
         $newAnnouncement->setVisibleUntil($announcement->getVisibleUntil());
         $this->om->persist($newAnnouncement);
     }
     $event->setCopy($copy);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_cpasimusante_simuresource")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $resource = $event->getResource();
     //Retrieve the entity (as an object) from the repository
     $resourceNow = $em->getRepository('CPASimUSanteSimuResourceBundle:SimuResource')->find($resource->getId());
     //Copy the entity into a new one
     $resourceNew = new SimuResource();
     //custom entity fields
     $resourceNew->setField($resourceNow->getField());
     $resourceNew->setOtherfield($resourceNow->getOtherfield());
     //generic entity fields
     $resourceNew->setName($resourceNow->getName());
     //Save the entity
     $em->persist($resourceNew);
     $em->flush();
     //Set the copy (Claroline stuff)
     $event->setCopy($resourceNew);
     $event->stopPropagation();
 }
Beispiel #16
0
 /**
  * @DI\Observe("copy_claroline_survey")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $survey = $event->getResource();
     $copy = new Survey();
     $copy->setPublished($survey->isPublished());
     $copy->setClosed($survey->isClosed());
     $copy->setHasPublicResult($survey->getHasPublicResult());
     $copy->setAllowAnswerEdition($survey->getAllowAnswerEdition());
     $copy->setStartDate($survey->getStartDate());
     $copy->setEndDate($survey->getEndDate());
     $this->om->persist($copy);
     $relations = $survey->getQuestionRelations();
     foreach ($relations as $relation) {
         $newRelation = new SurveyQuestionRelation();
         $newRelation->setSurvey($copy);
         $newRelation->setQuestion($relation->getQuestion());
         $newRelation->setQuestionOrder($relation->getQuestionOrder());
         $this->om->persist($newRelation);
     }
     $event->setCopy($copy);
     $event->stopPropagation();
 }
Beispiel #17
0
 /**
  * @DI\Observe("copy_hevinci_url")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $resource = $event->getResource();
     $copy = new Url();
     $copy->setName($resource->getName());
     $copy->setUrl($resource->getUrl());
     $copy->setInternalUrl($resource->getInternalUrl());
     $event->setCopy($copy);
     $event->stopPropagation();
 }
Beispiel #18
0
 /**
  * Fired when a ResourceNode of type Path is duplicated
  * @param \Claroline\CoreBundle\Event\CopyResourceEvent $event
  * @throws \Exception
  */
 public function onCopy(CopyResourceEvent $event)
 {
     // Get Path to duplicate
     $pathToCopy = $event->getResource();
     // Create new Path
     $path = new Path();
     // Set up new Path properties
     $path->setName($pathToCopy->getName());
     $path->setDescription($pathToCopy->getDescription());
     $parent = $event->getParent();
     $structure = json_decode($pathToCopy->getStructure());
     // Process steps
     $processedNodes = array();
     foreach ($structure->steps as $step) {
         $processedNodes = $this->copyStepContent($step, $parent, $processedNodes);
     }
     // Store the new structure of the Path
     $path->setStructure(json_encode($structure));
     $event->setCopy($path);
     // Force the unpublished state (the publication will recreate the correct links, and create new Activities)
     // If we directly copy all the published Entities we can't remap some relations
     $event->setPublish(false);
     $event->stopPropagation();
 }
 public function onCopy(CopyResourceEvent $event)
 {
     $newRes = null;
     $event->setCopy($newRes);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_claroline_scorm_12")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $resource = $event->getResource();
     $copy = new Scorm12Resource();
     $copy->setHashName($resource->getHashName());
     $copy->setName($resource->getName());
     $this->om->persist($copy);
     $scos = $resource->getScos();
     foreach ($scos as $sco) {
         if (is_null($sco->getScoParent())) {
             $this->copySco($sco, $copy);
         }
     }
     $event->setCopy($copy);
     $event->stopPropagation();
 }
 /**
  * Fired when a ResourceNode of type MediaResource is duplicated.
  *
  * @DI\Observe("copy_innova_media_resource")
  *
  * @param \Claroline\CoreBundle\Event\CopyResourceEvent $event
  *
  * @throws \Exception
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $toCopy = $event->getResource();
     $new = new MediaResource();
     $new->setName($toCopy->getName());
     // copy options
     $this->container->get('innova_media_resource.manager.media_resource')->copyOptions($new, $toCopy);
     // duplicate media resource media(s) (=file(s))
     $medias = $toCopy->getMedias();
     foreach ($medias as $media) {
         $this->container->get('innova_media_resource.manager.media_resource')->copyMedia($new, $media);
     }
     // duplicate regions and region config
     $regions = $toCopy->getRegions();
     foreach ($regions as $region) {
         $this->container->get('innova_media_resource.manager.media_resource_region')->copyRegion($new, $region);
     }
     $event->setCopy($new);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("copy_ujm_exercise")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $newExercise = $this->container->get('ujm.exo.exercise_manager')->copyExercise($event->getResource());
     $this->container->get('doctrine.orm.entity_manager')->persist($newExercise);
     // Create Subscription for User who has copied the Exercise
     $user = $this->container->get('security.token_storage')->getToken()->getUser();
     $this->container->get('ujm.exo.subscription_manager')->subscribe($newExercise, $user);
     $event->setCopy($newExercise);
     $event->stopPropagation();
 }