Example #1
0
 /**
  * Remove session Registration
  *
  * @param \IIA\ApiBundle\Entity\Session $session
  */
 public function removeSessionRegistration(\IIA\ApiBundle\Entity\Session $session)
 {
     $session->removeUserRegistration($this);
     $this->sessions->removeElement($session);
 }
Example #2
0
 public function load(ObjectManager $em)
 {
     for ($i = 1; $i < 3; $i++) {
         $cat = "android";
         $session = new Session();
         $session->setCategory($em->merge($this->getReference('category-' . $cat)));
         $session->setDuration(86000);
         $session->setIsRandom(true);
         $session->setName("QCM n" . $i . " " . $cat);
         $user = $this->getReference("userAdmin");
         $session->addUserRegistration($user);
         $group1 = $this->getReference("group-CDSM");
         $session->addGroupRegistration($group1);
         $group2 = $this->getReference("group-M2");
         $session->addGroupRegistration($group2);
         for ($j = 1; $j < 5; $j++) {
             $question = "question " . $cat . "_session" . $i . " n°" . $j;
             $qcm = new QCM();
             $qcm->setQuestion($question);
             $qcm->setSession($session);
             for ($k = 1; $k < 4; $k++) {
                 $answerTxt = "réponse " . $cat . "_session" . $i . "_question" . $j . " n°" . $k;
                 $answer = new Answer();
                 $answer->setContent($answerTxt);
                 $answer->setIsTrue(rand(0, 1));
                 $answer->setQcm($qcm);
                 $qcm->addAnswer($answer);
                 $em->persist($answer);
             }
             $em->persist($qcm);
         }
         $em->persist($session);
     }
     for ($i = 1; $i < 3; $i++) {
         $cat = "security";
         $session = new Session();
         $session->setCategory($em->merge($this->getReference('category-' . $cat)));
         $session->setDuration(86000);
         $session->setIsRandom(true);
         $session->setName("QCM n" . $i . " " . $cat);
         $user = $this->getReference("userAdmin");
         $session->addUserRegistration($user);
         $group1 = $this->getReference("group-CDSM");
         $session->addGroupRegistration($group1);
         $group2 = $this->getReference("group-M2");
         $session->addGroupRegistration($group2);
         $group3 = $this->getReference("group-BTS1");
         $session->addGroupRegistration($group3);
         $group4 = $this->getReference("group-BTS2");
         $session->addGroupRegistration($group4);
         for ($j = 1; $j < 5; $j++) {
             $question = "question " . $cat . "_session" . $i . " n°" . $j;
             $qcm = new QCM();
             $qcm->setQuestion($question);
             $qcm->setSession($session);
             for ($k = 1; $k < 4; $k++) {
                 $answerTxt = "réponse " . $cat . "_session" . $i . "_question" . $j . " n°" . $k;
                 $answer = new Answer();
                 $answer->setContent($answerTxt);
                 $answer->setIsTrue(rand(0, 1));
                 $answer->setQcm($qcm);
                 $qcm->addAnswer($answer);
                 $em->persist($answer);
             }
             $em->persist($qcm);
         }
         $em->persist($session);
     }
     for ($i = 1; $i < 3; $i++) {
         $cat = "ios";
         $session = new Session();
         $session->setCategory($em->merge($this->getReference('category-' . $cat)));
         $session->setDuration(86000);
         $session->setIsRandom(true);
         $session->setName("QCM n" . $i . " " . $cat);
         $user = $this->getReference("userAdmin");
         $session->addUserRegistration($user);
         $group1 = $this->getReference("group-CDSM");
         $session->addGroupRegistration($group1);
         $group2 = $this->getReference("group-M2");
         $session->addGroupRegistration($group2);
         for ($j = 1; $j < 5; $j++) {
             $question = "question " . $cat . "_session" . $i . " n°" . $j;
             $qcm = new QCM();
             $qcm->setQuestion($question);
             $qcm->setSession($session);
             for ($k = 1; $k < 4; $k++) {
                 $answerTxt = "réponse " . $cat . "_session" . $i . "_question" . $j . " n°" . $k;
                 $answer = new Answer();
                 $answer->setContent($answerTxt);
                 $answer->setIsTrue(rand(0, 1));
                 $answer->setQcm($qcm);
                 $qcm->addAnswer($answer);
                 $em->persist($answer);
             }
             $em->persist($qcm);
         }
         $em->persist($session);
     }
     for ($i = 1; $i < 3; $i++) {
         $cat = "windowsPhone";
         $session = new Session();
         $session->setCategory($em->merge($this->getReference('category-' . $cat)));
         $session->setDuration(86000);
         $session->setIsRandom(true);
         $session->setName("QCM n" . $i . " " . $cat);
         $user = $this->getReference("userAdmin");
         $session->addUserRegistration($user);
         $group1 = $this->getReference("group-CDSM");
         $session->addGroupRegistration($group1);
         $group2 = $this->getReference("group-M2");
         $session->addGroupRegistration($group2);
         for ($j = 1; $j < 5; $j++) {
             $question = "question " . $cat . "_session" . $i . " n°" . $j;
             $qcm = new QCM();
             $qcm->setQuestion($question);
             $qcm->setSession($session);
             for ($k = 1; $k < 4; $k++) {
                 $answerTxt = "réponse " . $cat . "_session" . $i . "_question" . $j . " n°" . $k;
                 $answer = new Answer();
                 $answer->setContent($answerTxt);
                 $answer->setIsTrue(rand(0, 1));
                 $answer->setQcm($qcm);
                 $qcm->addAnswer($answer);
                 $em->persist($answer);
             }
             $em->persist($qcm);
         }
         $em->persist($session);
     }
     $em->flush();
 }