当前位置: 首页>>代码示例>>PHP>>正文


PHP Question::initFromXmlNode方法代码示例

本文整理汇总了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'));
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:7,代码来源:TypeInSurveyQuestion.class.php

示例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];
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:35,代码来源:MatchingSurveyQuestion.class.php

示例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;
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:28,代码来源:LikertScaleQuestion.class.php

示例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;
         }
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:25,代码来源:MultipleResponseSurveyQuestion.class.php

示例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);
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:9,代码来源:EssayQuestion.class.php

示例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();
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:10,代码来源:MultipleChoiceSurveyQuestion.class.php

示例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 : '______';
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:13,代码来源:FillInTheBlankSurveyQuestion.class.php

示例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');
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:13,代码来源:HotspotQuestion.class.php

示例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;
     }
 }
开发者ID:andhis2,项目名称:QuizResults,代码行数:23,代码来源:SequenceSurveyQuestion.class.php


注:本文中的Question::initFromXmlNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。