Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/calculatedsimple/simpletest/helper.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 require_once($CFG->dirroot . '/question/type/calculated/simpletest/helper.php');
00030 
00031 
00038 class qtype_calculatedsimple_test_helper extends question_test_helper {
00039     public function get_test_questions() {
00040         return array('sum');
00041     }
00042 
00047     public function make_calculatedsimple_question_sum() {
00048         question_bank::load_question_definition_classes('calculatedsimple');
00049         $q = new qtype_calculatedsimple_question();
00050         test_question_maker::initialise_a_question($q);
00051         $q->name = 'Simple sum';
00052         $q->questiontext = 'What is {a} + {b}?';
00053         $q->generalfeedback = 'Generalfeedback: {={a} + {b}} is the right answer.';
00054 
00055         $q->answers = array(
00056             13 => new qtype_numerical_answer(13, '{a} + {b}', 1.0, 'Very good.', FORMAT_HTML, 0),
00057             14 => new qtype_numerical_answer(14, '{a} - {b}', 0.0, 'Add. not subtract!.',
00058                     FORMAT_HTML, 0),
00059             17 => new qtype_numerical_answer(17, '*', 0.0, 'Completely wrong.', FORMAT_HTML, 0),
00060         );
00061         foreach ($q->answers as $answer) {
00062             $answer->correctanswerlength = 2;
00063             $answer->correctanswerformat = 1;
00064         }
00065 
00066         $q->qtype = question_bank::get_qtype('calculated');
00067         $q->unitdisplay = qtype_numerical::UNITNONE;
00068         $q->unitgradingtype = 0;
00069         $q->unitpenalty = 0;
00070         $q->ap = new qtype_numerical_answer_processor(array());
00071 
00072         $q->datasetloader = new qtype_calculated_test_dataset_loader(0, array(
00073             array('a' => 1, 'b' => 5),
00074             array('a' => 3, 'b' => 4),
00075         ));
00076 
00077         return $q;
00078     }
00079 }
 All Data Structures Namespaces Files Functions Variables Enumerations