|
Moodle
2.2.1
http://www.collinsharper.com
|
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 quiz_class_test extends UnitTestCase { 00039 public function test_cannot_review_message() { 00040 $quiz = new stdClass(); 00041 $quiz->reviewattempt = 0x10010; 00042 $quiz->timeclose = 0; 00043 $quiz->attempts = 0; 00044 $quiz->questions = '1,2,0,3,4,0'; 00045 00046 $cm = new stdClass(); 00047 $cm->id = 123; 00048 00049 $quizobj = new quiz($quiz, $cm, new stdClass(), false); 00050 00051 $this->assertEqual('', 00052 $quizobj->cannot_review_message(mod_quiz_display_options::DURING)); 00053 $this->assertEqual('', 00054 $quizobj->cannot_review_message(mod_quiz_display_options::IMMEDIATELY_AFTER)); 00055 $this->assertEqual(get_string('noreview', 'quiz'), 00056 $quizobj->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN)); 00057 $this->assertEqual(get_string('noreview', 'quiz'), 00058 $quizobj->cannot_review_message(mod_quiz_display_options::AFTER_CLOSE)); 00059 00060 $closetime = time() + 10000; 00061 $quiz->timeclose = $closetime; 00062 $quizobj = new quiz($quiz, $cm, new stdClass(), false); 00063 00064 $this->assertEqual(get_string('noreviewuntil', 'quiz', userdate($closetime)), 00065 $quizobj->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN)); 00066 } 00067 00068 public function test_empty_quiz() { 00069 $quiz = new stdClass(); 00070 $quiz->reviewattempt = 0x10010; 00071 $quiz->timeclose = 0; 00072 $quiz->attempts = 0; 00073 $quiz->questions = '0'; 00074 00075 $cm = new stdClass(); 00076 $cm->id = 123; 00077 00078 $quizobj = new quiz($quiz, $cm, new stdClass(), false); 00079 00080 $this->assertFalse($quizobj->has_questions()); 00081 } 00082 }