Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/format/multianswer/format.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 
00037 class qformat_multianswer extends qformat_default {
00038 
00039     public function provide_import() {
00040       return true;
00041     }
00042 
00043     protected function readquestions($lines) {
00044         // For this class the method has been simplified as
00045         // there can never be more than one question for a
00046         // multianswer import
00047         $questions = array();
00048 
00049         $questiontext = array();
00050         $questiontext['text'] = implode('', $lines);
00051         $questiontext['format'] = 0 ;
00052         $questiontext['itemid'] = '';
00053         $question = qtype_multianswer_extract_question($questiontext);
00054         $question->questiontext = $question->questiontext['text'] ;
00055         $question->questiontextformat = 0 ;
00056 
00057         $question->qtype = MULTIANSWER;
00058         $question->generalfeedback = '';
00059         $question->course = $this->course;
00060 
00061         if (!empty($question)) {
00062             $name = html_to_text(implode(' ', $lines));
00063             $name = preg_replace('/{[^}]*}/', '', $name);
00064             $name = trim($name);
00065 
00066             if ($name) {
00067                 $question->name = shorten_text($name, 45);
00068             } else {
00069                 // We need some name, so use the current time, since that will be
00070                 // reasonably unique.
00071                 $question->name = userdate(time());
00072             }
00073 
00074             $questions[] = $question;
00075         }
00076 
00077         return $questions;
00078     }
00079 }
 All Data Structures Namespaces Files Functions Variables Enumerations