/**
  * add the tag mapping in responseDeclaration.
  *
  *
  * @param \UJM\ExoBundle\Entity\Hole $hole
  */
 private function mappingTag($hole)
 {
     $responseDeclaration = $this->responseDeclaration[$this->nbResponseDeclaration - 1];
     $correctResponse = $this->correctResponse[$this->nbResponseDeclaration - 1];
     $correctWordResponse = '';
     $mapping = $this->document->createElement('mapping');
     $mapping->setAttribute('defaultValue', '0');
     foreach ($hole->getWordResponses() as $resp) {
         $i = 0;
         if ($correctWordResponse == '') {
             $correctWordResponse = $resp;
         } else {
             if ($correctWordResponse->getScore() < $resp->getScore()) {
                 $correctWordResponse = $resp;
             }
         }
         $mapEntry = $this->document->createElement('mapEntry');
         if (!$hole->getSelector()) {
             $mapEntry->setAttribute('mapKey', $resp->getResponse());
         } else {
             $mapEntry->setAttribute('mapKey', 'choice_' . $resp->getId());
         }
         $mapEntry->setAttribute('mappedValue', $resp->getScore());
         $mapEntry->setAttribute('caseSensitive', $resp->getCaseSensitive());
         $mapping->appendChild($mapEntry);
         if ($resp->getFeedback() != null && $resp->getFeedback() != '') {
             $feedbackInline = $this->document->CreateElement('feedbackInline');
             $feedbackInline->setAttribute('outcomeIdentifier', 'FEEDBACK');
             $feedbackInline->setAttribute('identifier', 'choice_' . $resp->getId());
             $feedbackInline->setAttribute('showHide', 'show');
             $this->getDomEl($feedbackInline, $resp->getFeedback());
             $mapEntry->appendChild($feedbackInline);
         }
         ++$i;
     }
     $Tagvalue = $this->document->CreateElement('value');
     if (!$hole->getSelector()) {
         $responsevalue = $this->document->CreateTextNode($correctWordResponse->getResponse());
     } else {
         $responsevalue = $this->document->CreateTextNode('choice_' . $correctWordResponse->getId());
     }
     $Tagvalue->appendChild($responsevalue);
     $correctResponse->appendChild($Tagvalue);
     $responseDeclaration->appendChild($correctResponse);
     $responseDeclaration->appendChild($mapping);
 }
Exemple #2
0
 /**
  * add the tag mapping in responseDeclaration
  *
  * @access private
  *
  * @param \UJM\ExoBundle\Entity\Hole $hole
  *
  */
 private function mappingTag($hole)
 {
     $responseDeclaration = $this->responseDeclaration[$this->nbResponseDeclaration - 1];
     $correctResponse = $this->correctResponse[$this->nbResponseDeclaration - 1];
     $correctWordResponse = '';
     $mapping = $this->document->createElement("mapping");
     $mapping->setAttribute("defaultValue", "0");
     foreach ($hole->getWordResponses() as $resp) {
         $i = 0;
         if ($correctWordResponse == '') {
             $correctWordResponse = $resp;
         } else {
             if ($correctWordResponse->getScore() < $resp->getScore()) {
                 $correctWordResponse = $resp;
             }
         }
         $mapEntry = $this->document->createElement("mapEntry");
         if (!$hole->getSelector()) {
             $mapEntry->setAttribute("mapKey", $resp->getResponse());
         } else {
             $mapEntry->setAttribute("mapKey", 'choice_' . $resp->getId());
         }
         $mapEntry->setAttribute("mappedValue", $resp->getScore());
         $mapEntry->setAttribute("caseSensitive", $resp->getCaseSensitive());
         $mapping->appendChild($mapEntry);
         $i++;
     }
     $Tagvalue = $this->document->CreateElement("value");
     if (!$hole->getSelector()) {
         $responsevalue = $this->document->CreateTextNode($correctWordResponse->getResponse());
     } else {
         $responsevalue = $this->document->CreateTextNode('choice_' . $correctWordResponse->getId());
     }
     $Tagvalue->appendChild($responsevalue);
     $correctResponse->appendChild($Tagvalue);
     $responseDeclaration->appendChild($correctResponse);
     $responseDeclaration->appendChild($mapping);
 }
Exemple #3
0
 /**
  * Create wordResponse
  *
  * @access protected
  *
  * @param String $qtiId id of hole in the qti file
  * @param UJM\ExoBundle\Entity\Hole $hole
  *
  */
 protected function createWordResponse($qtiId, $hole)
 {
     foreach ($this->assessmentItem->getElementsByTagName("responseDeclaration") as $rp) {
         if ($rp->getAttribute("identifier") == $qtiId) {
             $mapping = $rp->getElementsByTagName("mapping")->item(0);
             if ($hole->getSelector() === false) {
                 $this->wordResponseForSimpleHole($mapping, $hole);
             } else {
                 $ib = $this->assessmentItem->getElementsByTagName("itemBody")->item(0);
                 if ($mapping != null) {
                     $this->wordResponseForList($qtiId, $ib, $mapping, $hole);
                 }
             }
         }
     }
 }
Exemple #4
0
 /**
  * @param \UJM\ExoBundle\Entity\Hole $hole
  * @param string                     $response
  *
  * @return float
  */
 private function getScoreHole($hole, $response)
 {
     $em = $this->doctrine->getManager();
     $mark = 0;
     if ($hole->getSelector() == true) {
         $wr = $em->getRepository('UJMExoBundle:WordResponse')->find($response);
         $mark = $wr->getScore();
     } else {
         foreach ($hole->getWordResponses() as $wr) {
             $mark += $this->getScoreWordResponse($wr, $response);
         }
     }
     return $mark;
 }
 /**
  * Create wordResponse.
  *
  *
  * @param string                    $qtiId id of hole in the qti file
  * @param UJM\ExoBundle\Entity\Hole $hole
  */
 protected function createWordResponse($qtiId, $hole)
 {
     foreach ($this->assessmentItem->getElementsByTagName('responseDeclaration') as $rp) {
         if ($rp->getAttribute('identifier') === (string) $qtiId) {
             $mapping = $rp->getElementsByTagName('mapping')->item(0);
             if ($hole->getSelector() === false) {
                 $this->wordResponseForSimpleHole($mapping, $hole);
             } else {
                 $ib = $this->assessmentItem->getElementsByTagName('itemBody')->item(0);
                 $this->wordResponseForList($qtiId, $ib, $mapping, $hole);
             }
         }
     }
 }