MDL-32149 add quiz unit tests
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user