Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401]
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 mod_quiz_display_options class. 19 * 20 * @package mod_quiz 21 * @category phpunit 22 * @copyright 2010 The Open University 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 global $CFG; 30 require_once($CFG->dirroot . '/mod/quiz/locallib.php'); 31 32 33 /** 34 * Unit tests for {@link mod_quiz_display_options}. 35 * 36 * @copyright 2010 The Open University 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class mod_quiz_display_options_testcase extends basic_testcase { 40 public function test_num_attempts_access_rule() { 41 $quiz = new stdClass(); 42 $quiz->decimalpoints = 2; 43 $quiz->questiondecimalpoints = -1; 44 $quiz->reviewattempt = 0x11110; 45 $quiz->reviewcorrectness = 0x10000; 46 $quiz->reviewmarks = 0x01110; 47 $quiz->reviewspecificfeedback = 0x10000; 48 $quiz->reviewgeneralfeedback = 0x01000; 49 $quiz->reviewrightanswer = 0x00100; 50 $quiz->reviewoverallfeedback = 0x00010; 51 52 $options = mod_quiz_display_options::make_from_quiz($quiz, 53 mod_quiz_display_options::DURING); 54 55 $this->assertEquals(true, $options->attempt); 56 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->correctness); 57 $this->assertEquals(mod_quiz_display_options::MAX_ONLY, $options->marks); 58 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->feedback); 59 // The next two should be controlled by the same settings as ->feedback. 60 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->numpartscorrect); 61 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->manualcomment); 62 $this->assertEquals(2, $options->markdp); 63 64 $quiz->questiondecimalpoints = 5; 65 $options = mod_quiz_display_options::make_from_quiz($quiz, 66 mod_quiz_display_options::IMMEDIATELY_AFTER); 67 68 $this->assertEquals(mod_quiz_display_options::MARK_AND_MAX, $options->marks); 69 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->generalfeedback); 70 $this->assertEquals(mod_quiz_display_options::HIDDEN, $options->feedback); 71 // The next two should be controlled by the same settings as ->feedback. 72 $this->assertEquals(mod_quiz_display_options::HIDDEN, $options->numpartscorrect); 73 $this->assertEquals(mod_quiz_display_options::HIDDEN, $options->manualcomment); 74 $this->assertEquals(5, $options->markdp); 75 76 $options = mod_quiz_display_options::make_from_quiz($quiz, 77 mod_quiz_display_options::LATER_WHILE_OPEN); 78 79 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->rightanswer); 80 $this->assertEquals(mod_quiz_display_options::HIDDEN, $options->generalfeedback); 81 82 $options = mod_quiz_display_options::make_from_quiz($quiz, 83 mod_quiz_display_options::AFTER_CLOSE); 84 85 $this->assertEquals(mod_quiz_display_options::VISIBLE, $options->overallfeedback); 86 $this->assertEquals(mod_quiz_display_options::HIDDEN, $options->rightanswer); 87 } 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body