Ejemplo n.º 1
0
 /**
  * Create the Coords.
  */
 protected function createCoords()
 {
     $am = $this->assessmentItem->getElementsByTagName('areaMapping')->item(0);
     foreach ($am->getElementsByTagName('areaMapEntry') as $areaMapEntry) {
         $tabCoords = explode(',', $areaMapEntry->getAttribute('coords'));
         $coords = new Coords();
         $feedback = $areaMapEntry->getElementsByTagName('feedbackInline');
         if ($feedback->item(0)) {
             $feedbackVal = $this->domElementToString($feedback->item(0));
             $feedbackVal = html_entity_decode($feedbackVal);
             $coords->setFeedback($feedbackVal);
             $areaMapEntry->removeChild($feedback->item(0));
         }
         $x = $tabCoords[0] - $tabCoords[2];
         $y = $tabCoords[1] - $tabCoords[2];
         $coords->setValue($x . ',' . $y);
         $coords->setSize($tabCoords[2] * 2);
         $coords->setShape($areaMapEntry->getAttribute('shape'));
         $coords->setScoreCoords($areaMapEntry->getAttribute('mappedValue'));
         $color = $areaMapEntry->getAttribute('color');
         if ($color === '') {
             $coords->setColor('black');
         } else {
             $coords->setColor($color);
         }
         $coords->setInteractionGraphic($this->interactionGraph);
         $this->om->persist($coords);
     }
     $this->om->flush();
 }
Ejemplo n.º 2
0
 /**
  * Create the Coords
  *
  * @access protected
  *
  */
 protected function createCoords()
 {
     $am = $this->assessmentItem->getElementsByTagName("areaMapping")->item(0);
     foreach ($am->getElementsByTagName("areaMapEntry") as $areaMapEntry) {
         $tabCoords = explode(',', $areaMapEntry->getAttribute('coords'));
         $coords = new Coords();
         $x = $tabCoords[0] - $tabCoords[2];
         $y = $tabCoords[1] - $tabCoords[2];
         $coords->setValue($x . ',' . $y);
         $coords->setSize($tabCoords[2] * 2);
         $coords->setShape($areaMapEntry->getAttribute('shape'));
         $coords->setScoreCoords($areaMapEntry->getAttribute('mappedValue'));
         $coords->setColor('white');
         $coords->setInteractionGraphic($this->interactionGraph);
         $this->om->persist($coords);
     }
     $this->om->flush();
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function persistInteractionDetails(Question $question, \stdClass $importData)
 {
     $interaction = new InteractionGraphic();
     for ($i = 0, $max = count($importData->coords); $i < $max; ++$i) {
         $coord = new Coords();
         foreach ($importData->solutions as $solution) {
             if ($solution->id === $importData->choices[$i]->id) {
                 $coord->setValue($solution->value);
                 $coord->setShape($solution->shape);
                 $coord->setScoreCoords($solution->score);
                 $coord->setSize($solution->size);
                 if (isset($solution->feedback)) {
                     $coord->setFeedback($solution->feedback);
                 }
                 // should be required ?
                 if (isset($solution->color)) {
                     $coord->setColor($solution->color);
                 } else {
                     $coord->setColor('white');
                 }
             }
         }
         $coord->setInteractionGraphic($interaction);
         $interaction->addCoord($coord);
         $this->om->persist($coord);
     }
     // should we upload the picture ??
     $picture = new Picture();
     $picture->setLabel($importData->document->label ? $importData->document->label : '');
     $picture->setUrl($importData->document->url);
     $picture->setWidth($importData->width);
     $picture->setHeight($importData->height);
     $ext = pathinfo($importData->document->url)['extension'];
     $picture->setType($ext);
     $this->om->persist($picture);
     $interaction->setPicture($picture);
     $interaction->setQuestion($question);
     $this->om->persist($interaction);
 }