/** * Create wordResponse. */ private function createWordResponse() { $rp = $this->assessmentItem->getElementsByTagName('responseDeclaration')->item(0); $mapping = $rp->getElementsByTagName('mapping')->item(0); foreach ($mapping->getElementsByTagName('mapEntry') as $me) { $keyWord = new WordResponse(); $feedback = $me->getElementsByTagName('feedbackInline'); if ($feedback->item(0)) { $feedbackVal = $this->domElementToString($feedback->item(0)); $feedbackVal = html_entity_decode($feedbackVal); $keyWord->setFeedback($feedbackVal); $me->removeChild($feedback->item(0)); } $keyWord->setResponse($me->getAttribute('mapKey')); $keyWord->setScore($me->getAttribute('mappedValue')); $keyWord->setInteractionOpen($this->interactionOpen); if ($me->getAttribute('caseSensitive') == true) { $keyWord->setCaseSensitive(true); } else { $keyWord->setCaseSensitive(false); } $this->om->persist($keyWord); } $this->om->flush(); }
/** * Create wordResponse * * @access private * */ private function createWordResponse() { $rp = $this->assessmentItem->getElementsByTagName("responseDeclaration")->item(0); $mapping = $rp->getElementsByTagName("mapping")->item(0); foreach ($mapping->getElementsByTagName("mapEntry") as $me) { $keyWord = new WordResponse(); $keyWord->setResponse($me->getAttribute('mapKey')); $keyWord->setScore($me->getAttribute('mappedValue')); $keyWord->setInteractionOpen($this->interactionOpen); if ($me->getAttribute('caseSensitive') == true) { $keyWord->setCaseSensitive(true); } else { $keyWord->setCaseSensitive(false); } $this->om->persist($keyWord); } $this->om->flush(); }
public function addWordResponse(\UJM\ExoBundle\Entity\WordResponse $wordResponse) { $this->wordResponses[] = $wordResponse; $wordResponse->setHole($this); }
/** * Get score for a question with key word. * * * @param \UJM\ExoBundle\Entity\WordResponse $wr * @param string $response * * @return float */ protected function getScoreWordResponse($wr, $response) { $score = 0; $formattedResponse = trim($response); $formattedWord = trim($wr->getResponse()); if (!$wr->getCaseSensitive()) { $formattedResponse = strtolower($formattedResponse); $formattedWord = strtolower($formattedWord); } if ($formattedResponse === $formattedWord) { $score = $wr->getScore(); } return $score; }
/** * Get score for a question with key word * * @access private * * @param \UJM\ExoBundle\Entity\WordResponse $wr * @param String $response * * @return float */ private function getScoreWordResponse($wr, $response) { $score = 0; if (strcasecmp(trim($wr->getResponse()), trim($response)) == 0 && $wr->getCaseSensitive() == false || trim($wr->getResponse()) == trim($response)) { $score = $wr->getScore(); } return $score; }
/** * Create wordResponseForList * * @access protected * * @param String $qtiId id of hole in the qti file * @param DOMNodelist::item $ib element itemBody * @param DOMNodelist::item $mapping element mapping * @param UJM\ExoBundle\Entity\Hole $hole * */ protected function wordResponseForList($qtiId, $ib, $mapping, $hole) { foreach ($ib->getElementsByTagName("inlineChoiceInteraction") as $ici) { if ($ici->getAttribute('responseIdentifier') == $qtiId) { foreach ($ici->getElementsByTagName('inlineChoice') as $ic) { $keyWord = new WordResponse(); $score = 0; $matchScore = false; $keyWord->setResponse($ic->nodeValue); foreach ($mapping->getElementsByTagName("mapEntry") as $mapEntry) { if ($mapEntry->getAttribute('mapKey') == $ic->getAttribute('identifier')) { $score = $mapEntry->getAttribute('mappedValue'); $matchScore = true; } if ($mapEntry->getAttribute('caseSensitive') == true) { $keyWord->setCaseSensitive(true); } else { $keyWord->setCaseSensitive(false); } } if ($matchScore === false) { foreach ($mapping->getElementsByTagName("mapEntry") as $mapEntry) { if ($mapEntry->getAttribute('mapKey') == $ic->nodeValue) { $score = $mapEntry->getAttribute('mappedValue'); } } } $keyWord->setScore($score); $keyWord->setHole($hole); $this->om->persist($keyWord); $this->tabWrOpt[] = $keyWord; } } } }