Exemplo 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();
 }
Exemplo 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();
 }
Exemplo n.º 3
0
 /**
  * Export question areas.
  *
  * @param Coords $coords
  *
  * @return \stdClass
  */
 private function exportArea(Coords $coords)
 {
     $exportData = new \stdClass();
     $exportData->id = $coords->getId();
     $exportData->color = $coords->getColor();
     $position = explode(',', $coords->getValue());
     switch ($coords->getShape()) {
         case 'circle':
             $exportData->shape = 'circle';
             $exportData->radius = $coords->getSize() / 2;
             // We store the top left corner, so we need to calculate the real center
             $center = $this->exportCoords($position);
             $center->x += $exportData->radius;
             $center->y += $exportData->radius;
             $exportData->center = $center;
             break;
         case 'square':
             $exportData->shape = 'rect';
             $exportData->coords = [$this->exportCoords($position), $this->exportCoords([$position[0] + $coords->getSize(), $position[1] + $coords->getSize()])];
             break;
     }
     return $exportData;
 }
Exemplo n.º 4
0
 public function addCoord(\UJM\ExoBundle\Entity\Coords $coord)
 {
     $this->coords[] = $coord;
     //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
     $coord->setInteractionGraphic($this);
 }