Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/engine/simpletest/testquestionengine.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(dirname(__FILE__) . '/../lib.php');
00030 
00031 
00038 class question_engine_test extends UnitTestCase {
00039 
00040     public function setUp() {
00041 
00042     }
00043 
00044     public function tearDown() {
00045 
00046     }
00047 
00048     public function test_load_behaviour_class() {
00049         // Exercise SUT
00050         question_engine::load_behaviour_class('deferredfeedback');
00051         // Verify
00052         $this->assertTrue(class_exists('qbehaviour_deferredfeedback'));
00053     }
00054 
00055     public function test_load_behaviour_class_missing() {
00056         // Set expectation.
00057         $this->expectException();
00058         // Exercise SUT
00059         question_engine::load_behaviour_class('nonexistantbehaviour');
00060     }
00061 
00062     public function test_get_behaviour_unused_display_options() {
00063         $this->assertEqual(array(), question_engine::get_behaviour_unused_display_options('interactive'));
00064         $this->assertEqual(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'),
00065                 question_engine::get_behaviour_unused_display_options('deferredfeedback'));
00066         $this->assertEqual(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'),
00067                 question_engine::get_behaviour_unused_display_options('deferredcbm'));
00068         $this->assertEqual(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'),
00069                 question_engine::get_behaviour_unused_display_options('manualgraded'));
00070     }
00071 
00072     public function test_sort_behaviours() {
00073         $in = array('b1' => 'Behave 1', 'b2' => 'Behave 2', 'b3' => 'Behave 3', 'b4' => 'Behave 4', 'b5' => 'Behave 5', 'b6' => 'Behave 6');
00074 
00075         $out = array('b1' => 'Behave 1', 'b2' => 'Behave 2', 'b3' => 'Behave 3', 'b4' => 'Behave 4', 'b5' => 'Behave 5', 'b6' => 'Behave 6');
00076         $this->assertIdentical($out, question_engine::sort_behaviours($in, '', '', ''));
00077 
00078         $this->assertIdentical($out, question_engine::sort_behaviours($in, '', 'b4', 'b4'));
00079 
00080         $out = array('b4' => 'Behave 4', 'b5' => 'Behave 5', 'b6' => 'Behave 6');
00081         $this->assertIdentical($out, question_engine::sort_behaviours($in, '', 'b1,b2,b3,b4', 'b4'));
00082 
00083         $out = array('b6' => 'Behave 6', 'b1' => 'Behave 1', 'b4' => 'Behave 4');
00084         $this->assertIdentical($out, question_engine::sort_behaviours($in, 'b6,b1,b4', 'b2,b3,b4,b5', 'b4'));
00085 
00086         $out = array('b6' => 'Behave 6', 'b5' => 'Behave 5', 'b4' => 'Behave 4');
00087         $this->assertIdentical($out, question_engine::sort_behaviours($in, 'b6,b5,b4', 'b1,b2,b3', 'b4'));
00088 
00089         $out = array('b6' => 'Behave 6', 'b5' => 'Behave 5', 'b4' => 'Behave 4');
00090         $this->assertIdentical($out, question_engine::sort_behaviours($in, 'b1,b6,b5', 'b1,b2,b3,b4', 'b4'));
00091 
00092         $out = array('b2' => 'Behave 2', 'b4' => 'Behave 4', 'b6' => 'Behave 6');
00093         $this->assertIdentical($out, question_engine::sort_behaviours($in, 'b2,b4,b6', 'b1,b3,b5', 'b2'));
00094 
00095         // Ignore unknown input in the order argument.
00096         $this->assertIdentical($in, question_engine::sort_behaviours($in, 'unknown', '', ''));
00097 
00098         // Ignore unknown input in the disabled argument.
00099         $this->assertIdentical($in, question_engine::sort_behaviours($in, '', 'unknown', ''));
00100     }
00101 }
 All Data Structures Namespaces Files Functions Variables Enumerations