Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Embedded answer (Cloze) question importer. 19 * 20 * @package qformat_multianswer 21 * @copyright 2003 Henrik Kaipe 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 29 /** 30 * Importer that imports a text file containing a single Multianswer question 31 * from a text file. 32 * 33 * @copyright 2003 Henrik Kaipe 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class qformat_multianswer extends qformat_default { 37 38 public function provide_import() { 39 return true; 40 } 41 42 public function readquestions($lines) { 43 question_bank::get_qtype('multianswer'); // Ensure the multianswer code is loaded. 44 45 // For this class the method has been simplified as 46 // there can never be more than one question for a 47 // multianswer import. 48 $questions = array(); 49 50 $questiontext = array(); 51 $questiontext['text'] = implode('', $lines); 52 $questiontext['format'] = FORMAT_MOODLE; 53 $questiontext['itemid'] = ''; 54 55 $question = qtype_multianswer_extract_question($questiontext); 56 $errors = qtype_multianswer_validate_question($question); 57 if ($errors) { 58 $this->error(get_string('invalidmultianswerquestion', 'qtype_multianswer', implode(' ', $errors))); 59 return array(); 60 } 61 62 $question->questiontext = $question->questiontext['text']; 63 $question->questiontextformat = 0; 64 65 $question->qtype = 'multianswer'; 66 $question->generalfeedback = ''; 67 $question->generalfeedbackformat = FORMAT_MOODLE; 68 $question->length = 1; 69 $question->penalty = 0.3333333; 70 71 if (!empty($question)) { 72 $question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question')); 73 $questions[] = $question; 74 } 75 76 return $questions; 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body