Exemplo n.º 1
0
 private function recursiveObjectives($objectives, $parent, $structure)
 {
     foreach ($objectives as $obj) {
         $data = $obj;
         //$data['parent'] = $parent;
         $objective = $this->currRepo->objectiveOfCode($data['code']);
         //if not already exists in database
         if (!$objective) {
             $objective = Objective::register(new Name($data['name']), $data['code'], $structure);
             if ($parent) {
                 $parent->addChild($objective);
                 $objective->setParent($parent);
             }
             $this->manager->persist($objective);
             $structure->addObjective($objective);
             if (isset($data['level'])) {
                 $o_levels = str_split($data['level']);
                 //find group
                 $i = 0;
                 foreach ($this->cur_classlevels as $grouplevel) {
                     $group = $this->groupRepo->groupOfName($grouplevel);
                     $obj_level = ObjectiveControlLevel::register($group, $objective, $o_levels[$i++]);
                     $this->manager->merge($obj_level);
                 }
             }
         }
         if (isset($data['obj'])) {
             $this->recursiveObjectives($data['obj'], $objective, $structure);
         }
     }
     //$this->manager->persist($structure);
     if ($parent) {
         $this->manager->persist($parent);
     }
 }
Exemplo n.º 2
0
 public function createWebsites()
 {
     $websites = [['n' => 'Rekenmeeseter', 'u' => 'www.rekenmeester.be', 'o' => ['WIS G1', 'WIS G1.a'], 't' => ['optellen', 'aftrekken']], ['n' => 'Google', 'u' => 'www.google.be', 'o' => ['WIS G7', 'WIS G9', 'WIS G9.e'], 't' => ['optellen', 'Sinterklaas']]];
     foreach ($websites as $awebsite) {
         $website = Website::register(new Name($awebsite['n']), new URL($awebsite['u']));
         foreach ($awebsite['t'] as $atag) {
             $tag = $this->tagRepo->tagOfName(new TagName($atag));
             $website->addTag($tag);
         }
         foreach ($awebsite['o'] as $aobjective) {
             $objective = $this->currRepo->objectiveOfCode($aobjective);
             $website->addObjective($objective);
         }
         $this->manager->persist($website);
         $this->websiteRepo->add($website);
     }
 }
 /**
  * @test
  * @group currrepo
  */
 public function should_return_objective_of_id()
 {
     $code = 'D0.1.a';
     $tmp = $this->currRepo->objectiveOfCode($code);
     $id = $tmp->getId();
     $this->em->clear();
     $objective = $this->currRepo->objectiveOfId($id);
     $this->assertInstanceOf('Bakgat\\Notos\\Domain\\Model\\Curricula\\Objective', $objective);
     $this->assertEquals($code, $objective->code());
     $this->assertTrue($tmp->name()->equals($objective->name()));
 }