public function parse()
 {
     // 定义题型样式
     $ap = $this->patterning(array($this->anp, $this->ap), 'umi');
     // 处理答案
     $answerTextArray = array();
     preg_match_all($ap, $this->_sectionText, $answerTextArray);
     if (count($answerTextArray) > 0 && count($answerTextArray[0]) > 0) {
         $answerTextArray = $answerTextArray[0];
     } else {
         return null;
     }
     // 处理答案
     $answerArray = array();
     foreach ($answerTextArray as $answerText) {
         // 拆解每个答案并生成对应的Answer
         $answer = new Answer(true);
         $answerText = preg_replace($this->patterning($this->anp), '', $answerText);
         $subAnswerTextArray = array();
         $subAnswerTextArray = preg_split($this->patterning($this->sas), $answerText);
         foreach ($subAnswerTextArray as $subAnswerText) {
             $subAnswer = new Answer();
             $subAnswer->Set_content(ext_trim($subAnswerText));
             $subAnswer->Set_type(AnswerType::SHORT_ANSWER);
             $subAnswers =& $answer->Get_answers();
             $subAnswers[] = $subAnswer;
         }
         $answer->Set_type(AnswerType::SHORT_ANSWER);
         $answerArray[] = $answer;
     }
     // 返回结果
     return $answerArray;
 }
 public function parse()
 {
     // 定义题型样式
     $ap = $this->patterning(array($this->anp, $this->ap, $this->ep), 'umi');
     // 处理答案
     $answerTextArray = array();
     preg_match_all($ap, $this->_sectionText, $answerTextArray);
     if (count($answerTextArray) > 0 && count($answerTextArray[0]) > 0) {
         $answerTextArray = $answerTextArray[0];
     } else {
         return null;
     }
     // 处理答案
     $answerArray = array();
     foreach ($answerTextArray as $answerText) {
         // 拆解每个答案并生成对应的Answer
         $answer = new Answer();
         $answer->Set_content(ext_trim(preg_replace($ap, '$1', $answerText)));
         $answer->Set_type(AnswerType::CORRECTION);
         $answer->Set_desc(ext_trim(preg_replace($this->patterning(array($this->anp, $this->ap), 'umi'), '', $answerText)));
         $answerArray[] = $answer;
     }
     // 返回结果
     return $answerArray;
 }
 public function parse()
 {
     // 定义题型样式
     $qp = $this->patterning($this->qp, 'us');
     // 提取题型
     $questionTextArray = array();
     preg_match_all($qp, preg_replace($this->patterning(QuestionType::$PATTERNS[QuestionType::SHORT_ANSWER], 'us'), '', $this->_sectionText), $questionTextArray);
     if (count($questionTextArray) == 0 || count($questionTextArray[0]) == 0) {
         return null;
     }
     // 处理题型
     $questionArray = array();
     $questionDescArray = $questionTextArray[1];
     // 每个问题的描述部分
     $questionSetArray = $questionTextArray[2];
     // 每个问题的提问部分
     for ($i = 0; $i < count($questionDescArray); $i++) {
         // 拆解每个题型并生成对应的Question
         $question = new Question();
         // 大问题部分
         $question->Set_content(ext_trim($questionDescArray[$i]));
         $question->Set_type(QuestionType::SHORT_ANSWER);
         $question->Set_questions(array());
         $subQuestionArray =& $question->Get_questions();
         $questionArray[] = $question;
         // 追加大问题
         // 生成子问题以及选项
         $questionSet = array();
         preg_match_all($this->patterning(array($this->qnp, '.+?(?=(?:\\n', $this->qnp, '|$))'), 'us'), $questionSetArray[$i], $questionSet);
         $questionSet = count($questionSet) > 0 ? $questionSet[0] : null;
         if (!$questionSet) {
             continue;
         }
         foreach ($questionSet as $optionText) {
             $subQuestion = new Question();
             // 子问题
             $subQuestion->Set_content(ext_trim(preg_replace($this->patterning(array('.*?', $this->qnp), 'us'), '', $optionText)));
             $subQuestion->Set_type(QuestionType::SHORT_ANSWER);
             //                $subQuestion->Set_options(array());
             $subQuestionArray[] = $subQuestion;
             // 追加子问题
             //                $subOptionArray = &$subQuestion->Get_options();
             //                // 整理每个选项组
             //                $optionSetTextArray = array();
             //                preg_match_all($this->patterning(array($this->onp, '.+?', '(?:(?=', $this->onp, ')|(?=$))'), 'us'), $optionText, $optionSetTextArray);
             //                foreach ($optionSetTextArray as $eachOptionTextArray) {
             //                    foreach ($eachOptionTextArray as $eachOptionText) {
             //                        $option = new Option();
             //                        $option->Set_option_content(ext_trim(preg_replace($this->patterning($this->onp), '', $eachOptionText)));
             //                        $option->Set_item_tag(preg_replace($this->patterning(array('(', $this->onp, ').+')), '$1', $eachOptionText));
             //                        $option->Set_type(QuestionType::SHORT_ANSWER);
             //                        $subOptionArray[] = $option;
             //                    }
             //                }
         }
     }
     // 返回结果
     return $questionArray;
 }
 public function parse()
 {
     // 定义题型样式
     $qp = $this->patterning($this->qp);
     // 提取题型
     $questionTextArray = array();
     preg_match_all($qp, $this->_sectionText, $questionTextArray);
     if (count($questionTextArray) > 0 && count($questionTextArray[0]) > 0) {
         $questionTextArray = $questionTextArray[0];
     } else {
         return null;
     }
     // 处理题型
     $questionArray = array();
     foreach ($questionTextArray as $eachQuestionText) {
         // 拆解每个题型并生成对应的Question
         $question = new Question();
         $question->Set_content(ext_trim(preg_replace($this->patterning($this->qnp), '', $eachQuestionText)));
         $question->Set_type(QuestionType::COMPLETION);
         $questionArray[] = $question;
     }
     // 返回结果
     return $questionArray;
 }
 public function parse()
 {
     // 定义题型样式
     $ap = $this->patterning($this->ap, 'usi');
     // 处理答案
     $answerTextArray = array();
     preg_match_all($ap, $this->_sectionText, $answerTextArray);
     if (count($answerTextArray) > 0 && count($answerTextArray[0]) > 0) {
         $answerTextArray = $answerTextArray[0];
     } else {
         return null;
     }
     // 处理答案
     $answerArray = array();
     foreach ($answerTextArray as $answerText) {
         // 拆解每个答案并生成对应的Answer
         $answer = new Answer();
         $answer->Set_content(ext_trim($answerText));
         $answer->Set_type(AnswerType::TRUE_OR_FALSE);
         $answerArray[] = $answer;
     }
     // 返回结果
     return $answerArray;
 }
 public function parse()
 {
     // 定义题型样式
     $qop = $this->patterning($this->qop, 'us');
     // 提取题型
     $questionOptionTextArray = array();
     preg_match_all($qop, $this->_sectionText, $questionOptionTextArray);
     if (count($questionOptionTextArray) > 0 && count($questionOptionTextArray[0]) > 0) {
         $questionOptionTextArray = $questionOptionTextArray[0];
     } else {
         return null;
     }
     // 处理题型
     $questionArray = array();
     foreach ($questionOptionTextArray as $eachQuestionOptionText) {
         // 拆解每个题型并生成对应的Question
         $question = new Question();
         $question->Set_content(ext_trim(preg_replace($this->patterning(array($this->qnp, '(.+?)\\n.*'), 'usi'), '$2', $eachQuestionOptionText)));
         $question->Set_type(QuestionType::MULTIPLE_CHOICE);
         // 处理选项Option
         $eachQuestionOptionText = preg_replace($this->patterning(array($this->qnp, '.+?\\n'), 'us'), '', $eachQuestionOptionText, 1);
         // 去除问题部分,仅仅保留Option
         $eachQuestionOptionText = preg_replace('/^\\n+|\\n+$/', "", $eachQuestionOptionText);
         // 去除首尾换行符
         $optionTextArray = array();
         preg_match_all($this->patterning(array($this->onp, '.+?', '(?:(?=', $this->onp, ')|(?=$))'), 'us'), $eachQuestionOptionText, $optionTextArray);
         if (count($optionTextArray) > 0) {
             $optionTextArray = $optionTextArray[0];
         }
         $options = array();
         foreach ($optionTextArray as $eachOptionText) {
             $option = new Option();
             $option->Set_option_content(ext_trim(preg_replace($this->patterning($this->onp), '', $eachOptionText)));
             $option->Set_item_tag(preg_replace($this->patterning(array('(', $this->onp, ').+')), '$1', $eachOptionText));
             $option->Set_type(QuestionType::MULTIPLE_CHOICE);
             $options[] = $option;
         }
         $question->Set_options($options);
         $questionArray[] = $question;
     }
     // 返回结果
     return $questionArray;
 }
Example #7
0
 function Set_item_tag($_item_tag)
 {
     $_item_tag = strtoupper(ext_trim(preg_replace('/[^A-Z\\d]/', '', $_item_tag)));
     $this->_item_tag = is_numeric($_item_tag) ? $_item_tag : ord($_item_tag) - 64;
 }