See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310]
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 * This file contains tests that walks a question through the deferred feedback 19 * with certainty base marking behaviour. 20 * 21 * @package qbehaviour 22 * @subpackage deferredcbm 23 * @copyright 2009 The Open University 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 global $CFG; 31 require_once (__DIR__ . '/../../../engine/lib.php'); 32 require_once (__DIR__ . '/../../../engine/tests/helpers.php'); 33 34 35 /** 36 * Unit tests for the deferred feedback with certainty base marking behaviour. 37 * 38 * @copyright 2009 The Open University 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base { 42 43 /** @var qbehaviour_deferredcbm_type */ 44 protected $behaviourtype; 45 46 public function setUp() { 47 parent::setUp(); 48 $this->behaviourtype = question_engine::get_behaviour_type('deferredcbm'); 49 } 50 51 public function test_is_archetypal() { 52 $this->assertTrue($this->behaviourtype->is_archetypal()); 53 } 54 55 public function test_get_unused_display_options() { 56 $this->assertEquals(array('correctness', 'marks', 'specificfeedback', 'generalfeedback', 'rightanswer'), 57 $this->behaviourtype->get_unused_display_options()); 58 } 59 60 public function test_can_questions_finish_during_the_attempt() { 61 $this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt()); 62 } 63 64 public function test_adjust_random_guess_score() { 65 $this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0)); 66 $this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1)); 67 } 68 69 public function test_summarise_usage_max_mark_1() { 70 71 // Create a usage comprising 3 true-false questions. 72 $this->quba->set_preferred_behaviour('deferredcbm'); 73 $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 3); 74 $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 3); 75 $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 3); 76 $this->quba->start_all_questions(); 77 78 // Process responses right, high certainty; right, med certainty; wrong, med certainty. 79 $this->quba->process_action(1, array('answer' => 1, '-certainty' => 3)); 80 $this->quba->process_action(2, array('answer' => 1, '-certainty' => 2)); 81 $this->quba->process_action(3, array('answer' => 0, '-certainty' => 2)); 82 $this->quba->finish_all_questions(); 83 84 // Get the summary. 85 $summarydata = $this->quba->get_summary_information(new question_display_options()); 86 87 // Verify. 88 $this->assertContains(get_string('breakdownbycertainty', 'qbehaviour_deferredcbm'), 89 $summarydata['qbehaviour_cbm_judgement_heading']['content']); 90 91 $this->assertContains('100%', 92 $summarydata['qbehaviour_cbm_judgement3']['content']); 93 $this->assertContains(get_string('judgementok', 'qbehaviour_deferredcbm'), 94 $summarydata['qbehaviour_cbm_judgement3']['content']); 95 96 $this->assertContains('50%', 97 $summarydata['qbehaviour_cbm_judgement2']['content']); 98 $this->assertContains(get_string('slightlyoverconfident', 'qbehaviour_deferredcbm'), 99 $summarydata['qbehaviour_cbm_judgement2']['content']); 100 101 $this->assertContains(get_string('noquestions', 'qbehaviour_deferredcbm'), 102 $summarydata['qbehaviour_cbm_judgement1']['content']); 103 } 104 105 public function test_summarise_usage_max_mark_3() { 106 107 // Create a usage comprising 3 true-false questions. 108 $this->quba->set_preferred_behaviour('deferredcbm'); 109 $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 1); 110 $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 1); 111 $this->quba->add_question(test_question_maker::make_question('truefalse', 'true'), 1); 112 $this->quba->start_all_questions(); 113 114 // Process responses right, high certainty; right, med certainty; wrong, med certainty. 115 $this->quba->process_action(1, array('answer' => 1, '-certainty' => 3)); 116 $this->quba->process_action(2, array('answer' => 1, '-certainty' => 2)); 117 $this->quba->process_action(3, array('answer' => 0, '-certainty' => 2)); 118 $this->quba->finish_all_questions(); 119 120 // Get the summary. 121 $summarydata = $this->quba->get_summary_information(new question_display_options()); 122 123 // Verify. 124 $this->assertContains(get_string('breakdownbycertainty', 'qbehaviour_deferredcbm'), 125 $summarydata['qbehaviour_cbm_judgement_heading']['content']); 126 127 $this->assertContains('100%', 128 $summarydata['qbehaviour_cbm_judgement3']['content']); 129 $this->assertContains(get_string('judgementok', 'qbehaviour_deferredcbm'), 130 $summarydata['qbehaviour_cbm_judgement3']['content']); 131 132 $this->assertContains('50%', 133 $summarydata['qbehaviour_cbm_judgement2']['content']); 134 $this->assertContains(get_string('slightlyoverconfident', 'qbehaviour_deferredcbm'), 135 $summarydata['qbehaviour_cbm_judgement2']['content']); 136 137 $this->assertContains(get_string('noquestions', 'qbehaviour_deferredcbm'), 138 $summarydata['qbehaviour_cbm_judgement1']['content']); 139 } 140 141 public function test_calculate_bonus() { 142 $this->assertEqualsWithDelta(0.05, $this->behaviourtype->calculate_bonus(1, 1 / 2), question_testcase::GRADE_DELTA); 143 $this->assertEqualsWithDelta(-0.01, $this->behaviourtype->calculate_bonus(2, 9 / 10), question_testcase::GRADE_DELTA); 144 $this->assertEqualsWithDelta(0, $this->behaviourtype->calculate_bonus(3, 1), question_testcase::GRADE_DELTA); 145 } 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body