Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/simpletest/testquizdisplayoptions.php
Go to the documentation of this file.
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($CFG->dirroot . '/mod/quiz/locallib.php');
00030 
00031 
00038 class mod_quiz_display_options_test extends UnitTestCase {
00039     public function test_num_attempts_access_rule() {
00040         $quiz = new stdClass();
00041         $quiz->decimalpoints = 2;
00042         $quiz->questiondecimalpoints = -1;
00043         $quiz->reviewattempt          = 0x11110;
00044         $quiz->reviewcorrectness      = 0x10000;
00045         $quiz->reviewmarks            = 0x01110;
00046         $quiz->reviewspecificfeedback = 0x10000;
00047         $quiz->reviewgeneralfeedback  = 0x01000;
00048         $quiz->reviewrightanswer      = 0x00100;
00049         $quiz->reviewoverallfeedback  = 0x00010;
00050 
00051         $options = mod_quiz_display_options::make_from_quiz($quiz,
00052                 mod_quiz_display_options::DURING);
00053 
00054         $this->assertEqual(true, $options->attempt);
00055         $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->correctness);
00056         $this->assertEqual(mod_quiz_display_options::MAX_ONLY, $options->marks);
00057         $this->assertEqual(2, $options->markdp);
00058 
00059         $quiz->questiondecimalpoints = 5;
00060         $options = mod_quiz_display_options::make_from_quiz($quiz,
00061                 mod_quiz_display_options::IMMEDIATELY_AFTER);
00062 
00063         $this->assertEqual(mod_quiz_display_options::MARK_AND_MAX, $options->marks);
00064         $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->generalfeedback);
00065         $this->assertEqual(mod_quiz_display_options::HIDDEN, $options->feedback);
00066         $this->assertEqual(5, $options->markdp);
00067 
00068         $options = mod_quiz_display_options::make_from_quiz($quiz,
00069                 mod_quiz_display_options::LATER_WHILE_OPEN);
00070 
00071         $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->rightanswer);
00072         $this->assertEqual(mod_quiz_display_options::HIDDEN, $options->generalfeedback);
00073 
00074         $options = mod_quiz_display_options::make_from_quiz($quiz,
00075                 mod_quiz_display_options::AFTER_CLOSE);
00076 
00077         $this->assertEqual(mod_quiz_display_options::VISIBLE, $options->overallfeedback);
00078         $this->assertEqual(mod_quiz_display_options::HIDDEN, $options->rightanswer);
00079     }
00080 }
 All Data Structures Namespaces Files Functions Variables Enumerations