|
Moodle
2.2.1
http://www.collinsharper.com
|
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_bank_test extends UnitTestCase { 00039 00040 public function setUp() { 00041 } 00042 00043 public function tearDown() { 00044 } 00045 00046 public function test_sort_qtype_array() { 00047 $config = new stdClass(); 00048 $config->multichoice_sortorder = '1'; 00049 $config->calculated_sortorder = '2'; 00050 $qtypes = array( 00051 'frog' => 'toad', 00052 'calculated' => 'newt', 00053 'multichoice' => 'eft', 00054 ); 00055 $this->assertEqual(question_bank::sort_qtype_array($qtypes, $config), array( 00056 'multichoice' => 'eft', 00057 'calculated' => 'newt', 00058 'frog' => 'toad', 00059 )); 00060 } 00061 00062 public function test_fraction_options() { 00063 $fractions = question_bank::fraction_options(); 00064 $this->assertIdentical(get_string('none'), reset($fractions)); 00065 $this->assertIdentical('0.0', key($fractions)); 00066 $this->assertIdentical('5%', end($fractions)); 00067 $this->assertIdentical('0.05', key($fractions)); 00068 array_shift($fractions); 00069 array_pop($fractions); 00070 array_pop($fractions); 00071 $this->assertIdentical('100%', reset($fractions)); 00072 $this->assertIdentical('1.0', key($fractions)); 00073 $this->assertIdentical('11.11111%', end($fractions)); 00074 $this->assertIdentical('0.1111111', key($fractions)); 00075 } 00076 00077 public function test_fraction_options_full() { 00078 $fractions = question_bank::fraction_options_full(); 00079 $this->assertIdentical(get_string('none'), reset($fractions)); 00080 $this->assertIdentical('0.0', key($fractions)); 00081 $this->assertIdentical('-100%', end($fractions)); 00082 $this->assertIdentical('-1.0', key($fractions)); 00083 array_shift($fractions); 00084 array_pop($fractions); 00085 array_pop($fractions); 00086 $this->assertIdentical('100%', reset($fractions)); 00087 $this->assertIdentical('1.0', key($fractions)); 00088 $this->assertIdentical('-83.33333%', end($fractions)); 00089 $this->assertIdentical('-0.8333333', key($fractions)); 00090 } 00091 }