See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
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 * Unit tests for the calculated_random_question_summary class. 19 * 20 * @package core_question 21 * @category test 22 * @copyright 2018 Shamim Rezaie <shamim@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 use core_question\statistics\questions\calculated_question_summary; 29 30 /** 31 * Class core_question_calculated_question_summary_testcase 32 * 33 * @copyright 2018 Shamim Rezaie <shamim@moodle.com> 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class core_question_calculated_question_summary_testcase extends advanced_testcase { 37 38 /** 39 * Provider for test_get_min_max_of. 40 * 41 * @return array 42 */ 43 public function get_min_max_provider() { 44 return [ 45 'negative number and null' => [ 46 [ 47 (object)['questionid' => 1, 'index' => 2], 48 (object)['questionid' => 2, 'index' => -7], 49 (object)['questionid' => 3, 'index' => null], 50 (object)['questionid' => 4, 'index' => 12], 51 ], 52 [-7, 12] 53 ], 54 'null and negative number' => [ 55 [ 56 (object)['questionid' => 1, 'index' => 2], 57 (object)['questionid' => 2, 'index' => null], 58 (object)['questionid' => 3, 'index' => -7], 59 (object)['questionid' => 4, 'index' => 12], 60 ], 61 [-7, 12] 62 ], 63 'negative number and null as maximum' => [ 64 [ 65 (object)['questionid' => 1, 'index' => -2], 66 (object)['questionid' => 2, 'index' => null], 67 (object)['questionid' => 3, 'index' => -7], 68 ], 69 [-7, null] 70 ], 71 'zero and null' => [ 72 [ 73 (object)['questionid' => 1, 'index' => 2], 74 (object)['questionid' => 2, 'index' => 0], 75 (object)['questionid' => 3, 'index' => null], 76 (object)['questionid' => 4, 'index' => 12], 77 ], 78 [0, 12] 79 ], 80 'null as minimum' => [ 81 [ 82 (object)['questionid' => 1, 'index' => 2], 83 (object)['questionid' => 2, 'index' => null], 84 (object)['questionid' => 3, 'index' => 12], 85 ], 86 [null, 12] 87 ], 88 'null and null' => [ 89 [ 90 (object)['questionid' => 1, 'index' => 2], 91 (object)['questionid' => 2, 'index' => null], 92 (object)['questionid' => 3, 'index' => null], 93 ], 94 [null, 2] 95 ], 96 ]; 97 } 98 99 /** 100 * Unit test for get_min_max_of() method. 101 * 102 * @dataProvider get_min_max_provider 103 */ 104 public function test_get_min_max_of($subqstats, $expected) { 105 $calculatedsummary = new calculated_question_summary(null, null, $subqstats); 106 $res = $calculatedsummary->get_min_max_of('index'); 107 $this->assertEquals($expected, $res); 108 } 109 110 /** 111 * Provider for test_get_min_max_of. 112 * 113 * @return array 114 */ 115 public function get_sd_min_max_provider() { 116 return [ 117 'null and number' => [ 118 [ 119 (object)['questionid' => 1, 'sd' => 0.2, 'maxmark' => 0.5], 120 (object)['questionid' => 2, 'sd' => null, 'maxmark' => 1], 121 (object)['questionid' => 3, 'sd' => 0.1049, 'maxmark' => 1], 122 (object)['questionid' => 4, 'sd' => 0.12, 'maxmark' => 1], 123 ], 124 [null, 0.4] 125 ], 126 'null and zero' => [ 127 [ 128 (object)['questionid' => 1, 'sd' => 0.2, 'maxmark' => 0.5], 129 (object)['questionid' => 2, 'sd' => null, 'maxmark' => 1], 130 (object)['questionid' => 3, 'sd' => 0, 'maxmark' => 1], 131 (object)['questionid' => 4, 'sd' => 0.12, 'maxmark' => 1], 132 ], 133 [0, 0.4] 134 ], 135 'zero mark' => [ 136 [ 137 (object)['questionid' => 1, 'sd' => 0.2, 'maxmark' => 0], 138 (object)['questionid' => 2, 'sd' => 0.1049, 'maxmark' => 1], 139 ], 140 [null, 0.1049] 141 ], 142 'nonzero and nonzero' => [ 143 [ 144 (object)['questionid' => 1, 'sd' => 0.2, 'maxmark' => 0.5], 145 (object)['questionid' => 2, 'sd' => 0.7, 'maxmark' => 2], 146 ], 147 [0.35, 0.4] 148 ], 149 ]; 150 } 151 152 /** 153 * Unit test for get_min_max_of_sd() method. 154 * 155 * @dataProvider get_sd_min_max_provider 156 */ 157 public function test_get_min_max_of_sd($subqstats, $expected) { 158 $calculatedsummary = new calculated_question_summary(null, null, $subqstats); 159 $res = $calculatedsummary->get_min_max_of('sd'); 160 $this->assertEquals($expected, $res); 161 } 162 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body