public function cursus($name, Cursus $parent = null, Course $course = null, $order = 0, $blocking = false)
 {
     $cursus = new Cursus();
     $cursus->setTitle($name);
     $cursus->setCode($name);
     $cursus->setDescription($name);
     $cursus->setParent($parent);
     $cursus->setCourse($course);
     $cursus->setCursusOrder($order);
     $cursus->setBlocking($blocking);
     $this->om->persist($cursus);
     return $cursus;
 }
 /**
  * @EXT\Route(
  *     "cursus/{cursus}/dissociate/course",
  *     name="claro_cursus_dissociate_course",
  *     options={"expose"=true}
  * )
  * @EXT\Method("POST")
  * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
  */
 public function cursusCourseDissociateAction(Cursus $cursus)
 {
     $this->checkToolAccess();
     $cursus->setCourse(null);
     $this->cursusManager->persistCursus($cursus);
     return new JsonResponse('success', 200);
 }
Example #3
0
 private function importCursusChildren(array $parent, array $children, array $courses, array $codes, array &$createdCursus, &$index)
 {
     if (isset($parent['id']) && isset($children[$parent['id']])) {
         foreach ($children[$parent['id']] as $child) {
             $cursus = new Cursus();
             $cursus->setTitle($child['title']);
             $cursus->setDescription($child['description']);
             $cursus->setBlocking($child['blocking']);
             $cursus->setCursusOrder($child['cursus_order']);
             $cursus->setDetails($child['details']);
             if (isset($createdCursus[$parent['id']])) {
                 $cursus->setParent($createdCursus[$parent['id']]);
             }
             if (!empty($child['course']) && isset($courses[$child['course']])) {
                 $cursus->setCourse($courses[$child['course']]);
             }
             if (!empty($child['code'])) {
                 $code = $this->generateValidCode($child['code'], $codes);
                 $cursus->setCode($code);
             }
             $this->om->persist($cursus);
             $createdCursus[$child['id']] = $cursus;
             $index++;
             if ($index % 50 === 0) {
                 $this->om->forceFlush();
             }
             if (isset($children[$child['id']])) {
                 $this->importCursusChildren($child, $children, $courses, $codes, $createdCursus, $index);
             }
         }
     }
 }
Example #4
0
 private function importRootCursus(array $roots, array $children, array $courses)
 {
     $this->om->startFlushSuite();
     $codes = $this->getAllCursusCodes();
     $createdCursus = [];
     $rootCursus = [];
     $index = 0;
     foreach ($roots as $root) {
         $cursus = new Cursus();
         $cursus->setTitle($root['title']);
         $cursus->setDescription($root['description']);
         $cursus->setBlocking($root['blocking']);
         $cursus->setCursusOrder($root['cursus_order']);
         $cursus->setDetails($root['details']);
         if (!empty($root['course']) && isset($courses[$root['course']])) {
             $cursus->setCourse($courses[$root['course']]);
         }
         if (!empty($root['code'])) {
             $code = $this->generateValidCode($root['code'], $codes);
             $cursus->setCode($code);
         }
         $this->om->persist($cursus);
         $createdCursus[$root['id']] = $cursus;
         ++$index;
         if ($index % 50 === 0) {
             $this->om->forceFlush();
         }
         if (isset($children[$root['id']])) {
             $this->importCursusChildren($root, $children, $courses, $codes, $createdCursus, $index);
         }
         $rootCursus[] = $cursus;
     }
     $this->om->endFlushSuite();
     return $rootCursus;
 }