[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/format/multianswer/ -> format.php (source)

   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          $question = qtype_multianswer_extract_question($questiontext);
  55          $question->questiontext = $question->questiontext['text'];
  56          $question->questiontextformat = 0;
  57  
  58          $question->qtype = 'multianswer';
  59          $question->generalfeedback = '';
  60          $question->generalfeedbackformat = FORMAT_MOODLE;
  61          $question->length = 1;
  62          $question->penalty = 0.3333333;
  63  
  64          if (!empty($question)) {
  65              $question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question'));
  66              $questions[] = $question;
  67          }
  68  
  69          return $questions;
  70      }
  71  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1