예제 #1
0
 public function matchQuestion($title, $labels = [], $proposals = [])
 {
     $question = new Question();
     $question->setTitle($title);
     $question->setInvite('Invite...');
     if (!$this->matchType) {
         $this->matchType = $this->om->getRepository('UJMExoBundle:TypeMatching')->findOneByCode(1);
     }
     $interactionMatching = new InteractionMatching();
     $interactionMatching->setQuestion($question);
     $interactionMatching->setShuffle(false);
     $interactionMatching->setTypeMatching($this->matchType);
     for ($i = 0, $max = count($labels); $i < $max; ++$i) {
         $labels[$i]->setOrdre($i);
         $interactionMatching->addLabel($labels[$i]);
     }
     for ($i = 0, $max = count($proposals); $i < $max; ++$i) {
         $proposals[$i]->setOrdre($i + 1);
         $interactionMatching->addProposal($proposals[$i]);
     }
     $this->om->persist($interactionMatching);
     $this->om->persist($question);
     return $question;
 }