Exemplo n.º 1
0
 /**
  * @param string $text
  * @param float  $order
  * @param float  $score
  *
  * @return Choice
  */
 public function qcmChoice($text, $order, $score)
 {
     $choice = new Choice();
     $choice->setLabel($text);
     $choice->setOrdre($order);
     $choice->setWeight($score);
     $this->om->persist($choice);
     return $choice;
 }
Exemplo n.º 2
0
 public function load(ObjectManager $manager)
 {
     $arr_data = array(array('LabelFIX ChoiceA', 1, 1, true), array('LabelFIX ChoiceB', 2, 0.75, false));
     foreach ($arr_data as $data) {
         $choice = new Choice();
         $choice->setLabel($data[0]);
         $choice->setOrdre($data[1]);
         $choice->setWeight($data[2]);
         $choice->setRightResponse($data[3]);
         $choice->setInteractionQCM($this->getReference('interactionqcm1'));
         $manager->persist($choice);
         $manager->flush();
     }
     foreach ($arr_data as $data) {
         $choice = new Choice();
         $choice->setLabel($data[0]);
         $choice->setOrdre($data[1]);
         $choice->setWeight($data[2]);
         $choice->setRightResponse($data[3]);
         $choice->setInteractionQCM($this->getReference('interactionqcm2'));
         $manager->persist($choice);
         $manager->flush();
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function persistInteractionDetails(Question $question, \stdClass $importData)
 {
     $interaction = new InteractionQCM();
     if ($importData->score->type === 'sum') {
         $interaction->setWeightResponse(true);
         //weighted true
     } elseif ($importData->score->type === 'fixed') {
         $interaction->setWeightResponse(false);
         //no weighted false
         $interaction->setScoreRightResponse($importData->score->success);
         $interaction->setScoreFalseResponse($importData->score->failure);
     }
     for ($i = 0, $max = count($importData->choices); $i < $max; ++$i) {
         // temporary limitation
         if ($importData->choices[$i]->type !== 'text/html') {
             throw new \Exception("Import not implemented for MIME type {$importData->choices[$i]->type}");
         }
         $choice = new Choice();
         $choice->setLabel($importData->choices[$i]->data);
         $choice->setOrdre($i);
         foreach ($importData->solutions as $solution) {
             if ($solution->id === $importData->choices[$i]->id) {
                 $choice->setWeight($solution->score);
                 if (0 < $solution->score) {
                     $choice->setRightResponse(true);
                 }
                 if (isset($solution->feedback)) {
                     $choice->setFeedback($solution->feedback);
                 }
             }
         }
         $choice->setInteractionQCM($interaction);
         $interaction->addChoice($choice);
         $this->om->persist($choice);
     }
     $subTypeCode = $importData->multiple ? 1 : 2;
     $subType = $this->om->getRepository('UJMExoBundle:TypeQCM')->findOneByCode($subTypeCode);
     $interaction->setTypeQCM($subType);
     $interaction->setShuffle($importData->random);
     $interaction->setQuestion($question);
     $this->om->persist($interaction);
 }
Exemplo n.º 4
0
 /**
  * Create choices
  *
  * @access protected
  *
  */
 protected function createChoices()
 {
     $order = 1;
     $ib = $this->assessmentItem->getElementsByTagName("itemBody")->item(0);
     $ci = $ib->getElementsByTagName("choiceInteraction")->item(0);
     foreach ($ci->getElementsByTagName("simpleChoice") as $simpleChoice) {
         $choice = new Choice();
         if ($simpleChoice->hasAttribute("fixed") && $simpleChoice->getAttribute("fixed") == 'true') {
             $choice->setPositionForce(true);
         }
         $feedback = $simpleChoice->getElementsByTagName("feedbackInline");
         if ($feedback->item(0)) {
             $choice->setFeedback($feedback->item(0)->nodeValue);
             $simpleChoice->removeChild($feedback->item(0));
         }
         $choice->setLabel($this->choiceValue($simpleChoice));
         $choice->setOrdre($order);
         $choice->setWeight($this->getWeightChoice($simpleChoice->getAttribute("identifier")));
         $choice->setRightResponse($this->getRightResponse($simpleChoice->getAttribute("identifier")));
         $choice->setInteractionQCM($this->interactionQCM);
         $this->om->persist($choice);
         $order++;
     }
     $this->om->flush();
 }
Exemplo n.º 5
0
 /**
  * add the tag simpleChoice in choiceInteraction.
  *
  *
  * @param \UJM\ExoBundle\Entity\Choice $choice
  * @param int                          $choiceNumber
  */
 private function simpleChoiceTag($choice, $choiceNumber)
 {
     $simpleChoice = $this->document->CreateElement('simpleChoice');
     $simpleChoice->setAttribute('identifier', 'Choice' . $choiceNumber);
     $this->choiceInteraction->appendChild($simpleChoice);
     if ($choice->getPositionForce() == 1) {
         $positionForced = 'true';
     } else {
         $positionForced = 'false';
     }
     $simpleChoice->setAttribute('fixed', $positionForced);
     $this->getDomEl($simpleChoice, $choice->getLabel());
     //comment per line for each choice
     if ($choice->getFeedback() != null && $choice->getFeedback() != '') {
         $feedbackInline = $this->document->CreateElement('feedbackInline');
         $feedbackInline->setAttribute('outcomeIdentifier', 'FEEDBACK');
         $feedbackInline->setAttribute('identifier', 'Choice' . $choiceNumber);
         $feedbackInline->setAttribute('showHide', 'show');
         $this->getDomEl($feedbackInline, $choice->getFeedback());
         $simpleChoice->appendChild($feedbackInline);
     }
 }
Exemplo n.º 6
0
 /**
  * Create choices.
  */
 protected function createChoices()
 {
     $order = 1;
     $ib = $this->assessmentItem->getElementsByTagName('itemBody')->item(0);
     $ci = $ib->getElementsByTagName('choiceInteraction')->item(0);
     foreach ($ci->getElementsByTagName('simpleChoice') as $simpleChoice) {
         $choice = new Choice();
         if ($simpleChoice->hasAttribute('fixed') && $simpleChoice->getAttribute('fixed') === 'true') {
             $choice->setPositionForce(true);
         }
         $feedback = $simpleChoice->getElementsByTagName('feedbackInline');
         if ($feedback->item(0)) {
             $feedbackVal = $this->domElementToString($feedback->item(0));
             $feedbackVal = html_entity_decode($feedbackVal);
             $choice->setFeedback($feedbackVal);
             $simpleChoice->removeChild($feedback->item(0));
         }
         $choice->setLabel($this->choiceValue($simpleChoice));
         $choice->setOrdre($order);
         $choice->setWeight($this->getWeightChoice($simpleChoice->getAttribute('identifier')));
         $choice->setRightResponse($this->getRightResponse($simpleChoice->getAttribute('identifier')));
         $choice->setInteractionQCM($this->interactionQCM);
         $this->om->persist($choice);
         ++$order;
     }
     $this->om->flush();
 }
Exemplo n.º 7
0
 /**
  * add the tag simpleChoice in choiceInteraction
  *
  * @access private
  *
  * @param \UJM\ExoBundle\Entity\Choice $choice
  * @param Integer $choiceNumber
  *
  */
 private function simpleChoiceTag($choice, $choiceNumber)
 {
     $simpleChoice = $this->document->CreateElement('simpleChoice');
     $simpleChoice->setAttribute("identifier", "Choice" . $choiceNumber);
     $this->choiceInteraction->appendChild($simpleChoice);
     $simpleChoicetxt = $this->document->CreateTextNode($choice->getLabel());
     if ($choice->getPositionForce() == 1) {
         $positionForced = 'true';
     } else {
         $positionForced = 'false';
     }
     $simpleChoice->setAttribute("fixed", $positionForced);
     $simpleChoice->appendChild($simpleChoicetxt);
     //comment per line for each choice
     if ($choice->getFeedback() != Null && $choice->getFeedback() != "") {
         $feedbackInline = $this->document->CreateElement('feedbackInline');
         $feedbackInline->setAttribute("outcomeIdentifier", "FEEDBACK");
         $feedbackInline->setAttribute("identifier", "Choice" . $choiceNumber);
         $feedbackInline->setAttribute("showHide", "show");
         $feedbackInlinetxt = $this->document->CreateTextNode($choice->getFeedback());
         $feedbackInline->appendChild($feedbackInlinetxt);
         $simpleChoice->appendChild($feedbackInline);
     }
 }
Exemplo n.º 8
0
 public function addChoice(\UJM\ExoBundle\Entity\Choice $choice)
 {
     $this->choices[] = $choice;
     //le choix est bien lié à l'entité interactionqcm, mais dans l'entité choice il faut
     //aussi lié l'interactionqcm double travail avec les relations bidirectionnelles avec
     //lesquelles il faut bien faire attention à garder les données cohérentes dans un autre
     //script il faudra exécuter $interactionqcm->addChoice() qui garde la cohérence entre les
     //deux entités, il ne faudra pas exécuter $choice->setInteractionQCM(), car lui ne garde
     //pas la cohérence
     $choice->setInteractionQCM($this);
 }