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