本文整理汇总了PHP中Question::initFromXmlNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::initFromXmlNode方法的具体用法?PHP Question::initFromXmlNode怎么用?PHP Question::initFromXmlNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::initFromXmlNode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
if ($node->hasAttribute('userAnswer')) {
$this->userAnswer = trim($node->getAttribute('userAnswer'));
}
}
示例2: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$premisesNode = $node->getElementsByTagName('premises')->item(0);
$premisesList = $premisesNode->getElementsByTagName('premise');
for ($i = 0; $i < $premisesList->length; ++$i) {
$this->premises[] = trim($premisesList->item($i)->textContent);
}
$responsesNode = $node->getElementsByTagName('responses')->item(0);
$responsesList = $responsesNode->getElementsByTagName('response');
for ($i = 0; $i < $responsesList->length; ++$i) {
$this->responses[] = trim($responsesList->item($i)->textContent);
}
$userAnswerMatches = array();
if ($node->getElementsByTagName('userAnswer')->length != 0) {
$userAnswerNode = $node->getElementsByTagName('userAnswer')->item(0);
$userAnswerMatches = $this->exportMatchesCollection($userAnswerNode);
}
if (empty($userAnswerMatches)) {
return;
}
$userAnswers = array();
foreach ($userAnswerMatches as $answer) {
$userAnswers[$answer->premiseIndex] = $answer;
}
ksort($userAnswers);
foreach ($userAnswers as $i => $answer) {
$premiseIndex = $i;
$responseIndex = $answer->responseIndex;
if ($this->userAnswer != '') {
$this->userAnswer .= '; ';
}
$this->userAnswer .= $this->premises[$premiseIndex] . ' - ' . $this->responses[$responseIndex];
}
}
示例3: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$statementsNode = $node->getElementsByTagName('statements')->item(0);
$statementsCollection = TextCollection::fromXmlNode($statementsNode, 'statement');
$statements = $statementsCollection->toArray();
$labelsNode = $node->getElementsByTagName('scaleLabels')->item(0);
$labelsCollection = TextCollection::fromXmlNode($labelsNode, 'label');
$labels = $labelsCollection->toArray();
$userAnswers = array();
if ($node->getElementsByTagName('userAnswer')->length != 0) {
$userAnswerNode = $node->getElementsByTagName('userAnswer')->item(0);
$userAnswers = $this->exportUserAnswer($userAnswerNode);
}
$index = 0;
foreach ($statements as $statement) {
$label = '';
$userAnswer = $this->getUserAnswerByStatementIndex($userAnswers, $index);
if ($userAnswer) {
$label = $labels[$userAnswer->labelIndex];
}
if ($this->userAnswer != '') {
$this->userAnswer .= '; ';
}
$this->userAnswer .= $statement . ' - ' . $label;
++$index;
}
}
示例4: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$answersNode = $node->getElementsByTagName('answers')->item(0);
$answersList = $answersNode->getElementsByTagName('answer');
for ($i = 0; $i < $answersList->length; ++$i) {
$answerNode = $answersList->item($i);
$answer = $this->createAnswer();
$answer->initFromXmlNode($answerNode);
$this->answers[] = $answer;
}
foreach ($this->answers as $answer) {
/** @var MultipleResponseSurveyAnswer $answer */
if (!$answer->selected) {
continue;
}
if ($this->userAnswer != '') {
$this->userAnswer .= '; ';
}
$this->userAnswer .= $answer->text;
if (!empty($answer->customAnswer)) {
$this->userAnswer .= " " . $answer->customAnswer;
}
}
}
示例5: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$userAnswerNodeList = $node->getElementsByTagName('userAnswer');
if ($userAnswerNodeList->length > 0) {
$userAnswer = trim($userAnswerNodeList->item(0)->textContent);
$this->userAnswer = str_replace("\n", PHP_EOL, $userAnswer);
}
}
示例6: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$answersNode = $node->getElementsByTagName('answers')->item(0);
$this->answers = $this->createAnswers();
$this->answers->initFromXmlNode($answersNode);
$answer = $this->answers->answers[$this->answers->userAnswerIndex];
/** @var MultipleChoiceSurveyAnswer $answer */
$this->userAnswer = $answer->getValue();
}
示例7: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$detailsNode = $node->getElementsByTagName('details')->item(0);
$this->details = $this->createDetails();
$this->details->initFromXmlNode($detailsNode);
foreach ($this->details->items as $item) {
if ($this->userAnswer != '') {
$this->userAnswer .= '; ';
}
$this->userAnswer .= $item->userAnswer ? $item->userAnswer : '______';
}
}
示例8: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$hotspotsNodeList = $node->getElementsByTagName('hotspots');
$hotspotsNode = $hotspotsNodeList->item(0);
$hotspots = $this->getHotspotsFromXmlNode($hotspotsNode);
foreach ($hotspots as $hotspot) {
if ($this->userAnswer != '') {
$this->userAnswer .= '; ';
}
$this->userAnswer .= $hotspot->label . ' - ' . ($hotspot->marked ? 'Marked' : 'Unmarked');
}
}
示例9: initFromXmlNode
public function initFromXmlNode(DOMElement $node)
{
parent::initFromXmlNode($node);
$answersNode = $node->getElementsByTagName('answers')->item(0);
$answersList = $answersNode->getElementsByTagName('answer');
for ($i = 0; $i < $answersList->length; ++$i) {
$answerNode = $answersList->item($i);
$answer = $this->createAnswer($i);
$answer->initFromXmlNode($answerNode);
$this->answers[] = $answer;
}
$userAnswer = array();
foreach ($this->answers as $answer) {
$userAnswer[$answer->userDefinedPosition] = $answer;
}
$answersCount = count($userAnswer);
for ($i = 0; $i < $answersCount; ++$i) {
if ($this->userAnswer != '') {
$this->userAnswer .= '; ';
}
$this->userAnswer .= $i + 1 . '. ' . $userAnswer[$i]->text;
}
}