示例#1
0
 public function result($title, User $creator, $total = 20)
 {
     $result = new Result();
     $result->setTotal($total);
     if (!$this->resultType) {
         $this->resultType = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('claroline_result');
     }
     $node = new ResourceNode();
     $node->setName($title);
     $node->setCreator($creator);
     $node->setResourceType($this->resultType);
     $node->setWorkspace($creator->getPersonalWorkspace());
     $node->setClass('Claroline\\ResultBundle\\Entity\\Result');
     $node->setGuid(time());
     $result->setResourceNode($node);
     $this->om->persist($result);
     $this->om->persist($node);
     return $result;
 }
示例#2
0
 public function lesson($title, User $creator)
 {
     $lesson = new Lesson();
     if (!$this->lessonType) {
         $this->lessonType = new ResourceType();
         $this->lessonType->setName('icap_lesson');
         $this->om->persist($this->lessonType);
     }
     $node = new ResourceNode();
     $node->setName($title);
     $node->setCreator($creator);
     $node->setResourceType($this->lessonType);
     $node->setWorkspace($creator->getPersonalWorkspace());
     $node->setClass('Icap\\LessonBundle\\Entity\\Lesson');
     $node->setGuid(time());
     $lesson->setResourceNode($node);
     $this->om->persist($lesson);
     $this->om->persist($node);
     $this->om->flush();
     return $lesson;
 }
 public function load(ObjectManager $manager)
 {
     $user = $manager->getRepository('ClarolineCoreBundle:User')->findOneById(1);
     $resourceType = $manager->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('ujm_exercise');
     $ws = $manager->getRepository('ClarolineCoreBundle:Workspace\\Workspace')->findOneById(2);
     $guid = $this->container->get('claroline.utilities.misc')->generateGuid();
     $node = new ResourceNode();
     $node->setResourceType($resourceType);
     $node->setCreator($user);
     $node->setCreationDate(new \Datetime());
     $node->setName('ExoFIX Title 1');
     $node->setWorkspace($ws);
     $node->setMimeType('custom/ujm_exercise');
     $node->setPublished(true);
     $node->setActive(true);
     $node->setClass('UJM\\ExoBundle\\Entity\\Exercise');
     $node->setGuid($guid);
     /*
             $rn->setParent();
     */
     $manager->persist($node);
     $manager->flush();
     $this->addReference('rn1', $node);
 }
示例#4
0
 /**
  * @param string        $title
  * @param Question[]    $questions
  * @param User          $user
  *
  * @return Exercise
  */
 public function exercise($title, array $questions = [], User $user = null)
 {
     $exercise = new Exercise();
     if ($user) {
         if (!isset($this->exoType)) {
             $this->exoType = new ResourceType();
             $this->exoType->setName('exercise');
             $this->om->persist($this->exoType);
         }
         $node = new ResourceNode();
         $node->setName($title);
         $node->setCreator($user);
         $node->setResourceType($this->exoType);
         $node->setWorkspace($user->getPersonalWorkspace());
         $node->setClass('UJM\\ExoBundle\\Entity\\Exercise');
         $node->setGuid(time());
         $exercise->setResourceNode($node);
         $this->om->persist($node);
     }
     $this->om->persist($exercise);
     for ($i = 0, $max = count($questions); $i < $max; ++$i) {
         $step = new Step();
         $step->setText('step');
         $step->setOrder($i);
         // Add step to the exercise
         $exercise->addStep($step);
         $this->om->persist($step);
         $stepQuestion = new StepQuestion();
         $stepQuestion->setStep($step);
         $stepQuestion->setQuestion($questions[$i]);
         $stepQuestion->setOrdre(0);
         $this->om->persist($stepQuestion);
     }
     return $exercise;
 }
 protected function persistActivity($name)
 {
     if (!isset($this->defaults['user'])) {
         $this->defaults['user'] = $this->persistUser('default_user');
     }
     if (!isset($this->defaults['workspace'])) {
         $workspace = new Workspace();
         $workspace->setName('ws-jdoe');
         $workspace->setCreator($this->defaults['user']);
         $workspace->setCode('jdoe-123');
         $workspace->setGuid('123');
         $this->om->persist($workspace);
         $this->defaults['workspace'] = $workspace;
     }
     if (!isset($this->defaults['activity_type'])) {
         $type = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('activity');
         $this->defaults['activity_type'] = $type;
     }
     $node = new ResourceNode();
     $node->setName($name);
     $node->setCreator($this->defaults['user']);
     $node->setResourceType($this->defaults['activity_type']);
     $node->setWorkspace($this->defaults['workspace']);
     $node->setGuid($name);
     $node->setClass('foo');
     $activity = new Activity();
     $activity->setName($name);
     $activity->setDescription('desc');
     $activity->setResourceNode($node);
     $this->om->persist($node);
     $this->om->persist($activity);
     return $activity;
 }
示例#6
0
 /**
  * @param $title
  * @param User $creator
  *
  * @return Website
  */
 public function website($title, User $creator)
 {
     $website = new Website(true);
     $node = new ResourceNode();
     $node->setName($title);
     $node->setCreator($creator);
     $node->setResourceType($this->websiteType);
     $node->setWorkspace($creator->getPersonalWorkspace());
     $node->setClass('Icap\\WebsiteBundle\\Entity\\Website');
     $node->setGuid(time());
     $website->setResourceNode($node);
     $this->om->persist($website);
     $this->om->persist($node);
     return $website;
 }
示例#7
0
 /**
  * needed to create a functional simupoll resource.
  */
 public function simupoll($title, User $creator)
 {
     $simupoll = new Simupoll();
     $simupoll->setTitle($title);
     if (!$this->simupollType) {
         $this->simupollType = new ResourceType();
         $this->simupollType->setName('claroline_result');
         $this->om->persist($this->simupollType);
     }
     $node = new ResourceNode();
     $node->setName($title);
     $node->setCreator($creator);
     $node->setResourceType($this->simupollType);
     $node->setWorkspace($creator->getPersonalWorkspace());
     $node->setClass('CPASimUSante\\SimupollBundle\\Entity\\Simupoll');
     $node->setGuid(time());
     $simupoll->setResourceNode($node);
     $this->om->persist($simupoll);
     $this->om->persist($node);
     return $simupoll;
 }