public function load(ObjectManager $manager) { $typeQCM = $manager->getRepository('UJMExoBundle:TypeQCM')->findOneById(2); //QCU $interactionqcm = new InteractionQCM(); $interactionqcm->setTypeQCM($typeQCM); $interactionqcm->setInteraction($this->getReference('interaction1')); $manager->persist($interactionqcm); $manager->flush(); $this->addReference('interactionqcm1', $interactionqcm); $interactionqcm = new InteractionQCM(); $interactionqcm->setTypeQCM($typeQCM); $interactionqcm->setInteraction($this->getReference('interaction2')); $manager->persist($interactionqcm); $manager->flush(); $this->addReference('interactionqcm2', $interactionqcm); }
/** * @param string $title * @param Choice[] $choices * @param string $description * * @return Question */ public function qcmQuestion($title, array $choices = [], $description = '') { $question = new Question(); $question->setTitle($title); $question->setInvite('Invite...'); $question->setDescription($description); if (!$this->multipleChoiceType) { $this->multipleChoiceType = $this->om->getRepository('UJMExoBundle:TypeQCM')->findOneByValue('Multiple response'); } $interactionQcm = new InteractionQCM(); $interactionQcm->setQuestion($question); $interactionQcm->setTypeQCM($this->multipleChoiceType); $interactionQcm->setWeightResponse(true); for ($i = 0, $max = count($choices); $i < $max; ++$i) { $choices[$i]->setOrdre($i); $interactionQcm->addChoice($choices[$i]); } $this->om->persist($interactionQcm); $this->om->persist($question); return $question; }