/** * Replace the object tag by a link to the Claroline resource * * @access private * * @param DOMNodelist::item $ob element object * @param Claroline\CoreBundle\Entity\Resource $resourceNode * */ private function replaceNode($ob, $resourceNode) { $mimeType = $ob->getAttribute('type'); if (strpos($mimeType, 'image/') !== false) { $url = $this->container->get('router')->generate('claro_file_get_media', array('node' => $resourceNode->getId())); $imgTag = $this->assessmentItem->ownerDocument->createElement('img'); $styleAttr = $this->assessmentItem->ownerDocument->createAttribute('style'); $srcAttr = $this->assessmentItem->ownerDocument->createAttribute('src'); $altAttr = $this->assessmentItem->ownerDocument->createAttribute('alt'); $styleAttr->value = 'max-width: 100%;'; $srcAttr->value = $url; $altAttr->value = $resourceNode->getName(); $imgTag->appendChild($styleAttr); $imgTag->appendChild($srcAttr); $imgTag->appendChild($altAttr); $ob->parentNode->replaceChild($imgTag, $ob); } else { $url = $this->container->get('router')->generate('claro_resource_open', array('resourceType' => $resourceNode->getResourceType()->getName(), 'node' => $resourceNode->getId())); $aTag = $this->assessmentItem->ownerDocument->createElement('a', $resourceNode->getName()); $hrefAttr = $this->assessmentItem->ownerDocument->createAttribute('href'); $hrefAttr->value = $url; $aTag->appendChild($hrefAttr); $ob->parentNode->replaceChild($aTag, $ob); } }
/** * 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; } } } }