/** * 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); }
/** * 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); }
/** * To delete keywords during the update of interactionHole * * @access private * * @param \UJM\ExoBundle\Entity\Hole $hole * @param Collection of \UJM\ExoBundle\Entity\Hole $originalHoles * */ private function delKeyWord($hole, $originalHoles) { $wordResponses = $hole->getWordResponses()->toArray(); foreach ($originalHoles as $holeOrig) { $originalWords = $holeOrig->getwordResponses()->getSnapshot(); if ($hole->getId() === $holeOrig->getId()) { foreach ($wordResponses as $word) { foreach ($originalWords as $key => $toDel) { if ($toDel->getId() === $word->getId()) { unset($originalWords[$key]); } } } // remove the relationship between the hole and the interactionhole foreach ($originalWords as $word) { // remove the wr from the wordResponse $hole->getWordResponses()->removeElement($word); // if you wanted to delete the Hole entirely, you can also do that $this->em->remove($word); } } } }
/** * @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; }