protected function readquestions($lines) { // For this class the method has been simplified as // there can never be more than one question for a // multianswer import $questions = array(); $questiontext = array(); $questiontext['text'] = implode('', $lines); $questiontext['format'] = 0; $questiontext['itemid'] = ''; $question = qtype_multianswer_extract_question($questiontext); $question->questiontext = $question->questiontext['text']; $question->questiontextformat = 0; $question->qtype = MULTIANSWER; $question->generalfeedback = ''; $question->course = $this->course; if (!empty($question)) { $name = html_to_text(implode(' ', $lines)); $name = preg_replace('/{[^}]*}/', '', $name); $name = trim($name); if ($name) { $question->name = shorten_text($name, 45); } else { // We need some name, so use the current time, since that will be // reasonably unique. $question->name = userdate(time()); } $questions[] = $question; } return $questions; }
public function readquestions($lines) { question_bank::get_qtype('multianswer'); // Ensure the multianswer code is loaded. // For this class the method has been simplified as // there can never be more than one question for a // multianswer import. $questions = array(); $questiontext = array(); $questiontext['text'] = implode('', $lines); $questiontext['format'] = FORMAT_MOODLE; $questiontext['itemid'] = ''; $question = qtype_multianswer_extract_question($questiontext); $question->questiontext = $question->questiontext['text']; $question->questiontextformat = 0; $question->qtype = 'multianswer'; $question->generalfeedback = ''; $question->generalfeedbackformat = FORMAT_MOODLE; $question->length = 1; $question->penalty = 0.3333333; if (!empty($question)) { $question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question')); $questions[] = $question; } return $questions; }
function definition_inner(&$mform) { $question_type_names = question_type_menu(); $mform->addRule('questiontext', null, 'required', null, 'client'); // Remove meaningless defaultgrade field. $mform->removeElement('defaultgrade'); // display the questions from questiontext; if ("" != optional_param('questiontext', '', PARAM_RAW)) { $this->questiondisplay = fullclone(qtype_multianswer_extract_question(optional_param('questiontext', '', PARAM_RAW))); } else { $this->questiondisplay = ""; } if (isset($this->questiondisplay->options->questions) && is_array($this->questiondisplay->options->questions)) { $countsubquestions = 0; foreach ($this->questiondisplay->options->questions as $subquestion) { if (!empty($subquestion)) { $countsubquestions++; } } } else { $countsubquestions = 0; } $mform->addElement('submit', 'analyzequestion', get_string('decodeverifyquestiontext', 'qtype_multianswer')); $mform->registerNoSubmitButton('analyzequestion'); for ($sub = 1; $sub <= $countsubquestions; $sub++) { $this->editas[$sub] = 'unknown type'; if (isset($this->questiondisplay->options->questions[$sub]->qtype)) { $this->editas[$sub] = $this->questiondisplay->options->questions[$sub]->qtype; } else { if (optional_param('sub_' . $sub . "_" . 'qtype', '', PARAM_RAW) != '') { $this->editas[$sub] = optional_param('sub_' . $sub . "_" . 'qtype', '', PARAM_RAW); } } $mform->addElement('header', 'subhdr', get_string('questionno', 'quiz', '{#' . $sub . '}') . ' ' . $question_type_names[$this->questiondisplay->options->questions[$sub]->qtype]); $mform->addElement('static', 'sub_' . $sub . "_" . 'questiontext', get_string('questiondefinition', 'qtype_multianswer'), array('cols' => 60, 'rows' => 3)); if (isset($this->questiondisplay->options->questions[$sub]->questiontext)) { $mform->setDefault('sub_' . $sub . "_" . 'questiontext', $this->questiondisplay->options->questions[$sub]->questiontext); } $mform->addElement('static', 'sub_' . $sub . "_" . 'defaultgrade', get_string('defaultgrade', 'quiz')); $mform->setDefault('sub_' . $sub . "_" . 'defaultgrade', $this->questiondisplay->options->questions[$sub]->defaultgrade); if ($this->questiondisplay->options->questions[$sub]->qtype == 'shortanswer') { $mform->addElement('static', 'sub_' . $sub . "_" . 'usecase', get_string('casesensitive', 'quiz')); } if ($this->questiondisplay->options->questions[$sub]->qtype == 'multichoice') { $mform->addElement('static', 'sub_' . $sub . "_" . 'layout', get_string('layout', 'qtype_multianswer'), array('cols' => 60, 'rows' => 1)); //, $gradeoptions); } foreach ($this->questiondisplay->options->questions[$sub]->answer as $key => $ans) { $mform->addElement('static', 'sub_' . $sub . "_" . 'answer[' . $key . ']', get_string('answer', 'quiz'), array('cols' => 60, 'rows' => 1)); if ($this->questiondisplay->options->questions[$sub]->qtype == 'numerical' && $key == 0) { $mform->addElement('static', 'sub_' . $sub . "_" . 'tolerance[' . $key . ']', get_string('acceptederror', 'quiz')); //, $gradeoptions); } $mform->addElement('static', 'sub_' . $sub . "_" . 'fraction[' . $key . ']', get_string('grade')); //, $gradeoptions); $mform->addElement('static', 'sub_' . $sub . "_" . 'feedback[' . $key . ']', get_string('feedback', 'quiz')); } } }
function readquestions($lines) { // Parses an array of lines into an array of questions. // For this class the method has been simplified as // there can never be more than one question for a // multianswer import $questions = array(); $thequestion = qtype_multianswer_extract_question(addslashes(implode('', $lines))); $thequestion->qtype = MULTIANSWER; $thequestion->course = $this->course; if (!empty($thequestion)) { $thequestion->name = addslashes($lines[0]); $questions[] = $thequestion; } return $questions; }
/** * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle. * Used to process data not supported by QTI and to improve performances. * * @param QtiImportSettings $data * @return object|null */ public function build_moodle(QtiImportSettings $settings) { $result = parent::build_moodle($settings); $data = $settings->get_data(); $text = $data->questiontext; foreach ($data->options->questions as $key => $q) { $text = str_replace('{#' . $key . '}', $q->questiontext, $text); } $result = qtype_multianswer_extract_question($text); $result->resources = array(); $result->questiontextformat = FORMAT_HTML; $result->name = $data->name; $result->generalfeedback = $data->generalfeedback; $result->penalty = $data->penalty; return $result; }
public function readquestions($lines) { question_bank::get_qtype('multianswer'); // Ensure the multianswer code is loaded. // For this class the method has been simplified as // there can never be more than one question for a // multianswer import. $questions = array(); $questiontext = array(); $questiontext['text'] = implode('', $lines); $questiontext['format'] = FORMAT_MOODLE; $questiontext['itemid'] = ''; $question = qtype_multianswer_extract_question($questiontext); $question->questiontext = $question->questiontext['text']; $question->questiontextformat = 0; $question->qtype = 'multianswer'; $question->generalfeedback = ''; $question->generalfeedbackformat = FORMAT_MOODLE; $question->length = 1; $question->penalty = 0.3333333; if (!empty($question)) { $name = html_to_text(implode(' ', $lines)); $name = preg_replace('/{[^}]*}/', '', $name); $name = trim($name); if ($name) { $question->name = shorten_text($name, 45); } else { // We need some name, so use the current time, since that will be // reasonably unique. $question->name = userdate(time()); } $questions[] = $question; } return $questions; }
/** * import cloze type question * @param array question question array from xml tree * @return object question object */ function import_multianswer($questions) { $questiontext = $questions['#']['questiontext'][0]['#']['text']; $qo = qtype_multianswer_extract_question($this->import_text($questiontext)); // 'header' parts particular to multianswer $qo->qtype = MULTIANSWER; $qo->course = $this->course; $qo->generalfeedback = $this->getpath($questions, array('#', 'generalfeedback', 0, '#', 'text', 0, '#'), '', true); if (!empty($questions)) { $qo->name = $this->import_text($questions['#']['name'][0]['#']['text']); } return $qo; }
/** * Import cloze type question * @param array question question array from xml tree * @return object question object */ public function import_multianswer($question) { global $USER; question_bank::get_qtype('multianswer'); $questiontext = $this->import_text_with_files($question, array('#', 'questiontext', 0)); $qo = qtype_multianswer_extract_question($questiontext); // Header parts particular to multianswer. $qo->qtype = 'multianswer'; $qo->course = $this->course; $qo->name = $this->clean_question_name($this->import_text($question['#']['name'][0]['#']['text'])); $qo->questiontextformat = $questiontext['format']; $qo->questiontext = $qo->questiontext['text']; if (!empty($questiontext['itemid'])) { $qo->questiontextitemid = $questiontext['itemid']; } // Backwards compatibility, deal with the old image tag. $filedata = $this->getpath($question, array('#', 'image_base64', '0', '#'), null, false); $filename = $this->getpath($question, array('#', 'image', '0', '#'), null, false); if ($filedata && $filename) { $fs = get_file_storage(); if (empty($qo->questiontextitemid)) { $qo->questiontextitemid = file_get_unused_draft_itemid(); } $filename = clean_param(str_replace('/', '_', $filename), PARAM_FILE); $filerecord = array('contextid' => context_user::instance($USER->id)->id, 'component' => 'user', 'filearea' => 'draft', 'itemid' => $qo->questiontextitemid, 'filepath' => '/', 'filename' => $filename); $fs->create_file_from_string($filerecord, base64_decode($filedata)); $qo->questiontext .= ' <img src="@@PLUGINFILE@@/' . $filename . '" />'; } // Restore files in generalfeedback. $generalfeedback = $this->import_text_with_files($question, array('#', 'generalfeedback', 0), $qo->generalfeedback, $this->get_format($qo->questiontextformat)); $qo->generalfeedback = $generalfeedback['text']; $qo->generalfeedbackformat = $generalfeedback['format']; if (!empty($generalfeedback['itemid'])) { $qo->generalfeedbackitemid = $generalfeedback['itemid']; } $qo->penalty = $this->getpath($question, array('#', 'penalty', 0, '#'), $this->defaultquestion()->penalty); // Fix problematic rounding from old files. if (abs($qo->penalty - 0.3333333) < 0.005) { $qo->penalty = 0.3333333; } $this->import_hints($qo, $question, true, false, $this->get_format($qo->questiontextformat)); return $qo; }
public function validation($data, $files) { $errors = parent::validation($data, $files); $questiondisplay = qtype_multianswer_extract_question($data['questiontext']); if (isset($questiondisplay->options->questions)) { $subquestions = fullclone($questiondisplay->options->questions); if (count($subquestions)) { $sub = 1; foreach ($subquestions as $subquestion) { $prefix = 'sub_' . $sub . '_'; $answercount = 0; $maxgrade = false; $maxfraction = -1; foreach ($subquestion->answer as $key => $answer) { if (is_array($answer)) { $answer = $answer['text']; } $trimmedanswer = trim($answer); if ($trimmedanswer !== '') { $answercount++; if ($subquestion->qtype == 'numerical' && !($this->is_valid_number($trimmedanswer) || $trimmedanswer == '*')) { $errors[$prefix . 'answer[' . $key . ']'] = get_string('answermustbenumberorstar', 'qtype_numerical'); } if ($subquestion->fraction[$key] == 1) { $maxgrade = true; } if ($subquestion->fraction[$key] > $maxfraction) { $maxfraction = $subquestion->fraction[$key]; } } } if ($answercount == 0) { if ($subquestion->qtype == 'multichoice') { $errors[$prefix . 'answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2); } else { $errors[$prefix . 'answer[0]'] = get_string('notenoughanswers', 'question', 1); } } if ($maxgrade == false) { $errors[$prefix . 'fraction[0]'] = get_string('fractionsnomax', 'question'); } $sub++; } } else { $errors['questiontext'] = get_string('questionsmissing', 'qtype_multianswer'); } } if (($this->negativediff > 0 || $this->usedinquiz && ($this->negativediff > 0 || $this->negativediff < 0 || $this->qtypechange)) && !$this->confirm) { $errors['confirm'] = get_string('confirmsave', 'qtype_multianswer', $this->negativediff); } return $errors; }
/** * import cloze type question * @param array question question array from xml tree * @return object question object */ function import_multianswer($questions) { $questiontext = array(); $questiontext['text'] = $this->import_text($questions['#']['questiontext'][0]['#']['text']); $questiontext['format'] = '1'; $questiontext['itemid'] = ''; $qo = qtype_multianswer_extract_question($questiontext); // 'header' parts particular to multianswer $qo->qtype = MULTIANSWER; $qo->course = $this->course; $qo->generalfeedback = ''; // restore files in generalfeedback $qo->generalfeedback = $this->getpath($questions, array('#', 'generalfeedback', 0, '#', 'text', 0, '#'), $qo->generalfeedback, true); $qo->generalfeedbackfiles = array(); $qo->generalfeedbackformat = $this->trans_format($this->getpath($questions, array('#', 'generalfeedback', 0, '@', 'format'), 'moodle_auto_format')); $files = $this->getpath($questions, array('#', 'generalfeedback', 0, '#', 'file'), array(), false); foreach ($files as $file) { $data = new stdclass(); $data->content = $file['#']; $data->encoding = $file['@']['encoding']; $data->name = $file['@']['name']; $qo->generalfeedbackfiles[] = $data; } if (!empty($questions)) { $qo->name = $this->import_text($questions['#']['name'][0]['#']['text']); } $qo->questiontext = $qo->questiontext['text']; $qo->questiontextformat = ''; return $qo; }
/** * Import cloze type question * @param array question question array from xml tree * @return object question object */ public function import_multianswer($question) { question_bank::get_qtype('multianswer'); $questiontext['text'] = $this->import_text($question['#']['questiontext'][0]['#']['text']); $questiontext['format'] = FORMAT_HTML; $questiontext['itemid'] = ''; $qo = qtype_multianswer_extract_question($questiontext); // 'header' parts particular to multianswer $qo->qtype = 'multianswer'; $qo->course = $this->course; $qo->generalfeedback = ''; $qo->name = $this->clean_question_name($this->import_text($question['#']['name'][0]['#']['text'])); $qo->questiontextformat = $questiontext['format']; $qo->questiontext = $qo->questiontext['text']; $itemid = $this->import_files($this->getpath($question, array('#', 'questiontext', 0, '#', 'file'), array(), false)); if (!empty($itemid)) { $qo->questiontextitemid = $itemid; } // Backwards compatibility, deal with the old image tag. $filedata = $this->getpath($question, array('#', 'image_base64', '0', '#'), null, false); $filename = $this->getpath($question, array('#', 'image', '0', '#'), null, false); if ($filedata && $filename) { $data = new stdClass(); $data->content = $filedata; $data->encoding = 'base64'; // Question file areas don't support subdirs, so convert path to filename if necessary. $data->name = clean_param(str_replace('/', '_', $filename), PARAM_FILE); $qo->questiontextfiles[] = $data; $qo->questiontext .= ' <img src="@@PLUGINFILE@@/' . $data->name . '" />'; } // restore files in generalfeedback $generalfeedback = $this->import_text_with_files($question, array('#', 'generalfeedback', 0), $qo->generalfeedback, $this->get_format($qo->questiontextformat)); $qo->generalfeedback = $generalfeedback['text']; $qo->generalfeedbackformat = $generalfeedback['format']; if (!empty($generalfeedback['itemid'])) { $qo->generalfeedbackitemid = $generalfeedback['itemid']; } $qo->penalty = $this->getpath($question, array('#', 'penalty', 0, '#'), $this->defaultquestion()->penalty); // Fix problematic rounding from old files: if (abs($qo->penalty - 0.3333333) < 0.005) { $qo->penalty = 0.3333333; } $this->import_hints($qo, $question, false, false, $this->get_format($qo->questiontextformat)); return $qo; }
/** * Verify that the multiplechoice variants parameters are correctly interpreted from * the question text * * */ public function test_questiontext_extraction_of_multiplechoice_subquestions_variants() { $questiontext = array(); $questiontext['format'] = FORMAT_HTML; $questiontext['itemid'] = ''; $questiontext['text'] = '<p>Match the following cities with the correct state:</p> <ul> <li>1 San Francisco:{1:MULTICHOICE:=California#OK~Arizona#Wrong}</li> <li>2 Tucson:{1:MC:%0%California#Wrong~=Arizona#OK}</li> <li>3 Los Angeles:{1:MULTICHOICE_S:=California#OK~Arizona#Wrong}</li> <li>4 Phoenix:{1:MCS:%0%California#Wrong~=Arizona#OK}</li> <li>5 San Francisco:{1:MULTICHOICE_H:=California#OK~Arizona#Wrong}</li> <li>6 Tucson:{1:MCH:%0%California#Wrong~=Arizona#OK}</li> <li>7 Los Angeles:{1:MULTICHOICE_HS:=California#OK~Arizona#Wrong}</li> <li>8 Phoenix:{1:MCHS:%0%California#Wrong~=Arizona#OK}</li> <li>9 San Francisco:{1:MULTICHOICE_V:=California#OK~Arizona#Wrong}</li> <li>10 Tucson:{1:MCV:%0%California#Wrong~=Arizona#OK}</li> <li>11 Los Angeles:{1:MULTICHOICE_VS:=California#OK~Arizona#Wrong}</li> <li>12 Phoenix:{1:MCVS:%0%California#Wrong~=Arizona#OK}</li> </ul>'; $q = qtype_multianswer_extract_question($questiontext); foreach ($q->options->questions as $key => $sub) { $this->assertSame($sub->qtype, 'multichoice'); if ($key == 1 || $key == 2 || $key == 5 || $key == 6 || $key == 9 || $key == 10) { $this->assertSame($sub->shuffleanswers, 0); } else { $this->assertSame($sub->shuffleanswers, 1); } if ($key == 1 || $key == 2 || $key == 3 || $key == 4) { $this->assertSame($sub->layout, qtype_multichoice_base::LAYOUT_DROPDOWN); } else { if ($key == 5 || $key == 6 || $key == 7 || $key == 8) { $this->assertSame($sub->layout, qtype_multichoice_base::LAYOUT_HORIZONTAL); } else { if ($key == 9 || $key == 10 || $key == 11 || $key == 12) { $this->assertSame($sub->layout, qtype_multichoice_base::LAYOUT_VERTICAL); } } } } }
/** * Import cloze type question * @param array question question array from xml tree * @return object question object */ public function import_multianswer($questions) { question_bank::get_qtype('multianswer'); $questiontext = array(); $questiontext['text'] = $this->import_text($questions['#']['questiontext'][0]['#']['text']); $questiontext['format'] = '1'; $questiontext['itemid'] = ''; $qo = qtype_multianswer_extract_question($questiontext); // 'header' parts particular to multianswer $qo->qtype = MULTIANSWER; $qo->course = $this->course; $qo->generalfeedback = ''; // restore files in generalfeedback $qo->generalfeedback = $this->getpath($questions, array('#', 'generalfeedback', 0, '#', 'text', 0, '#'), $qo->generalfeedback, true); $qo->generalfeedbackformat = $this->trans_format($this->getpath($questions, array('#', 'generalfeedback', 0, '@', 'format'), 'moodle_auto_format')); $qo->generalfeedbackfiles = $this->import_files($this->getpath($questions, array('#', 'generalfeedback', 0, '#', 'file'), array(), false)); if (!empty($questions)) { $qo->name = $this->import_text($questions['#']['name'][0]['#']['text']); } $qo->questiontext = $qo->questiontext['text']; $qo->questiontextformat = ''; $this->import_hints($qo, $questions, true); return $qo; }
function wrsqz_qtype_multianswer_extract_question($form){ global $CFG; //include($CFG->dirroot . '/question/type/multianswer/questiontype.php'); $text = $form->questiontext; $question = qtype_multianswer_extract_question($text); //if ( isset($form->hiddenCASValue) && !wrsqz_isEmptySession($form->hiddenCASValue)){ $question->qtype = 'multianswerwiris'; foreach($question->options->questions as $key=>$wrapped){ if(($wrapped->qtype == 'shortanswer' || $wrapped->qtype == 'multichoice') && strpos($wrapped->questiontext,'#')!==false){ $wrapped->qtype .= 'wiris'; } $question->options->questions[$key] = $wrapped; } // } return $question; }
function validation($data, $files) { $errors = parent::validation($data, $files); $questiondisplay = qtype_multianswer_extract_question($data['questiontext']); // echo "<p> questiondisplay ".$data['questiontext']['text']." <pre>";print_r($questiondisplay);echo "</pre></p>"; if (isset($questiondisplay->options->questions)) { $subquestions = fullclone($questiondisplay->options->questions); if (count($subquestions)) { $sub = 1; foreach ($subquestions as $subquestion) { $prefix = 'sub_' . $sub . '_'; $answercount = 0; $maxgrade = false; $maxfraction = -1; if (isset($this->savedquestiondisplay->options->questions[$sub]->qtype) && $this->savedquestiondisplay->options->questions[$sub]->qtype != $questiondisplay->options->questions[$sub]->qtype) { $storemess = " STORED QTYPE " . $question_type_names[$this->savedquestiondisplay->options->questions[$sub]->qtype]; } foreach ($subquestion->answer as $key => $answer) { $trimmedanswer = trim($answer); if ($trimmedanswer !== '') { $answercount++; if ($subquestion->qtype == 'numerical' && !(is_numeric($trimmedanswer) || $trimmedanswer == '*')) { $errors[$prefix . 'answer[' . $key . ']'] = get_string('answermustbenumberorstar', 'qtype_numerical'); } if ($subquestion->fraction[$key] == 1) { $maxgrade = true; } if ($subquestion->fraction[$key] > $maxfraction) { $maxfraction = $subquestion->fraction[$key]; } } } if ($answercount == 0) { if ($subquestion->qtype == 'multichoice') { $errors[$prefix . 'answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2); } else { $errors[$prefix . 'answer[0]'] = get_string('notenoughanswers', 'quiz', 1); } } if ($maxgrade == false) { $errors[$prefix . 'fraction[0]'] = get_string('fractionsnomax', 'question'); } $sub++; } } else { $errors['questiontext'] = get_string('questionsmissing', 'qtype_multianswer'); } } // $question = qtype_multianswer_extract_question($data['questiontext']); // if (isset $question->options->questions if (($this->negative_diff > 0 || $this->used_in_quiz && ($this->negative_diff > 0 || $this->negative_diff < 0 || $this->qtype_change)) && $this->confirm == 0) { $errors['confirm'] = get_string('confirmsave', 'qtype_multianswer', $this->negative_diff); } return $errors; }
function save_question($authorizedquestion, $form) { $question = qtype_multianswer_extract_question($form->questiontext); if (isset($authorizedquestion->id)) { $question->id = $authorizedquestion->id; } $question->category = $authorizedquestion->category; $form->defaultgrade = $question->defaultgrade; $form->questiontext = $question->questiontext; $form->questiontextformat = 0; $form->options = clone $question->options; unset($question->options); return parent::save_question($question, $form); }
/** * Import a fill in the blanks question that has a score per blannk * @param SimpleXML_Object xml object containing the question data * @param object a partly populated question object to work with * @return object the modified question object */ private function import_multi_answer_fib($xmlquestion, $qo) { question_bank::get_qtype('multianswer'); /* Parse QML text - import_fib basically does this, but we need to * build the Cloze question string in the correct format. */ $questiontext = array(); // Array holding question data. $multiansdata = $this->build_multianswer_string($xmlquestion); // Set the questiontext and format. $questiontext['text'] = $multiansdata['text']; $questiontext['format'] = FORMAT_MOODLE; $qo = qtype_multianswer_extract_question($questiontext); // Set values for the question. $qo->qtype = 'multianswer'; $qo->course = $this->course; $qo->name = $multiansdata['qname']; $qo->questiontextformat = 0; $qo->questiontext = $qo->questiontext['text']; $qo->generalfeedback = ''; $qo->generalfeedbackformat = FORMAT_MOODLE; $qo->length = 1; $qo->penalty = 0.3333333; return $qo; }
function save_question($authorizedquestion, $form, $course) { $question = qtype_multianswer_extract_question($form->questiontext); if (isset($authorizedquestion->id)) { $question->id = $authorizedquestion->id; } $question->category = $authorizedquestion->category; $form->course = $course; // To pass the course object to // save_question_options, where it is // needed to call type specific // save_question methods. $form->defaultgrade = $question->defaultgrade; $form->questiontext = $question->questiontext; $form->questiontextformat = 0; $form->options = clone $question->options; unset($question->options); return parent::save_question($question, $form, $course); }
/** * Import cloze type question * @param array question question array from xml tree * @return object question object */ public function import_multianswer($question) { question_bank::get_qtype('multianswer'); $questiontext['text'] = $this->import_text($question['#']['questiontext'][0]['#']['text']); $questiontext['format'] = FORMAT_HTML; $questiontext['itemid'] = ''; $qo = qtype_multianswer_extract_question($questiontext); // 'header' parts particular to multianswer $qo->qtype = 'multianswer'; $qo->course = $this->course; $qo->generalfeedback = ''; $qo->name = $this->clean_question_name($this->import_text($question['#']['name'][0]['#']['text'])); $qo->questiontextformat = $questiontext['format']; $qo->questiontext = $qo->questiontext['text']; $qo->questiontextfiles = array(); // restore files in generalfeedback $qo->generalfeedback = $this->getpath($question, array('#', 'generalfeedback', 0, '#', 'text', 0, '#'), $qo->generalfeedback, true); $qo->generalfeedbackformat = $this->trans_format($this->getpath($question, array('#', 'generalfeedback', 0, '@', 'format'), $this->get_format($qo->questiontextformat))); $qo->generalfeedbackfiles = $this->import_files($this->getpath($question, array('#', 'generalfeedback', 0, '#', 'file'), array(), false)); $qo->penalty = $this->getpath($question, array('#', 'penalty', 0, '#'), $this->defaultquestion()->penalty); // Fix problematic rounding from old files: if (abs($qo->penalty - 0.3333333) < 0.005) { $qo->penalty = 0.3333333; } $this->import_hints($qo, $question, false, false, $this->get_format($qo->questiontextformat)); return $qo; }