MDL-32149 add quiz unit tests

This commit is contained in:
Petr Skoda
2012-04-03 22:31:02 +02:00
parent e72ea4a5e4
commit 7fe8aac1a7
18 changed files with 2030 additions and 0 deletions
+3
View File
@@ -274,6 +274,9 @@ class phpunit_util {
}
}
// restore _SERVER
unset($_SERVER['HTTP_USER_AGENT']);
// restore original config
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
@@ -0,0 +1,289 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_delaybetweenattempts plugin.
*
* @package quizaccess
* @subpackage delaybetweenattempts
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/delaybetweenattempts/rule.php');
/**
* Unit tests for the quizaccess_delaybetweenattempts plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_delaybetweenattempts_testcase extends basic_testcase {
public function test_just_first_delay() {
$quiz = new stdClass();
$quiz->attempts = 3;
$quiz->timelimit = 0;
$quiz->delay1 = 1000;
$quiz->delay2 = 0;
$quiz->timeclose = 0;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->timefinish = 10000;
$rule = new quizaccess_delaybetweenattempts($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$attempt->timefinish = 9000;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$attempt->timefinish = 9001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
}
public function test_just_second_delay() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
$quiz->delay1 = 0;
$quiz->delay2 = 1000;
$quiz->timeclose = 0;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->timefinish = 10000;
$rule = new quizaccess_delaybetweenattempts($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->prevent_new_attempt(5, $attempt));
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertEquals($rule->prevent_new_attempt(3, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$attempt->timefinish = 9000;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$attempt->timefinish = 9001;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertEquals($rule->prevent_new_attempt(4, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
}
public function test_just_both_delays() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
$quiz->delay1 = 2000;
$quiz->delay2 = 1000;
$quiz->timeclose = 0;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->timefinish = 10000;
$rule = new quizaccess_delaybetweenattempts($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->prevent_new_attempt(5, $attempt));
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(12000)));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertEquals($rule->prevent_new_attempt(3, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$attempt->timefinish = 8000;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$attempt->timefinish = 8001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(4, $attempt));
$attempt->timefinish = 9000;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$attempt->timefinish = 9001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11001)));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertEquals($rule->prevent_new_attempt(4, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
}
public function test_with_close_date() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
$quiz->delay1 = 2000;
$quiz->delay2 = 1000;
$quiz->timeclose = 15000;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->timefinish = 13000;
$rule = new quizaccess_delaybetweenattempts($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
$attempt->timefinish = 13000;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(15000)));
$attempt->timefinish = 13001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youcannotwait', 'quizaccess_delaybetweenattempts'));
$attempt->timefinish = 14000;
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(15000)));
$attempt->timefinish = 14001;
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youcannotwait', 'quizaccess_delaybetweenattempts'));
$rule = new quizaccess_delaybetweenattempts($quizobj, 15000);
$attempt->timefinish = 13000;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$attempt->timefinish = 13001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youcannotwait', 'quizaccess_delaybetweenattempts'));
$attempt->timefinish = 14000;
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$attempt->timefinish = 14001;
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youcannotwait', 'quizaccess_delaybetweenattempts'));
$rule = new quizaccess_delaybetweenattempts($quizobj, 15001);
$attempt->timefinish = 13000;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$attempt->timefinish = 13001;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$attempt->timefinish = 14000;
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$attempt->timefinish = 14001;
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
}
public function test_time_limit_and_overdue() {
$quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 100;
$quiz->delay1 = 2000;
$quiz->delay2 = 1000;
$quiz->timeclose = 0;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->timestart = 9900;
$attempt->timefinish = 10100;
$rule = new quizaccess_delaybetweenattempts($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->prevent_new_attempt(5, $attempt));
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(12000)));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertEquals($rule->prevent_new_attempt(3, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$attempt->timestart = 7950;
$attempt->timefinish = 8000;
$this->assertFalse($rule->prevent_new_attempt(1, $attempt));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$attempt->timestart = 7950;
$attempt->timefinish = 8001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(4, $attempt));
$attempt->timestart = 8950;
$attempt->timefinish = 9000;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$attempt->timestart = 8950;
$attempt->timefinish = 9001;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11001)));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertEquals($rule->prevent_new_attempt(4, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$attempt->timestart = 8900;
$attempt->timefinish = 9100;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11000)));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertFalse($rule->prevent_new_attempt(3, $attempt));
$attempt->timestart = 8901;
$attempt->timefinish = 9100;
$this->assertEquals($rule->prevent_new_attempt(1, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(11001)));
$this->assertEquals($rule->prevent_new_attempt(2, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
$this->assertEquals($rule->prevent_new_attempt(4, $attempt),
get_string('youmustwait', 'quizaccess_delaybetweenattempts', userdate(10001)));
}
}
@@ -0,0 +1,73 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_ipaddress plugin.
*
* @package quizaccess
* @subpackage ipaddress
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/ipaddress/rule.php');
/**
* Unit tests for the quizaccess_ipaddress plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_ipaddress_testcase extends basic_testcase {
public function test_ipaddress_access_rule() {
$quiz = new stdClass();
$attempt = new stdClass();
$cm = new stdClass();
$cm->id = 0;
// Test the allowed case by getting the user's IP address. However, this
// does not always work, for example using the mac install package on my laptop.
$quiz->subnet = getremoteaddr(null);
if (!empty($quiz->subnet)) {
$quiz->questions = '';
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_ipaddress($quizobj, 0);
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->description());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 1));
}
$quiz->subnet = '0.0.0.0';
$quiz->questions = '';
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_ipaddress($quizobj, 0);
$this->assertNotEmpty($rule->prevent_access());
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 1));
}
}
@@ -0,0 +1,69 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_numattempts plugin.
*
* @package quizaccess
* @subpackage numattempts
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/numattempts/rule.php');
/**
* Unit tests for the quizaccess_numattempts plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_numattempts_testcase extends basic_testcase {
public function test_num_attempts_access_rule() {
$quiz = new stdClass();
$quiz->attempts = 3;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_numattempts($quizobj, 0);
$attempt = new stdClass();
$this->assertEquals($rule->description(),
get_string('attemptsallowedn', 'quizaccess_numattempts', 3));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->prevent_new_attempt(2, $attempt));
$this->assertEquals($rule->prevent_new_attempt(3, $attempt),
get_string('nomoreattempts', 'quiz'));
$this->assertEquals($rule->prevent_new_attempt(666, $attempt),
get_string('nomoreattempts', 'quiz'));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->is_finished(2, $attempt));
$this->assertTrue($rule->is_finished(3, $attempt));
$this->assertTrue($rule->is_finished(666, $attempt));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->time_left($attempt, 1));
}
}
@@ -0,0 +1,180 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_openclosedate plugin.
*
* @package quizaccess
* @subpackage openclosedate
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/openclosedate/rule.php');
/**
* Unit tests for the quizaccess_openclosedate plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_openclosedate_testcase extends basic_testcase {
public function test_no_dates() {
$quiz = new stdClass();
$quiz->timeopen = 0;
$quiz->timeclose = 0;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->preview = 0;
$rule = new quizaccess_openclosedate($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 10000));
$this->assertFalse($rule->time_left($attempt, 0));
$rule = new quizaccess_openclosedate($quizobj, 0);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
}
public function test_start_date() {
$quiz = new stdClass();
$quiz->timeopen = 10000;
$quiz->timeclose = 0;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->preview = 0;
$rule = new quizaccess_openclosedate($quizobj, 9999);
$this->assertEquals($rule->description(),
array(get_string('quiznotavailable', 'quizaccess_openclosedate', userdate(10000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
$rule = new quizaccess_openclosedate($quizobj, 10000);
$this->assertEquals($rule->description(),
array(get_string('quizopenedon', 'quiz', userdate(10000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 0));
}
public function test_close_date() {
$quiz = new stdClass();
$quiz->timeopen = 0;
$quiz->timeclose = 20000;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->preview = 0;
$rule = new quizaccess_openclosedate($quizobj, 20000);
$this->assertEquals($rule->description(),
array(get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 20000 - QUIZ_SHOW_TIME_BEFORE_DEADLINE));
$this->assertEquals($rule->time_left($attempt, 19900), 100);
$this->assertEquals($rule->time_left($attempt, 20000), 0);
$this->assertEquals($rule->time_left($attempt, 20100), -100);
$rule = new quizaccess_openclosedate($quizobj, 20001);
$this->assertEquals($rule->description(),
array(get_string('quizclosed', 'quiz', userdate(20000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertTrue($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 20000 - QUIZ_SHOW_TIME_BEFORE_DEADLINE));
$this->assertEquals($rule->time_left($attempt, 19900), 100);
$this->assertEquals($rule->time_left($attempt, 20000), 0);
$this->assertEquals($rule->time_left($attempt, 20100), -100);
}
public function test_both_dates() {
$quiz = new stdClass();
$quiz->timeopen = 10000;
$quiz->timeclose = 20000;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$attempt = new stdClass();
$attempt->preview = 0;
$rule = new quizaccess_openclosedate($quizobj, 9999);
$this->assertEquals($rule->description(),
array(get_string('quiznotavailable', 'quizaccess_openclosedate', userdate(10000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$rule = new quizaccess_openclosedate($quizobj, 10000);
$this->assertEquals($rule->description(),
array(get_string('quizopenedon', 'quiz', userdate(10000)),
get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$rule = new quizaccess_openclosedate($quizobj, 20000);
$this->assertEquals($rule->description(),
array(get_string('quizopenedon', 'quiz', userdate(10000)),
get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$rule = new quizaccess_openclosedate($quizobj, 20001);
$this->assertEquals($rule->description(),
array(get_string('quizclosed', 'quiz', userdate(20000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertTrue($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 20000 - QUIZ_SHOW_TIME_BEFORE_DEADLINE));
$this->assertEquals($rule->time_left($attempt, 19900), 100);
$this->assertEquals($rule->time_left($attempt, 20000), 0);
$this->assertEquals($rule->time_left($attempt, 20100), -100);
}
}
@@ -0,0 +1,58 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_password plugin.
*
* @package quizaccess
* @subpackage password
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/password/rule.php');
/**
* Unit tests for the quizaccess_password plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_password_testcase extends basic_testcase {
public function test_password_access_rule() {
$quiz = new stdClass();
$quiz->password = 'frog';
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_password($quizobj, 0);
$attempt = new stdClass();
$this->assertFalse($rule->prevent_access());
$this->assertEquals($rule->description(),
get_string('requirepasswordmessage', 'quizaccess_password'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 1));
}
}
@@ -0,0 +1,63 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_safebrowser plugin.
*
* @package quizaccess
* @subpackage safebrowser
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/safebrowser/rule.php');
/**
* Unit tests for the quizaccess_safebrowser plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_safebrowser_testcase extends basic_testcase {
// Nothing very testable in this class, just test that it obeys the general access rule contact.
public function test_safebrowser_access_rule() {
$quiz = new stdClass();
$quiz->browsersecurity = 'safebrowser';
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_safebrowser($quizobj, 0);
$attempt = new stdClass();
// This next test assumes the unit tests are not being run using Safe Exam Browser!
$_SERVER['HTTP_USER_AGENT'] = 'unknonw browser';
$this->assertEquals(get_string('safebrowsererror', 'quizaccess_safebrowser'),
$rule->prevent_access());
$this->assertEquals(get_string('safebrowsernotice', 'quizaccess_safebrowser'),
$rule->description());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 1));
}
}
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_securewindow plugin.
*
* @package quizaccess
* @subpackage securewindow
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/securewindow/rule.php');
/**
* Unit tests for the quizaccess_securewindow plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_securewindow_testcase extends basic_testcase {
public static $includecoverage = array('mod/quiz/accessrule/securewindow/rule.php');
// Nothing very testable in this class, just test that it obeys the general access rule contact.
public function test_securewindow_access_rule() {
$quiz = new stdClass();
$quiz->browsersecurity = 'securewindow';
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_securewindow($quizobj, 0);
$attempt = new stdClass();
$this->assertFalse($rule->prevent_access());
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
$this->assertFalse($rule->time_left($attempt, 1));
}
}
@@ -0,0 +1,62 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quizaccess_timelimit plugin.
*
* @package quizaccess
* @subpackage timelimit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/timelimit/rule.php');
/**
* Unit tests for the quizaccess_timelimit plugin.
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_timelimit_testcase extends basic_testcase {
public function test_time_limit_access_rule() {
$quiz = new stdClass();
$quiz->timelimit = 3600;
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new quizaccess_timelimit($quizobj, 10000);
$attempt = new stdClass();
$this->assertEquals($rule->description(),
get_string('quiztimelimit', 'quizaccess_timelimit', format_time(3600)));
$attempt->timestart = 10000;
$this->assertEquals($rule->time_left($attempt, 10000), 3600);
$this->assertEquals($rule->time_left($attempt, 12000), 1600);
$this->assertEquals($rule->time_left($attempt, 14000), -400);
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
}
}
@@ -0,0 +1,21 @@
slot,id,number,category,parent,name,questiontext,questiontextformat,image,generalfeedback,defaultgrade,penalty,qtype,length,stamp,version,hidden,timecreated,timemodified,createdby,modifiedby,maxmark
1,1,1,5,0,questionessay-11,What is the purpose of life?,0,,General feedback,1,0,essay,1,localhost+080922073527+WeUaUK,localhost+080922073527+qxLjv1,0,1222068927,0,2,NULL,1
2,2,2,5,0,questionessay-17,What is the purpose of life?,0,,General feedback,1,0,essay,1,localhost+080922073527+pvCseX,localhost+080922073527+mzy6tY,0,1222068927,0,2,NULL,1
3,3,3,5,0,questionessay-6,What is the purpose of life?,0,,General feedback,1,0,essay,1,localhost+080922073527+Cr3gDO,localhost+080922073527+hnxfTy,0,1222068927,0,2,NULL,1
4,4,4,5,0,questionessay-8,What is the purpose of life?,0,,General feedback,1,0,essay,1,localhost+080922073527+sSq9ln,localhost+080922073527+PGyab3,0,1222068927,0,2,NULL,1
5,5,5,5,0,questionmatch-10,"test question, generated by script",0,,Well done,1,0.1,match,1,localhost+080922073527+oG1i2f,localhost+080922073527+S1UxZy,0,1222068927,0,2,NULL,0
6,6,6,5,0,questionmatch-16,"test question, generated by script",0,,Well done,1,0.1,match,1,localhost+080922073527+vMFHyY,localhost+080922073527+4GZIyQ,0,1222068927,0,2,NULL,0
7,7,7,5,0,questionmatch-18,"test question, generated by script",0,,Well done,1,0.1,match,1,localhost+080922073527+Xkxqn1,localhost+080922073527+xbU6U7,0,1222068927,0,2,NULL,0
8,8,8,5,0,questionmultianswer-12,This question consists of some text with an answer embedded right here {#1} and right after that you will have to deal with this short answer {#2} and finally we have a floating point number {#3}. Note that addresses like www.moodle.org and smileys :-) all work as normal: a) How good is this? {#4} b) What grade would you give it? {#5} Good luck!,0,,General feedback,8,0.1,multianswer,1,localhost+080922073527+0zKgpF,localhost+080922073527+r1gsde,0,1222068927,0,2,NULL,8
9,14,9,5,0,questionmultichoice-13,How old is the sun?,0,,General feedback,1,0.1,multichoice,1,localhost+080922073527+AjIjeV,localhost+080922073527+UhtTLR,0,1222068927,0,2,NULL,1
10,15,10,5,0,questionmultichoice-14,How old is the sun?,0,,General feedback,1,0.1,multichoice,1,localhost+080922073527+IrAqRl,localhost+080922073527+xRfta8,0,1222068927,0,2,NULL,1
11,16,11,5,0,questionmultichoice-3,How old is the sun?,0,,General feedback,1,0.1,multichoice,1,localhost+080922073527+DMGirU,localhost+080922073527+689V8k,0,1222068927,0,2,NULL,1
12,17,12,5,0,questionmultichoice-5,How old is the sun?,0,,General feedback,1,0.1,multichoice,1,localhost+080922073527+wileZw,localhost+080922073527+zGcaDa,0,1222068927,0,2,NULL,1
13,25,13,5,0,Random Short-Answer Matching,"<p>For each of the following questions, select the matching answer from the menu.</p>",1,,,1,0.1,randomsamatch,1,localhost+080922073724+qF803I,localhost+080922075820+zbZtaD,0,1222069044,1222070300,2,2,1
14,22,14,5,0,Is Thai difficult?,Is Thai difficult?,0,,,1,0.1,shortanswer,1,localhost+080922073655+2FLtCU,localhost+080922073655+fgUeOj,0,1222069015,0,2,NULL,1
15,23,15,5,0,Is Thai grammar difficult?,Is Thai grammar difficult?,0,,,1,0.1,shortanswer,1,localhost+080922073655+LYSD32,localhost+080922073655+WgRYk4,0,1222069015,0,2,NULL,1
16,24,16,5,0,Is Thai pronunciation difficult?,Is Thai pronunciation difficult?,0,,,1,0.1,shortanswer,1,localhost+080922073655+5p1w22,localhost+080922073655+g5jrXa,0,1222069015,0,2,NULL,1
17,20,17,5,0,Who's buried in Grant's tomb?,Who's buried in Grant's tomb?,0,,,1,0.1,shortanswer,1,localhost+080922073655+PTDcDZ,localhost+080922073655+aghyfu,0,1222069015,0,2,NULL,1
18,21,18,5,0,Who's buried in Jamie's tomb?,Who's buried in Jamie's tomb?,0,,,1,0.1,shortanswer,1,localhost+080922073655+Xvy1ns,localhost+080922073655+Mx0Izs,0,1222069015,0,2,NULL,1
19,18,19,5,0,questiontruefalse-7,This question is really stupid,0,,Well done,1,1,truefalse,1,localhost+080922073527+9bzTef,localhost+080922073527+hjcQR1,0,1222068927,0,2,NULL,1
20,19,20,5,0,questiontruefalse-9,This question is really stupid,0,,Well done,1,1,truefalse,1,localhost+080922073527+TI0yD4,localhost+080922073527+iXIulQ,0,1222068927,0,2,NULL,1
1 slot id number category parent name questiontext questiontextformat image generalfeedback defaultgrade penalty qtype length stamp version hidden timecreated timemodified createdby modifiedby maxmark
2 1 1 1 5 0 questionessay-11 What is the purpose of life? 0 General feedback 1 0 essay 1 localhost+080922073527+WeUaUK localhost+080922073527+qxLjv1 0 1222068927 0 2 NULL 1
3 2 2 2 5 0 questionessay-17 What is the purpose of life? 0 General feedback 1 0 essay 1 localhost+080922073527+pvCseX localhost+080922073527+mzy6tY 0 1222068927 0 2 NULL 1
4 3 3 3 5 0 questionessay-6 What is the purpose of life? 0 General feedback 1 0 essay 1 localhost+080922073527+Cr3gDO localhost+080922073527+hnxfTy 0 1222068927 0 2 NULL 1
5 4 4 4 5 0 questionessay-8 What is the purpose of life? 0 General feedback 1 0 essay 1 localhost+080922073527+sSq9ln localhost+080922073527+PGyab3 0 1222068927 0 2 NULL 1
6 5 5 5 5 0 questionmatch-10 test question, generated by script 0 Well done 1 0.1 match 1 localhost+080922073527+oG1i2f localhost+080922073527+S1UxZy 0 1222068927 0 2 NULL 0
7 6 6 6 5 0 questionmatch-16 test question, generated by script 0 Well done 1 0.1 match 1 localhost+080922073527+vMFHyY localhost+080922073527+4GZIyQ 0 1222068927 0 2 NULL 0
8 7 7 7 5 0 questionmatch-18 test question, generated by script 0 Well done 1 0.1 match 1 localhost+080922073527+Xkxqn1 localhost+080922073527+xbU6U7 0 1222068927 0 2 NULL 0
9 8 8 8 5 0 questionmultianswer-12 This question consists of some text with an answer embedded right here {#1} and right after that you will have to deal with this short answer {#2} and finally we have a floating point number {#3}. Note that addresses like www.moodle.org and smileys :-) all work as normal: a) How good is this? {#4} b) What grade would you give it? {#5} Good luck! 0 General feedback 8 0.1 multianswer 1 localhost+080922073527+0zKgpF localhost+080922073527+r1gsde 0 1222068927 0 2 NULL 8
10 9 14 9 5 0 questionmultichoice-13 How old is the sun? 0 General feedback 1 0.1 multichoice 1 localhost+080922073527+AjIjeV localhost+080922073527+UhtTLR 0 1222068927 0 2 NULL 1
11 10 15 10 5 0 questionmultichoice-14 How old is the sun? 0 General feedback 1 0.1 multichoice 1 localhost+080922073527+IrAqRl localhost+080922073527+xRfta8 0 1222068927 0 2 NULL 1
12 11 16 11 5 0 questionmultichoice-3 How old is the sun? 0 General feedback 1 0.1 multichoice 1 localhost+080922073527+DMGirU localhost+080922073527+689V8k 0 1222068927 0 2 NULL 1
13 12 17 12 5 0 questionmultichoice-5 How old is the sun? 0 General feedback 1 0.1 multichoice 1 localhost+080922073527+wileZw localhost+080922073527+zGcaDa 0 1222068927 0 2 NULL 1
14 13 25 13 5 0 Random Short-Answer Matching <p>For each of the following questions, select the matching answer from the menu.</p> 1 1 0.1 randomsamatch 1 localhost+080922073724+qF803I localhost+080922075820+zbZtaD 0 1222069044 1222070300 2 2 1
15 14 22 14 5 0 Is Thai difficult? Is Thai difficult? 0 1 0.1 shortanswer 1 localhost+080922073655+2FLtCU localhost+080922073655+fgUeOj 0 1222069015 0 2 NULL 1
16 15 23 15 5 0 Is Thai grammar difficult? Is Thai grammar difficult? 0 1 0.1 shortanswer 1 localhost+080922073655+LYSD32 localhost+080922073655+WgRYk4 0 1222069015 0 2 NULL 1
17 16 24 16 5 0 Is Thai pronunciation difficult? Is Thai pronunciation difficult? 0 1 0.1 shortanswer 1 localhost+080922073655+5p1w22 localhost+080922073655+g5jrXa 0 1222069015 0 2 NULL 1
18 17 20 17 5 0 Who's buried in Grant's tomb? Who's buried in Grant's tomb? 0 1 0.1 shortanswer 1 localhost+080922073655+PTDcDZ localhost+080922073655+aghyfu 0 1222069015 0 2 NULL 1
19 18 21 18 5 0 Who's buried in Jamie's tomb? Who's buried in Jamie's tomb? 0 1 0.1 shortanswer 1 localhost+080922073655+Xvy1ns localhost+080922073655+Mx0Izs 0 1222069015 0 2 NULL 1
20 19 18 19 5 0 questiontruefalse-7 This question is really stupid 0 Well done 1 1 truefalse 1 localhost+080922073527+9bzTef localhost+080922073527+hjcQR1 0 1222068927 0 2 NULL 1
21 20 19 20 5 0 questiontruefalse-9 This question is really stupid 0 Well done 1 1 truefalse 1 localhost+080922073527+TI0yD4 localhost+080922073527+iXIulQ 0 1222068927 0 2 NULL 1
@@ -0,0 +1,441 @@
id,sumgrades,questionid,slot,maxmark,mark
39872,12,1,1,1,0
39873,12,2,2,1,0
39874,12,3,3,1,0
39875,12,4,4,1,0
39896,12,5,5,0,0
39897,12,6,6,0,0
39898,12,7,7,0,0
39899,12,8,8,8,5.5
39900,12,14,9,1,0.3
39901,12,15,10,1,0.9
39902,12,16,11,1,1
39903,12,17,12,1,0.3
39910,12,18,19,1,0
39911,12,19,20,1,1
39908,12,20,17,1,1
39909,12,21,18,1,0
39905,12,22,14,1,0
39906,12,23,15,1,0
39907,12,24,16,1,1
39904,12,25,13,1,1
39992,7.4,1,1,1,0
39993,7.4,2,2,1,0
39994,7.4,3,3,1,0
39995,7.4,4,4,1,0
40016,7.4,5,5,0,0
40017,7.4,6,6,0,0
40018,7.4,7,7,0,0
40019,7.4,8,8,8,1
40020,7.4,14,9,1,0.9
40021,7.4,15,10,1,0.9
40022,7.4,16,11,1,0.3
40023,7.4,17,12,1,0.3
40030,7.4,18,19,1,0
40031,7.4,19,20,1,1
40028,7.4,20,17,1,0
40029,7.4,21,18,1,1
40025,7.4,22,14,1,0
40026,7.4,23,15,1,0
40027,7.4,24,16,1,1
40024,7.4,25,13,1,1
40032,11.7,1,1,1,0
40033,11.7,2,2,1,0
40034,11.7,3,3,1,0
40035,11.7,4,4,1,0
40056,11.7,5,5,0,0
40057,11.7,6,6,0,0
40058,11.7,7,7,0,0
40059,11.7,8,8,8,2.5
40060,11.7,14,9,1,1
40061,11.7,15,10,1,0.9
40062,11.7,16,11,1,0.3
40063,11.7,17,12,1,1
40070,11.7,18,19,1,1
40071,11.7,19,20,1,1
40068,11.7,20,17,1,1
40069,11.7,21,18,1,1
40065,11.7,22,14,1,0
40066,11.7,23,15,1,1
40067,11.7,24,16,1,1
40064,11.7,25,13,1,0
39352,8.5,1,1,1,0
39353,8.5,2,2,1,0
39354,8.5,3,3,1,0
39355,8.5,4,4,1,0
39376,8.5,5,5,0,0
39377,8.5,6,6,0,0
39378,8.5,7,7,0,0
39379,8.5,8,8,8,4
39380,8.5,14,9,1,0.3
39381,8.5,15,10,1,0.9
39382,8.5,16,11,1,1
39383,8.5,17,12,1,0.3
39390,8.5,18,19,1,0
39391,8.5,19,20,1,1
39388,8.5,20,17,1,1
39389,8.5,21,18,1,0
39385,8.5,22,14,1,0
39386,8.5,23,15,1,0
39387,8.5,24,16,1,0
39384,8.5,25,13,1,0
37112,10.1,1,1,1,0
37113,10.1,2,2,1,0
37114,10.1,3,3,1,0
37115,10.1,4,4,1,0
37136,10.1,5,5,0,0
37137,10.1,6,6,0,0
37138,10.1,7,7,0,0
37139,10.1,8,8,8,3
37140,10.1,14,9,1,0.9
37141,10.1,15,10,1,0.3
37142,10.1,16,11,1,0.9
37143,10.1,17,12,1,1
37150,10.1,18,19,1,1
37151,10.1,19,20,1,0
37148,10.1,20,17,1,1
37149,10.1,21,18,1,1
37145,10.1,22,14,1,1
37146,10.1,23,15,1,0
37147,10.1,24,16,1,0
37144,10.1,25,13,1,0
37432,11.3,1,1,1,0
37433,11.3,2,2,1,0
37434,11.3,3,3,1,0
37435,11.3,4,4,1,0
37456,11.3,5,5,0,0
37457,11.3,6,6,0,0
37458,11.3,7,7,0,0
37459,11.3,8,8,8,4.5
37460,11.3,14,9,1,0.9
37461,11.3,15,10,1,1
37462,11.3,16,11,1,1
37463,11.3,17,12,1,0.9
37470,11.3,18,19,1,0
37471,11.3,19,20,1,0
37468,11.3,20,17,1,0
37469,11.3,21,18,1,0
37465,11.3,22,14,1,1
37466,11.3,23,15,1,1
37467,11.3,24,16,1,1
37464,11.3,25,13,1,0
37472,11.2,1,1,1,0
37473,11.2,2,2,1,0
37474,11.2,3,3,1,0
37475,11.2,4,4,1,0
37496,11.2,5,5,0,0
37497,11.2,6,6,0,0
37498,11.2,7,7,0,0
37499,11.2,8,8,8,3
37500,11.2,14,9,1,0.3
37501,11.2,15,10,1,0.3
37502,11.2,16,11,1,0.3
37503,11.2,17,12,1,0.3
37510,11.2,18,19,1,1
37511,11.2,19,20,1,1
37508,11.2,20,17,1,1
37509,11.2,21,18,1,1
37505,11.2,22,14,1,0
37506,11.2,23,15,1,1
37507,11.2,24,16,1,1
37504,11.2,25,13,1,1
37632,14.1,1,1,1,0
37633,14.1,2,2,1,0
37634,14.1,3,3,1,0
37635,14.1,4,4,1,0
37656,14.1,5,5,0,0
37657,14.1,6,6,0,0
37658,14.1,7,7,0,0
37659,14.1,8,8,8,6
37660,14.1,14,9,1,0.9
37661,14.1,15,10,1,0.9
37662,14.1,16,11,1,1
37663,14.1,17,12,1,0.3
37670,14.1,18,19,1,0
37671,14.1,19,20,1,1
37668,14.1,20,17,1,1
37669,14.1,21,18,1,0
37665,14.1,22,14,1,1
37666,14.1,23,15,1,1
37667,14.1,24,16,1,1
37664,14.1,25,13,1,0
37672,8.6,1,1,1,0
37673,8.6,2,2,1,0
37674,8.6,3,3,1,0
37675,8.6,4,4,1,0
37696,8.6,5,5,0,0
37697,8.6,6,6,0,0
37698,8.6,7,7,0,0
37699,8.6,8,8,8,0.5
37700,8.6,14,9,1,0.9
37701,8.6,15,10,1,1
37702,8.6,16,11,1,0.9
37703,8.6,17,12,1,0.3
37710,8.6,18,19,1,0
37711,8.6,19,20,1,1
37708,8.6,20,17,1,1
37709,8.6,21,18,1,1
37705,8.6,22,14,1,1
37706,8.6,23,15,1,1
37707,8.6,24,16,1,0
37704,8.6,25,13,1,0
37712,11.6,1,1,1,0
37713,11.6,2,2,1,0
37714,11.6,3,3,1,0
37715,11.6,4,4,1,0
37736,11.6,5,5,0,0
37737,11.6,6,6,0,0
37738,11.6,7,7,0,0
37739,11.6,8,8,8,5.5
37740,11.6,14,9,1,0.9
37741,11.6,15,10,1,1
37742,11.6,16,11,1,0.9
37743,11.6,17,12,1,0.3
37750,11.6,18,19,1,0
37751,11.6,19,20,1,0
37748,11.6,20,17,1,1
37749,11.6,21,18,1,0
37745,11.6,22,14,1,1
37746,11.6,23,15,1,0
37747,11.6,24,16,1,0
37744,11.6,25,13,1,1
38072,9.3,1,1,1,0
38073,9.3,2,2,1,0
38074,9.3,3,3,1,0
38075,9.3,4,4,1,0
38096,9.3,5,5,0,0
38097,9.3,6,6,0,0
38098,9.3,7,7,0,0
38099,9.3,8,8,8,2.5
38100,9.3,14,9,1,0.9
38101,9.3,15,10,1,1
38102,9.3,16,11,1,1
38103,9.3,17,12,1,0.9
38110,9.3,18,19,1,0
38111,9.3,19,20,1,1
38108,9.3,20,17,1,1
38109,9.3,21,18,1,0
38105,9.3,22,14,1,1
38106,9.3,23,15,1,0
38107,9.3,24,16,1,0
38104,9.3,25,13,1,0
38232,13.1,1,1,1,0
38233,13.1,2,2,1,0
38234,13.1,3,3,1,0
38235,13.1,4,4,1,0
38256,13.1,5,5,0,0
38257,13.1,6,6,0,0
38258,13.1,7,7,0,0
38259,13.1,8,8,8,4
38260,13.1,14,9,1,0.9
38261,13.1,15,10,1,0.3
38262,13.1,16,11,1,0.9
38263,13.1,17,12,1,1
38270,13.1,18,19,1,0
38271,13.1,19,20,1,1
38268,13.1,20,17,1,1
38269,13.1,21,18,1,1
38265,13.1,22,14,1,1
38266,13.1,23,15,1,1
38267,13.1,24,16,1,1
38264,13.1,25,13,1,0
38272,11.5,1,1,1,0
38273,11.5,2,2,1,0
38274,11.5,3,3,1,0
38275,11.5,4,4,1,0
38296,11.5,5,5,0,0
38297,11.5,6,6,0,0
38298,11.5,7,7,0,0
38299,11.5,8,8,8,4
38300,11.5,14,9,1,0.9
38301,11.5,15,10,1,0.3
38302,11.5,16,11,1,0.3
38303,11.5,17,12,1,1
38310,11.5,18,19,1,1
38311,11.5,19,20,1,0
38308,11.5,20,17,1,0
38309,11.5,21,18,1,1
38305,11.5,22,14,1,1
38306,11.5,23,15,1,1
38307,11.5,24,16,1,0
38304,11.5,25,13,1,1
38472,11.3,1,1,1,0
38473,11.3,2,2,1,0
38474,11.3,3,3,1,0
38475,11.3,4,4,1,0
38496,11.3,5,5,0,0
38497,11.3,6,6,0,0
38498,11.3,7,7,0,0
38499,11.3,8,8,8,3
38500,11.3,14,9,1,1
38501,11.3,15,10,1,1
38502,11.3,16,11,1,0.3
38503,11.3,17,12,1,1
38510,11.3,18,19,1,1
38511,11.3,19,20,1,0
38508,11.3,20,17,1,1
38509,11.3,21,18,1,1
38505,11.3,22,14,1,1
38506,11.3,23,15,1,0
38507,11.3,24,16,1,1
38504,11.3,25,13,1,0
38632,5.5,1,1,1,0
38633,5.5,2,2,1,0
38634,5.5,3,3,1,0
38635,5.5,4,4,1,0
38656,5.5,5,5,0,0
38657,5.5,6,6,0,0
38658,5.5,7,7,0,0
38659,5.5,8,8,8,1
38660,5.5,14,9,1,1
38661,5.5,15,10,1,0.9
38662,5.5,16,11,1,0.3
38663,5.5,17,12,1,0.3
38670,5.5,18,19,1,0
38671,5.5,19,20,1,0
38668,5.5,20,17,1,0
38669,5.5,21,18,1,0
38665,5.5,22,14,1,0
38666,5.5,23,15,1,1
38667,5.5,24,16,1,0
38664,5.5,25,13,1,1
38672,4.8,1,1,1,0
38673,4.8,2,2,1,0
38674,4.8,3,3,1,0
38675,4.8,4,4,1,0
38696,4.8,5,5,0,0
38697,4.8,6,6,0,0
38698,4.8,7,7,0,0
38699,4.8,8,8,8,1
38700,4.8,14,9,1,0.3
38701,4.8,15,10,1,0.3
38702,4.8,16,11,1,0.3
38703,4.8,17,12,1,0.9
38710,4.8,18,19,1,0
38711,4.8,19,20,1,1
38708,4.8,20,17,1,0
38709,4.8,21,18,1,0
38705,4.8,22,14,1,0
38706,4.8,23,15,1,0
38707,4.8,24,16,1,1
38704,4.8,25,13,1,0
38992,8.7,1,1,1,0
38993,8.7,2,2,1,0
38994,8.7,3,3,1,0
38995,8.7,4,4,1,0
39016,8.7,5,5,0,0
39017,8.7,6,6,0,0
39018,8.7,7,7,0,0
39019,8.7,8,8,8,1.5
39020,8.7,14,9,1,1
39021,8.7,15,10,1,0.3
39022,8.7,16,11,1,0.9
39023,8.7,17,12,1,1
39030,8.7,18,19,1,0
39031,8.7,19,20,1,0
39028,8.7,20,17,1,1
39029,8.7,21,18,1,0
39025,8.7,22,14,1,1
39026,8.7,23,15,1,0
39027,8.7,24,16,1,1
39024,8.7,25,13,1,1
39032,11.8,1,1,1,0
39033,11.8,2,2,1,0
39034,11.8,3,3,1,0
39035,11.8,4,4,1,0
39056,11.8,5,5,0,0
39057,11.8,6,6,0,0
39058,11.8,7,7,0,0
39059,11.8,8,8,8,4
39060,11.8,14,9,1,0.9
39061,11.8,15,10,1,1
39062,11.8,16,11,1,0.9
39063,11.8,17,12,1,1
39070,11.8,18,19,1,0
39071,11.8,19,20,1,0
39068,11.8,20,17,1,0
39069,11.8,21,18,1,1
39065,11.8,22,14,1,1
39066,11.8,23,15,1,1
39067,11.8,24,16,1,1
39064,11.8,25,13,1,0
39272,6,1,1,1,0
39273,6,2,2,1,0
39274,6,3,3,1,0
39275,6,4,4,1,0
39296,6,5,5,0,0
39297,6,6,6,0,0
39298,6,7,7,0,0
39299,6,8,8,8,2
39300,6,14,9,1,0.9
39301,6,15,10,1,0.9
39302,6,16,11,1,0.3
39303,6,17,12,1,0.9
39310,6,18,19,1,0
39311,6,19,20,1,0
39308,6,20,17,1,0
39309,6,21,18,1,0
39305,6,22,14,1,1
39306,6,23,15,1,0
39307,6,24,16,1,0
39304,6,25,13,1,0
36192,5.9,1,1,1,0
36193,5.9,2,2,1,0
36194,5.9,3,3,1,0
36195,5.9,4,4,1,0
36216,5.9,5,5,0,0
36217,5.9,6,6,0,0
36218,5.9,7,7,0,0
36219,5.9,8,8,8,1
36220,5.9,14,9,1,1
36221,5.9,15,10,1,0.3
36222,5.9,16,11,1,0.3
36223,5.9,17,12,1,0.3
36230,5.9,18,19,1,0
36231,5.9,19,20,1,0
36228,5.9,20,17,1,1
36229,5.9,21,18,1,0
36225,5.9,22,14,1,1
36226,5.9,23,15,1,1
36227,5.9,24,16,1,0
36224,5.9,25,13,1,0
36352,12.8,1,1,1,0
36353,12.8,2,2,1,0
36354,12.8,3,3,1,0
36355,12.8,4,4,1,0
36376,12.8,5,5,0,0
36377,12.8,6,6,0,0
36378,12.8,7,7,0,0
36379,12.8,8,8,8,6
36380,12.8,14,9,1,0.9
36381,12.8,15,10,1,1
36382,12.8,16,11,1,1
36383,12.8,17,12,1,0.9
36390,12.8,18,19,1,1
36391,12.8,19,20,1,1
36388,12.8,20,17,1,0
36389,12.8,21,18,1,0
36385,12.8,22,14,1,0
36386,12.8,23,15,1,0
36387,12.8,24,16,1,1
36384,12.8,25,13,1,0
36832,13.8,1,1,1,0
36833,13.8,2,2,1,0
36834,13.8,3,3,1,0
36835,13.8,4,4,1,0
36856,13.8,5,5,0,0
36857,13.8,6,6,0,0
36858,13.8,7,7,0,0
36859,13.8,8,8,8,7
36860,13.8,14,9,1,0.9
36861,13.8,15,10,1,0.3
36862,13.8,16,11,1,0.3
36863,13.8,17,12,1,0.3
36870,13.8,18,19,1,0
36871,13.8,19,20,1,0
36868,13.8,20,17,1,1
36869,13.8,21,18,1,1
36865,13.8,22,14,1,0
36866,13.8,23,15,1,1
36867,13.8,24,16,1,1
36864,13.8,25,13,1,1
1 id sumgrades questionid slot maxmark mark
2 39872 12 1 1 1 0
3 39873 12 2 2 1 0
4 39874 12 3 3 1 0
5 39875 12 4 4 1 0
6 39896 12 5 5 0 0
7 39897 12 6 6 0 0
8 39898 12 7 7 0 0
9 39899 12 8 8 8 5.5
10 39900 12 14 9 1 0.3
11 39901 12 15 10 1 0.9
12 39902 12 16 11 1 1
13 39903 12 17 12 1 0.3
14 39910 12 18 19 1 0
15 39911 12 19 20 1 1
16 39908 12 20 17 1 1
17 39909 12 21 18 1 0
18 39905 12 22 14 1 0
19 39906 12 23 15 1 0
20 39907 12 24 16 1 1
21 39904 12 25 13 1 1
22 39992 7.4 1 1 1 0
23 39993 7.4 2 2 1 0
24 39994 7.4 3 3 1 0
25 39995 7.4 4 4 1 0
26 40016 7.4 5 5 0 0
27 40017 7.4 6 6 0 0
28 40018 7.4 7 7 0 0
29 40019 7.4 8 8 8 1
30 40020 7.4 14 9 1 0.9
31 40021 7.4 15 10 1 0.9
32 40022 7.4 16 11 1 0.3
33 40023 7.4 17 12 1 0.3
34 40030 7.4 18 19 1 0
35 40031 7.4 19 20 1 1
36 40028 7.4 20 17 1 0
37 40029 7.4 21 18 1 1
38 40025 7.4 22 14 1 0
39 40026 7.4 23 15 1 0
40 40027 7.4 24 16 1 1
41 40024 7.4 25 13 1 1
42 40032 11.7 1 1 1 0
43 40033 11.7 2 2 1 0
44 40034 11.7 3 3 1 0
45 40035 11.7 4 4 1 0
46 40056 11.7 5 5 0 0
47 40057 11.7 6 6 0 0
48 40058 11.7 7 7 0 0
49 40059 11.7 8 8 8 2.5
50 40060 11.7 14 9 1 1
51 40061 11.7 15 10 1 0.9
52 40062 11.7 16 11 1 0.3
53 40063 11.7 17 12 1 1
54 40070 11.7 18 19 1 1
55 40071 11.7 19 20 1 1
56 40068 11.7 20 17 1 1
57 40069 11.7 21 18 1 1
58 40065 11.7 22 14 1 0
59 40066 11.7 23 15 1 1
60 40067 11.7 24 16 1 1
61 40064 11.7 25 13 1 0
62 39352 8.5 1 1 1 0
63 39353 8.5 2 2 1 0
64 39354 8.5 3 3 1 0
65 39355 8.5 4 4 1 0
66 39376 8.5 5 5 0 0
67 39377 8.5 6 6 0 0
68 39378 8.5 7 7 0 0
69 39379 8.5 8 8 8 4
70 39380 8.5 14 9 1 0.3
71 39381 8.5 15 10 1 0.9
72 39382 8.5 16 11 1 1
73 39383 8.5 17 12 1 0.3
74 39390 8.5 18 19 1 0
75 39391 8.5 19 20 1 1
76 39388 8.5 20 17 1 1
77 39389 8.5 21 18 1 0
78 39385 8.5 22 14 1 0
79 39386 8.5 23 15 1 0
80 39387 8.5 24 16 1 0
81 39384 8.5 25 13 1 0
82 37112 10.1 1 1 1 0
83 37113 10.1 2 2 1 0
84 37114 10.1 3 3 1 0
85 37115 10.1 4 4 1 0
86 37136 10.1 5 5 0 0
87 37137 10.1 6 6 0 0
88 37138 10.1 7 7 0 0
89 37139 10.1 8 8 8 3
90 37140 10.1 14 9 1 0.9
91 37141 10.1 15 10 1 0.3
92 37142 10.1 16 11 1 0.9
93 37143 10.1 17 12 1 1
94 37150 10.1 18 19 1 1
95 37151 10.1 19 20 1 0
96 37148 10.1 20 17 1 1
97 37149 10.1 21 18 1 1
98 37145 10.1 22 14 1 1
99 37146 10.1 23 15 1 0
100 37147 10.1 24 16 1 0
101 37144 10.1 25 13 1 0
102 37432 11.3 1 1 1 0
103 37433 11.3 2 2 1 0
104 37434 11.3 3 3 1 0
105 37435 11.3 4 4 1 0
106 37456 11.3 5 5 0 0
107 37457 11.3 6 6 0 0
108 37458 11.3 7 7 0 0
109 37459 11.3 8 8 8 4.5
110 37460 11.3 14 9 1 0.9
111 37461 11.3 15 10 1 1
112 37462 11.3 16 11 1 1
113 37463 11.3 17 12 1 0.9
114 37470 11.3 18 19 1 0
115 37471 11.3 19 20 1 0
116 37468 11.3 20 17 1 0
117 37469 11.3 21 18 1 0
118 37465 11.3 22 14 1 1
119 37466 11.3 23 15 1 1
120 37467 11.3 24 16 1 1
121 37464 11.3 25 13 1 0
122 37472 11.2 1 1 1 0
123 37473 11.2 2 2 1 0
124 37474 11.2 3 3 1 0
125 37475 11.2 4 4 1 0
126 37496 11.2 5 5 0 0
127 37497 11.2 6 6 0 0
128 37498 11.2 7 7 0 0
129 37499 11.2 8 8 8 3
130 37500 11.2 14 9 1 0.3
131 37501 11.2 15 10 1 0.3
132 37502 11.2 16 11 1 0.3
133 37503 11.2 17 12 1 0.3
134 37510 11.2 18 19 1 1
135 37511 11.2 19 20 1 1
136 37508 11.2 20 17 1 1
137 37509 11.2 21 18 1 1
138 37505 11.2 22 14 1 0
139 37506 11.2 23 15 1 1
140 37507 11.2 24 16 1 1
141 37504 11.2 25 13 1 1
142 37632 14.1 1 1 1 0
143 37633 14.1 2 2 1 0
144 37634 14.1 3 3 1 0
145 37635 14.1 4 4 1 0
146 37656 14.1 5 5 0 0
147 37657 14.1 6 6 0 0
148 37658 14.1 7 7 0 0
149 37659 14.1 8 8 8 6
150 37660 14.1 14 9 1 0.9
151 37661 14.1 15 10 1 0.9
152 37662 14.1 16 11 1 1
153 37663 14.1 17 12 1 0.3
154 37670 14.1 18 19 1 0
155 37671 14.1 19 20 1 1
156 37668 14.1 20 17 1 1
157 37669 14.1 21 18 1 0
158 37665 14.1 22 14 1 1
159 37666 14.1 23 15 1 1
160 37667 14.1 24 16 1 1
161 37664 14.1 25 13 1 0
162 37672 8.6 1 1 1 0
163 37673 8.6 2 2 1 0
164 37674 8.6 3 3 1 0
165 37675 8.6 4 4 1 0
166 37696 8.6 5 5 0 0
167 37697 8.6 6 6 0 0
168 37698 8.6 7 7 0 0
169 37699 8.6 8 8 8 0.5
170 37700 8.6 14 9 1 0.9
171 37701 8.6 15 10 1 1
172 37702 8.6 16 11 1 0.9
173 37703 8.6 17 12 1 0.3
174 37710 8.6 18 19 1 0
175 37711 8.6 19 20 1 1
176 37708 8.6 20 17 1 1
177 37709 8.6 21 18 1 1
178 37705 8.6 22 14 1 1
179 37706 8.6 23 15 1 1
180 37707 8.6 24 16 1 0
181 37704 8.6 25 13 1 0
182 37712 11.6 1 1 1 0
183 37713 11.6 2 2 1 0
184 37714 11.6 3 3 1 0
185 37715 11.6 4 4 1 0
186 37736 11.6 5 5 0 0
187 37737 11.6 6 6 0 0
188 37738 11.6 7 7 0 0
189 37739 11.6 8 8 8 5.5
190 37740 11.6 14 9 1 0.9
191 37741 11.6 15 10 1 1
192 37742 11.6 16 11 1 0.9
193 37743 11.6 17 12 1 0.3
194 37750 11.6 18 19 1 0
195 37751 11.6 19 20 1 0
196 37748 11.6 20 17 1 1
197 37749 11.6 21 18 1 0
198 37745 11.6 22 14 1 1
199 37746 11.6 23 15 1 0
200 37747 11.6 24 16 1 0
201 37744 11.6 25 13 1 1
202 38072 9.3 1 1 1 0
203 38073 9.3 2 2 1 0
204 38074 9.3 3 3 1 0
205 38075 9.3 4 4 1 0
206 38096 9.3 5 5 0 0
207 38097 9.3 6 6 0 0
208 38098 9.3 7 7 0 0
209 38099 9.3 8 8 8 2.5
210 38100 9.3 14 9 1 0.9
211 38101 9.3 15 10 1 1
212 38102 9.3 16 11 1 1
213 38103 9.3 17 12 1 0.9
214 38110 9.3 18 19 1 0
215 38111 9.3 19 20 1 1
216 38108 9.3 20 17 1 1
217 38109 9.3 21 18 1 0
218 38105 9.3 22 14 1 1
219 38106 9.3 23 15 1 0
220 38107 9.3 24 16 1 0
221 38104 9.3 25 13 1 0
222 38232 13.1 1 1 1 0
223 38233 13.1 2 2 1 0
224 38234 13.1 3 3 1 0
225 38235 13.1 4 4 1 0
226 38256 13.1 5 5 0 0
227 38257 13.1 6 6 0 0
228 38258 13.1 7 7 0 0
229 38259 13.1 8 8 8 4
230 38260 13.1 14 9 1 0.9
231 38261 13.1 15 10 1 0.3
232 38262 13.1 16 11 1 0.9
233 38263 13.1 17 12 1 1
234 38270 13.1 18 19 1 0
235 38271 13.1 19 20 1 1
236 38268 13.1 20 17 1 1
237 38269 13.1 21 18 1 1
238 38265 13.1 22 14 1 1
239 38266 13.1 23 15 1 1
240 38267 13.1 24 16 1 1
241 38264 13.1 25 13 1 0
242 38272 11.5 1 1 1 0
243 38273 11.5 2 2 1 0
244 38274 11.5 3 3 1 0
245 38275 11.5 4 4 1 0
246 38296 11.5 5 5 0 0
247 38297 11.5 6 6 0 0
248 38298 11.5 7 7 0 0
249 38299 11.5 8 8 8 4
250 38300 11.5 14 9 1 0.9
251 38301 11.5 15 10 1 0.3
252 38302 11.5 16 11 1 0.3
253 38303 11.5 17 12 1 1
254 38310 11.5 18 19 1 1
255 38311 11.5 19 20 1 0
256 38308 11.5 20 17 1 0
257 38309 11.5 21 18 1 1
258 38305 11.5 22 14 1 1
259 38306 11.5 23 15 1 1
260 38307 11.5 24 16 1 0
261 38304 11.5 25 13 1 1
262 38472 11.3 1 1 1 0
263 38473 11.3 2 2 1 0
264 38474 11.3 3 3 1 0
265 38475 11.3 4 4 1 0
266 38496 11.3 5 5 0 0
267 38497 11.3 6 6 0 0
268 38498 11.3 7 7 0 0
269 38499 11.3 8 8 8 3
270 38500 11.3 14 9 1 1
271 38501 11.3 15 10 1 1
272 38502 11.3 16 11 1 0.3
273 38503 11.3 17 12 1 1
274 38510 11.3 18 19 1 1
275 38511 11.3 19 20 1 0
276 38508 11.3 20 17 1 1
277 38509 11.3 21 18 1 1
278 38505 11.3 22 14 1 1
279 38506 11.3 23 15 1 0
280 38507 11.3 24 16 1 1
281 38504 11.3 25 13 1 0
282 38632 5.5 1 1 1 0
283 38633 5.5 2 2 1 0
284 38634 5.5 3 3 1 0
285 38635 5.5 4 4 1 0
286 38656 5.5 5 5 0 0
287 38657 5.5 6 6 0 0
288 38658 5.5 7 7 0 0
289 38659 5.5 8 8 8 1
290 38660 5.5 14 9 1 1
291 38661 5.5 15 10 1 0.9
292 38662 5.5 16 11 1 0.3
293 38663 5.5 17 12 1 0.3
294 38670 5.5 18 19 1 0
295 38671 5.5 19 20 1 0
296 38668 5.5 20 17 1 0
297 38669 5.5 21 18 1 0
298 38665 5.5 22 14 1 0
299 38666 5.5 23 15 1 1
300 38667 5.5 24 16 1 0
301 38664 5.5 25 13 1 1
302 38672 4.8 1 1 1 0
303 38673 4.8 2 2 1 0
304 38674 4.8 3 3 1 0
305 38675 4.8 4 4 1 0
306 38696 4.8 5 5 0 0
307 38697 4.8 6 6 0 0
308 38698 4.8 7 7 0 0
309 38699 4.8 8 8 8 1
310 38700 4.8 14 9 1 0.3
311 38701 4.8 15 10 1 0.3
312 38702 4.8 16 11 1 0.3
313 38703 4.8 17 12 1 0.9
314 38710 4.8 18 19 1 0
315 38711 4.8 19 20 1 1
316 38708 4.8 20 17 1 0
317 38709 4.8 21 18 1 0
318 38705 4.8 22 14 1 0
319 38706 4.8 23 15 1 0
320 38707 4.8 24 16 1 1
321 38704 4.8 25 13 1 0
322 38992 8.7 1 1 1 0
323 38993 8.7 2 2 1 0
324 38994 8.7 3 3 1 0
325 38995 8.7 4 4 1 0
326 39016 8.7 5 5 0 0
327 39017 8.7 6 6 0 0
328 39018 8.7 7 7 0 0
329 39019 8.7 8 8 8 1.5
330 39020 8.7 14 9 1 1
331 39021 8.7 15 10 1 0.3
332 39022 8.7 16 11 1 0.9
333 39023 8.7 17 12 1 1
334 39030 8.7 18 19 1 0
335 39031 8.7 19 20 1 0
336 39028 8.7 20 17 1 1
337 39029 8.7 21 18 1 0
338 39025 8.7 22 14 1 1
339 39026 8.7 23 15 1 0
340 39027 8.7 24 16 1 1
341 39024 8.7 25 13 1 1
342 39032 11.8 1 1 1 0
343 39033 11.8 2 2 1 0
344 39034 11.8 3 3 1 0
345 39035 11.8 4 4 1 0
346 39056 11.8 5 5 0 0
347 39057 11.8 6 6 0 0
348 39058 11.8 7 7 0 0
349 39059 11.8 8 8 8 4
350 39060 11.8 14 9 1 0.9
351 39061 11.8 15 10 1 1
352 39062 11.8 16 11 1 0.9
353 39063 11.8 17 12 1 1
354 39070 11.8 18 19 1 0
355 39071 11.8 19 20 1 0
356 39068 11.8 20 17 1 0
357 39069 11.8 21 18 1 1
358 39065 11.8 22 14 1 1
359 39066 11.8 23 15 1 1
360 39067 11.8 24 16 1 1
361 39064 11.8 25 13 1 0
362 39272 6 1 1 1 0
363 39273 6 2 2 1 0
364 39274 6 3 3 1 0
365 39275 6 4 4 1 0
366 39296 6 5 5 0 0
367 39297 6 6 6 0 0
368 39298 6 7 7 0 0
369 39299 6 8 8 8 2
370 39300 6 14 9 1 0.9
371 39301 6 15 10 1 0.9
372 39302 6 16 11 1 0.3
373 39303 6 17 12 1 0.9
374 39310 6 18 19 1 0
375 39311 6 19 20 1 0
376 39308 6 20 17 1 0
377 39309 6 21 18 1 0
378 39305 6 22 14 1 1
379 39306 6 23 15 1 0
380 39307 6 24 16 1 0
381 39304 6 25 13 1 0
382 36192 5.9 1 1 1 0
383 36193 5.9 2 2 1 0
384 36194 5.9 3 3 1 0
385 36195 5.9 4 4 1 0
386 36216 5.9 5 5 0 0
387 36217 5.9 6 6 0 0
388 36218 5.9 7 7 0 0
389 36219 5.9 8 8 8 1
390 36220 5.9 14 9 1 1
391 36221 5.9 15 10 1 0.3
392 36222 5.9 16 11 1 0.3
393 36223 5.9 17 12 1 0.3
394 36230 5.9 18 19 1 0
395 36231 5.9 19 20 1 0
396 36228 5.9 20 17 1 1
397 36229 5.9 21 18 1 0
398 36225 5.9 22 14 1 1
399 36226 5.9 23 15 1 1
400 36227 5.9 24 16 1 0
401 36224 5.9 25 13 1 0
402 36352 12.8 1 1 1 0
403 36353 12.8 2 2 1 0
404 36354 12.8 3 3 1 0
405 36355 12.8 4 4 1 0
406 36376 12.8 5 5 0 0
407 36377 12.8 6 6 0 0
408 36378 12.8 7 7 0 0
409 36379 12.8 8 8 8 6
410 36380 12.8 14 9 1 0.9
411 36381 12.8 15 10 1 1
412 36382 12.8 16 11 1 1
413 36383 12.8 17 12 1 0.9
414 36390 12.8 18 19 1 1
415 36391 12.8 19 20 1 1
416 36388 12.8 20 17 1 0
417 36389 12.8 21 18 1 0
418 36385 12.8 22 14 1 0
419 36386 12.8 23 15 1 0
420 36387 12.8 24 16 1 1
421 36384 12.8 25 13 1 0
422 36832 13.8 1 1 1 0
423 36833 13.8 2 2 1 0
424 36834 13.8 3 3 1 0
425 36835 13.8 4 4 1 0
426 36856 13.8 5 5 0 0
427 36857 13.8 6 6 0 0
428 36858 13.8 7 7 0 0
429 36859 13.8 8 8 8 7
430 36860 13.8 14 9 1 0.9
431 36861 13.8 15 10 1 0.3
432 36862 13.8 16 11 1 0.3
433 36863 13.8 17 12 1 0.3
434 36870 13.8 18 19 1 0
435 36871 13.8 19 20 1 0
436 36868 13.8 20 17 1 1
437 36869 13.8 21 18 1 1
438 36865 13.8 22 14 1 0
439 36866 13.8 23 15 1 1
440 36867 13.8 24 16 1 1
441 36864 13.8 25 13 1 1
@@ -0,0 +1,154 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for (some of) mod/quiz/report/statistics/qstats.php.
*
* @package quiz
* @subpackage statistics
* @category phpunit
* @copyright 2008 Jamie Pratt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->dirroot . '/mod/quiz/report/statistics/qstats.php');
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
/**
* Test helper subclass of quiz_statistics_question_stats
*
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class testable_quiz_statistics_question_stats extends quiz_statistics_question_stats {
public function set_step_data($states) {
$this->lateststeps = $states;
}
protected function get_random_guess_score($questiondata) {
return 0;
}
}
/**
* Unit tests for (some of) quiz_statistics_question_stats.
*
* @copyright 2008 Jamie Pratt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quiz_statistics_question_stats_testcase extends basic_testcase {
/** @var qstats object created to test class. */
protected $qstats;
public function test_qstats() {
global $CFG;
// Data is taken from randomly generated attempts data generated by
// contrib/tools/generators/qagenerator/
$steps = $this->get_records_from_csv(__DIR__.'/fixtures/mdl_question_states.csv');
// Data is taken from questions mostly generated by
// contrib/tools/generators/generator.php
$questions = $this->get_records_from_csv(__DIR__.'/fixtures/mdl_question.csv');
$this->qstats = new testable_quiz_statistics_question_stats($questions, 22, 10045.45455);
$this->qstats->set_step_data($steps);
$this->qstats->compute_statistics();
// Values expected are taken from contrib/tools/quiz_tools/stats.xls
$facility = array(0, 0, 0, 0, null, null, null, 41.19318182, 81.36363636,
71.36363636, 65.45454545, 65.90909091, 36.36363636, 59.09090909, 50,
59.09090909, 63.63636364, 45.45454545, 27.27272727, 50);
$this->qstats_q_fields('facility', $facility, 100);
$sd = array(0, 0, 0, 0, null, null, null, 1912.733589, 251.2738111,
322.6312277, 333.4199022, 337.5811591, 492.3659639, 503.2362797,
511.7663157, 503.2362797, 492.3659639, 509.6471914, 455.8423058, 511.7663157);
$this->qstats_q_fields('sd', $sd, 1000);
$effectiveweight = array(0, 0, 0, 0, 0, 0, 0, 26.58464457, 3.368456046,
3.253955259, 7.584083694, 3.79658376, 3.183278505, 4.532356904,
7.78856243, 10.08351572, 8.381139345, 8.727645713, 7.946277111, 4.769500946);
$this->qstats_q_fields('effectiveweight', $effectiveweight);
$discriminationindex = array(null, null, null, null, null, null, null,
25.88327077, 1.170256965, -4.207816809, 28.16930644, -2.513606859,
-12.99017581, -8.900638238, 8.670004606, 29.63337745, 15.18945843,
16.21079629, 15.52451404, -8.396734802);
$this->qstats_q_fields('discriminationindex', $discriminationindex);
$discriminativeefficiency = array(null, null, null, null, null, null, null,
27.23492723, 1.382386552, -4.691171307, 31.12404354, -2.877487579,
-17.5074184, -10.27568922, 10.86956522, 34.58997279, 17.4790556,
20.14359793, 22.06477733, -10);
$this->qstats_q_fields('discriminativeefficiency', $discriminativeefficiency);
}
public function qstats_q_fields($fieldname, $values, $multiplier=1) {
foreach ($this->qstats->questions as $question) {
$value = array_shift($values);
if ($value !== null) {
$this->assertEquals($question->_stats->{$fieldname} * $multiplier,
$value, '', 1E-6);
} else {
$this->assertEquals($question->_stats->{$fieldname} * $multiplier, $value);
}
}
}
public function get_fields_from_csv($line) {
$line = trim($line);
$items = preg_split('!,!', $line);
while (list($key) = each($items)) {
if ($items[$key]!='') {
if ($start = ($items[$key]{0}=='"')) {
$items[$key] = substr($items[$key], 1);
while (!$end = ($items[$key]{strlen($items[$key])-1}=='"')) {
$item = $items[$key];
unset($items[$key]);
list($key) = each($items);
$items[$key] = $item . ',' . $items[$key];
}
$items[$key] = substr($items[$key], 0, strlen($items[$key])-1);
}
}
}
return $items;
}
public function get_records_from_csv($filename) {
$filecontents = file($filename, FILE_IGNORE_NEW_LINES);
$records = array();
$keys = $this->get_fields_from_csv(array_shift($filecontents));//first line is field names
while (null !== ($line = array_shift($filecontents))) {
$data = $this->get_fields_from_csv($line);
$arraykey = reset($data);
$object = new stdClass();
foreach ($keys as $key) {
$value = array_shift($data);
if ($value !== null) {
$object->{$key} = $value;
} else {
$object->{$key} = '';
}
}
$records[$arraykey] = $object;
}
return $records;
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for (some of) mod/quiz/report/reportlib.php
*
* @package mod
* @subpackage quiz
* @category phpunit
* @copyright 2008 Jamie Pratt [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); // Include the code to test
/**
* This class contains the test cases for the functions in reportlib.php.
*
* @copyright 2008 Jamie Pratt [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
class question_reportlib_testcase extends basic_testcase {
public function test_quiz_report_index_by_keys() {
$datum = array();
$object = new stdClass();
$object->qid = 3;
$object->aid = 101;
$object->response = '';
$object->grade = 3;
$datum[] = $object;
$indexed = quiz_report_index_by_keys($datum, array('aid', 'qid'));
$this->assertEquals($indexed[101][3]->qid, 3);
$this->assertEquals($indexed[101][3]->aid, 101);
$this->assertEquals($indexed[101][3]->response, '');
$this->assertEquals($indexed[101][3]->grade, 3);
$indexed = quiz_report_index_by_keys($datum, array('aid', 'qid'), false);
$this->assertEquals($indexed[101][3][0]->qid, 3);
$this->assertEquals($indexed[101][3][0]->aid, 101);
$this->assertEquals($indexed[101][3][0]->response, '');
$this->assertEquals($indexed[101][3][0]->grade, 3);
}
public function test_quiz_report_scale_summarks_as_percentage() {
$quiz = new stdClass();
$quiz->sumgrades = 10;
$quiz->decimalpoints = 2;
$this->assertEquals('12.34567%',
quiz_report_scale_summarks_as_percentage(1.234567, $quiz, false));
$this->assertEquals('12.35%',
quiz_report_scale_summarks_as_percentage(1.234567, $quiz, true));
$this->assertEquals('-',
quiz_report_scale_summarks_as_percentage('-', $quiz, true));
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for (some of) mod/quiz/editlib.php.
*
* @package mod_quiz
* @category phpunit
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/editlib.php');
/**
* Unit tests for (some of) mod/quiz/editlib.php.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_editlib_testcase extends basic_testcase {
public function test_quiz_move_question_up() {
$this->assertEquals(quiz_move_question_up('0', 123), '0');
$this->assertEquals(quiz_move_question_up('1,2,0', 1), '1,2,0');
$this->assertEquals(quiz_move_question_up('1,2,0', 0), '1,2,0');
$this->assertEquals(quiz_move_question_up('1,2,0', 2), '2,1,0');
$this->assertEquals(quiz_move_question_up('1,2,0,3,4,0', 3), '1,2,3,0,4,0');
$this->assertEquals(quiz_move_question_up('1,2,3,0,4,0', 4), '1,2,3,4,0,0');
}
public function test_quiz_move_question_down() {
$this->assertEquals(quiz_move_question_down('0', 123), '0');
$this->assertEquals(quiz_move_question_down('1,2,0', 2), '1,2,0');
$this->assertEquals(quiz_move_question_down('1,2,0', 0), '1,2,0');
$this->assertEquals(quiz_move_question_down('1,2,0', 1), '2,1,0');
$this->assertEquals(quiz_move_question_down('1,2,0,3,4,0', 2), '1,0,2,3,4,0');
$this->assertEquals(quiz_move_question_down('1,0,2,3,0,4,0', 1), '0,1,2,3,0,4,0');
}
public function test_quiz_delete_empty_page() {
$this->assertEquals(quiz_delete_empty_page('0', 0), '0');
$this->assertEquals(quiz_delete_empty_page('1,2,0', 2), '1,2,0');
$this->assertEquals(quiz_delete_empty_page('0,1,2,0', -1), '1,2,0');
$this->assertEquals(quiz_delete_empty_page('0,1,2,0', 0), '0,1,2,0');
$this->assertEquals(quiz_delete_empty_page('1,2,0', 3), '1,2,0');
$this->assertEquals(quiz_delete_empty_page('1,2,0', -1), '1,2,0');
$this->assertEquals(quiz_delete_empty_page('1,2,0,0', 2), '1,2,0');
$this->assertEquals(quiz_delete_empty_page('1,2,0,0', 1), '1,2,0,0');
$this->assertEquals(quiz_delete_empty_page('1,2,0,0,3,4,0', 2), '1,2,0,3,4,0');
$this->assertEquals(quiz_delete_empty_page('0,0,1,2,0', 0), '0,1,2,0');
}
public function test_quiz_add_page_break_after() {
$this->assertEquals(quiz_add_page_break_after('0', 1), '0');
$this->assertEquals(quiz_add_page_break_after('1,2,0', 1), '1,0,2,0');
$this->assertEquals(quiz_add_page_break_after('1,2,0', 2), '1,2,0,0');
$this->assertEquals(quiz_add_page_break_after('1,2,0', 0), '1,2,0');
}
public function test_quiz_add_page_break_at() {
$this->assertEquals(quiz_add_page_break_at('0', 0), '0,0');
$this->assertEquals(quiz_add_page_break_at('1,2,0', 0), '0,1,2,0');
$this->assertEquals(quiz_add_page_break_at('1,2,0', 1), '1,0,2,0');
$this->assertEquals(quiz_add_page_break_at('1,2,0', 2), '1,2,0,0');
$this->assertEquals(quiz_add_page_break_at('1,2,0', 3), '1,2,0');
}
}
+78
View File
@@ -0,0 +1,78 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for (some of) mod/quiz/locallib.php.
*
* @package mod_quiz
* @category phpunit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/lib.php');
/**
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
class mod_quiz_lib_testcase extends basic_testcase {
public function test_quiz_has_grades() {
$quiz = new stdClass();
$quiz->grade = '100.0000';
$quiz->sumgrades = '100.0000';
$this->assertTrue(quiz_has_grades($quiz));
$quiz->sumgrades = '0.0000';
$this->assertFalse(quiz_has_grades($quiz));
$quiz->grade = '0.0000';
$this->assertFalse(quiz_has_grades($quiz));
$quiz->sumgrades = '100.0000';
$this->assertFalse(quiz_has_grades($quiz));
}
public function test_quiz_format_grade() {
$quiz = new stdClass();
$quiz->decimalpoints = 2;
$this->assertEquals(quiz_format_grade($quiz, 0.12345678), format_float(0.12, 2));
$this->assertEquals(quiz_format_grade($quiz, 0), format_float(0, 2));
$this->assertEquals(quiz_format_grade($quiz, 1.000000000000), format_float(1, 2));
$quiz->decimalpoints = 0;
$this->assertEquals(quiz_format_grade($quiz, 0.12345678), '0');
}
public function test_quiz_format_question_grade() {
$quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = 2;
$this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.12, 2));
$this->assertEquals(quiz_format_question_grade($quiz, 0), format_float(0, 2));
$this->assertEquals(quiz_format_question_grade($quiz, 1.000000000000), format_float(1, 2));
$quiz->decimalpoints = 3;
$quiz->questiondecimalpoints = -1;
$this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.123, 3));
$this->assertEquals(quiz_format_question_grade($quiz, 0), format_float(0, 3));
$this->assertEquals(quiz_format_question_grade($quiz, 1.000000000000), format_float(1, 3));
$quiz->questiondecimalpoints = 4;
$this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.1235, 4));
$this->assertEquals(quiz_format_question_grade($quiz, 0), format_float(0, 4));
$this->assertEquals(quiz_format_question_grade($quiz, 1.000000000000), format_float(1, 4));
}
}
+154
View File
@@ -0,0 +1,154 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for (some of) mod/quiz/locallib.php.
*
* @package mod_quiz
* @category phpunit
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
/**
* Unit tests for (some of) mod/quiz/locallib.php.
*
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_locallib_testcase extends basic_testcase {
public function test_quiz_questions_in_quiz() {
$this->assertEquals(quiz_questions_in_quiz(''), '');
$this->assertEquals(quiz_questions_in_quiz('0'), '');
$this->assertEquals(quiz_questions_in_quiz('0,0'), '');
$this->assertEquals(quiz_questions_in_quiz('0,0,0'), '');
$this->assertEquals(quiz_questions_in_quiz('1'), '1');
$this->assertEquals(quiz_questions_in_quiz('1,2'), '1,2');
$this->assertEquals(quiz_questions_in_quiz('1,0,2'), '1,2');
$this->assertEquals(quiz_questions_in_quiz('0,1,0,0,2,0'), '1,2');
}
public function test_quiz_number_of_pages() {
$this->assertEquals(quiz_number_of_pages('0'), 1);
$this->assertEquals(quiz_number_of_pages('0,0'), 2);
$this->assertEquals(quiz_number_of_pages('0,0,0'), 3);
$this->assertEquals(quiz_number_of_pages('1,0'), 1);
$this->assertEquals(quiz_number_of_pages('1,2,0'), 1);
$this->assertEquals(quiz_number_of_pages('1,0,2,0'), 2);
$this->assertEquals(quiz_number_of_pages('1,2,3,0'), 1);
$this->assertEquals(quiz_number_of_pages('1,2,3,0'), 1);
$this->assertEquals(quiz_number_of_pages('0,1,0,0,2,0'), 4);
}
public function test_quiz_number_of_questions_in_quiz() {
$this->assertEquals(quiz_number_of_questions_in_quiz('0'), 0);
$this->assertEquals(quiz_number_of_questions_in_quiz('0,0'), 0);
$this->assertEquals(quiz_number_of_questions_in_quiz('0,0,0'), 0);
$this->assertEquals(quiz_number_of_questions_in_quiz('1,0'), 1);
$this->assertEquals(quiz_number_of_questions_in_quiz('1,2,0'), 2);
$this->assertEquals(quiz_number_of_questions_in_quiz('1,0,2,0'), 2);
$this->assertEquals(quiz_number_of_questions_in_quiz('1,2,3,0'), 3);
$this->assertEquals(quiz_number_of_questions_in_quiz('1,2,3,0'), 3);
$this->assertEquals(quiz_number_of_questions_in_quiz('0,1,0,0,2,0'), 2);
$this->assertEquals(quiz_number_of_questions_in_quiz('10,,0,0'), 1);
}
public function test_quiz_clean_layout() {
// Without stripping empty pages.
$this->assertEquals(quiz_clean_layout(',,1,,,2,,'), '1,2,0');
$this->assertEquals(quiz_clean_layout(''), '0');
$this->assertEquals(quiz_clean_layout('0'), '0');
$this->assertEquals(quiz_clean_layout('0,0'), '0,0');
$this->assertEquals(quiz_clean_layout('0,0,0'), '0,0,0');
$this->assertEquals(quiz_clean_layout('1'), '1,0');
$this->assertEquals(quiz_clean_layout('1,2'), '1,2,0');
$this->assertEquals(quiz_clean_layout('1,0,2'), '1,0,2,0');
$this->assertEquals(quiz_clean_layout('0,1,0,0,2,0'), '0,1,0,0,2,0');
// With stripping empty pages.
$this->assertEquals(quiz_clean_layout('', true), '0');
$this->assertEquals(quiz_clean_layout('0', true), '0');
$this->assertEquals(quiz_clean_layout('0,0', true), '0');
$this->assertEquals(quiz_clean_layout('0,0,0', true), '0');
$this->assertEquals(quiz_clean_layout('1', true), '1,0');
$this->assertEquals(quiz_clean_layout('1,2', true), '1,2,0');
$this->assertEquals(quiz_clean_layout('1,0,2', true), '1,0,2,0');
$this->assertEquals(quiz_clean_layout('0,1,0,0,2,0', true), '1,0,2,0');
}
public function test_quiz_repaginate() {
// Test starting with 1 question per page.
$this->assertEquals(quiz_repaginate('1,0,2,0,3,0', 0), '1,2,3,0');
$this->assertEquals(quiz_repaginate('1,0,2,0,3,0', 3), '1,2,3,0');
$this->assertEquals(quiz_repaginate('1,0,2,0,3,0', 2), '1,2,0,3,0');
$this->assertEquals(quiz_repaginate('1,0,2,0,3,0', 1), '1,0,2,0,3,0');
// Test starting with all on one page page.
$this->assertEquals(quiz_repaginate('1,2,3,0', 0), '1,2,3,0');
$this->assertEquals(quiz_repaginate('1,2,3,0', 3), '1,2,3,0');
$this->assertEquals(quiz_repaginate('1,2,3,0', 2), '1,2,0,3,0');
$this->assertEquals(quiz_repaginate('1,2,3,0', 1), '1,0,2,0,3,0');
// Test single question case.
$this->assertEquals(quiz_repaginate('100,0', 0), '100,0');
$this->assertEquals(quiz_repaginate('100,0', 1), '100,0');
// No questions case.
$this->assertEquals(quiz_repaginate('0', 0), '0');
// Test empty pages are removed.
$this->assertEquals(quiz_repaginate('1,2,3,0,0,0', 0), '1,2,3,0');
$this->assertEquals(quiz_repaginate('1,0,0,0,2,3,0', 0), '1,2,3,0');
$this->assertEquals(quiz_repaginate('0,0,0,1,2,3,0', 0), '1,2,3,0');
// Test shuffle option.
$this->assertTrue(in_array(quiz_repaginate('1,2,0', 0, true),
array('1,2,0', '2,1,0')));
$this->assertTrue(in_array(quiz_repaginate('1,2,0', 1, true),
array('1,0,2,0', '2,0,1,0')));
}
public function test_quiz_rescale_grade() {
$quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = 3;
$quiz->grade = 10;
$quiz->sumgrades = 10;
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, false), 0.12345678);
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.12, 2));
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, 'question'),
format_float(0.123, 3));
$quiz->sumgrades = 5;
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, false), 0.24691356);
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.25, 2));
$this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, 'question'),
format_float(0.247, 3));
}
public function test_quiz_get_slot_for_question() {
$quiz = new stdClass();
$quiz->questions = '1,2,0,7,0';
$this->assertEquals(1, quiz_get_slot_for_question($quiz, 1));
$this->assertEquals(3, quiz_get_slot_for_question($quiz, 7));
}
}
@@ -0,0 +1,81 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the mod_quiz_display_options class.
*
* @package mod_quiz
* @category phpunit
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
/**
* Unit tests for {@link mod_quiz_display_options}.
*
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_display_options_testcase extends basic_testcase {
public function test_num_attempts_access_rule() {
$quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = -1;
$quiz->reviewattempt = 0x11110;
$quiz->reviewcorrectness = 0x10000;
$quiz->reviewmarks = 0x01110;
$quiz->reviewspecificfeedback = 0x10000;
$quiz->reviewgeneralfeedback = 0x01000;
$quiz->reviewrightanswer = 0x00100;
$quiz->reviewoverallfeedback = 0x00010;
$options = mod_quiz_display_options::make_from_quiz($quiz,
mod_quiz_display_options::DURING);
$this->assertEquals(true, $options->attempt);
$this->assertEquals(mod_quiz_display_options::VISIBLE, $options->correctness);
$this->assertEquals(mod_quiz_display_options::MAX_ONLY, $options->marks);
$this->assertEquals(2, $options->markdp);
$quiz->questiondecimalpoints = 5;
$options = mod_quiz_display_options::make_from_quiz($quiz,
mod_quiz_display_options::IMMEDIATELY_AFTER);
$this->assertEquals(mod_quiz_display_options::MARK_AND_MAX, $options->marks);
$this->assertEquals(mod_quiz_display_options::VISIBLE, $options->generalfeedback);
$this->assertEquals(mod_quiz_display_options::HIDDEN, $options->feedback);
$this->assertEquals(5, $options->markdp);
$options = mod_quiz_display_options::make_from_quiz($quiz,
mod_quiz_display_options::LATER_WHILE_OPEN);
$this->assertEquals(mod_quiz_display_options::VISIBLE, $options->rightanswer);
$this->assertEquals(mod_quiz_display_options::HIDDEN, $options->generalfeedback);
$options = mod_quiz_display_options::make_from_quiz($quiz,
mod_quiz_display_options::AFTER_CLOSE);
$this->assertEquals(mod_quiz_display_options::VISIBLE, $options->overallfeedback);
$this->assertEquals(mod_quiz_display_options::HIDDEN, $options->rightanswer);
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the quiz class.
*
* @package mod
* @subpackage quiz
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
/**
* Unit tests for the quiz class
*
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_class_testcase extends basic_testcase {
public function test_cannot_review_message() {
$quiz = new stdClass();
$quiz->reviewattempt = 0x10010;
$quiz->timeclose = 0;
$quiz->attempts = 0;
$quiz->questions = '1,2,0,3,4,0';
$cm = new stdClass();
$cm->id = 123;
$quizobj = new quiz($quiz, $cm, new stdClass(), false);
$this->assertEquals('',
$quizobj->cannot_review_message(mod_quiz_display_options::DURING));
$this->assertEquals('',
$quizobj->cannot_review_message(mod_quiz_display_options::IMMEDIATELY_AFTER));
$this->assertEquals(get_string('noreview', 'quiz'),
$quizobj->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN));
$this->assertEquals(get_string('noreview', 'quiz'),
$quizobj->cannot_review_message(mod_quiz_display_options::AFTER_CLOSE));
$closetime = time() + 10000;
$quiz->timeclose = $closetime;
$quizobj = new quiz($quiz, $cm, new stdClass(), false);
$this->assertEquals(get_string('noreviewuntil', 'quiz', userdate($closetime)),
$quizobj->cannot_review_message(mod_quiz_display_options::LATER_WHILE_OPEN));
}
public function test_empty_quiz() {
$quiz = new stdClass();
$quiz->reviewattempt = 0x10010;
$quiz->timeclose = 0;
$quiz->attempts = 0;
$quiz->questions = '0';
$cm = new stdClass();
$cm->id = 123;
$quizobj = new quiz($quiz, $cm, new stdClass(), false);
$this->assertFalse($quizobj->has_questions());
}
}