1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-11 11:23:52 +02:00

MDL-11312 Added new grade_letters table, and new grade_items.display field.

This commit is contained in:
nicolasconnault 2007-09-18 14:26:15 +00:00
parent ad2cd664d7
commit e480c18cf1
6 changed files with 293 additions and 30 deletions

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20070906" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20070918" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@ -1326,8 +1326,9 @@
<FIELD NAME="multfactor" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="1.0" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="Multiply all grades by this" PREVIOUS="gradepass" NEXT="plusfactor"/>
<FIELD NAME="plusfactor" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="Add this to all grades" PREVIOUS="multfactor" NEXT="aggregationcoef"/>
<FIELD NAME="aggregationcoef" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="Aggregation coefficient used for category weights or other aggregation types" PREVIOUS="plusfactor" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Sorting order of the columns" PREVIOUS="aggregationcoef" NEXT="hidden"/>
<FIELD NAME="hidden" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="1 is hidden, &amp;gt; 1 is a date to hide until (prevents viewing)" PREVIOUS="sortorder" NEXT="locked"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Sorting order of the columns" PREVIOUS="aggregationcoef" NEXT="display"/>
<FIELD NAME="display" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="-1" SEQUENCE="false" ENUM="false" COMMENT="Display as real grades, percentages (in reference to the minimum and maximum grades) or letters (A, B, C etc..), or course default (-1)" PREVIOUS="sortorder" NEXT="hidden"/>
<FIELD NAME="hidden" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="1 is hidden, &amp;gt; 1 is a date to hide until (prevents viewing)" PREVIOUS="display" NEXT="locked"/>
<FIELD NAME="locked" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="1 is locked, &amp;gt; 1 is a date to lock until (prevents update)" PREVIOUS="hidden" NEXT="locktime"/>
<FIELD NAME="locktime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="lock all final grades after this date" PREVIOUS="locked" NEXT="needsupdate"/>
<FIELD NAME="needsupdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="If this flag is set, then the whole column will be recalculated" PREVIOUS="locktime" NEXT="timecreated"/>
@ -1693,7 +1694,7 @@
<KEY NAME="groupid" TYPE="foreign" FIELDS="groupid" REFTABLE="groups" REFFIELDS="id" PREVIOUS="groupingid"/>
</KEYS>
</TABLE>
<TABLE NAME="user_private_key" COMMENT="access keys used in cookieless scripts - rss, etc." PREVIOUS="groupings_groups">
<TABLE NAME="user_private_key" COMMENT="access keys used in cookieless scripts - rss, etc." PREVIOUS="groupings_groups" NEXT="grade_letters">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="script"/>
<FIELD NAME="script" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="plugin, module - unique identifier" PREVIOUS="id" NEXT="value"/>
@ -1712,6 +1713,17 @@
<INDEX NAME="script-value" UNIQUE="false" FIELDS="script, value" COMMENT="index used for key validation"/>
</INDEXES>
</TABLE>
<TABLE NAME="grade_letters" COMMENT="Repository for grade letters, for courses and other moodle entities that use grades." PREVIOUS="user_private_key">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="contextid"/>
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="What contextid does this letter apply to (for now these will always be courses, but later...)" PREVIOUS="id" NEXT="lowerboundary"/>
<FIELD NAME="lowerboundary" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="The lower boundary of the letter. Its upper boundary is the lower boundary of the next highest letter, unless there is none above, in which case it's grademax for that grade_item." PREVIOUS="contextid" NEXT="letter"/>
<FIELD NAME="letter" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The display value of the letter. Can be any character or string of characters (OK, A, 10% etc..)" PREVIOUS="lowerboundary"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
</KEYS>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">

@ -1434,8 +1434,8 @@ function xmldb_main_upgrade($oldversion=0) {
$table->addKeyInfo('outcomeid', XMLDB_KEY_FOREIGN, array('outcomeid'), 'grade_outcomes', array('id'));
$table->addKeyInfo('courseid-outcomeid', XMLDB_KEY_UNIQUE, array('courseid', 'outcomeid'));
/// Launch create table for grade_outcomes_courses
$result = $result && create_table($table);
$result = $result && create_table($table);
}
@ -1736,12 +1736,12 @@ function xmldb_main_upgrade($oldversion=0) {
/// Define field ordering to be added to tag_instance table
$table = new XMLDBTable('tag_instance');
$field = new XMLDBField('ordering');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'itemid');
/// Launch add field rawname
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2007082700) {
@ -1753,10 +1753,10 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add field timemodified
$result = $result && add_field($table, $field);
}
/// migrate all tags table to tag
if ($result && $oldversion < 2007082701) {
require_once($CFG->dirroot.'/tag/lib.php');
require_once($CFG->dirroot.'/tag/lib.php');
$tagrefs = array(); // $tagrefs[$oldtagid] = $newtagid
if ($tags = get_records('tags')) {
foreach ($tags as $oldtag) {
@ -1783,7 +1783,7 @@ function xmldb_main_upgrade($oldversion=0) {
}
}
}
// fetch all the tag instances and migrate them as well
if ($blogtags = get_records('blog_tag_instance')) {
foreach ($blogtags as $blogtag) {
@ -1798,7 +1798,7 @@ function xmldb_main_upgrade($oldversion=0) {
$table = new XMLDBTable('blog_tag_instance');
drop_table($table);
}
/// MDL-11015, MDL-11016
if ($result && $oldversion < 2007082800) {
@ -1809,7 +1809,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch change of type for field userid
$result = $result && change_field_type($table, $field);
/// Changing type of field descriptionformat on table tag to int
$table = new XMLDBTable('tag');
$field = new XMLDBField('descriptionformat');
@ -1817,7 +1817,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch change of type for field descriptionformat
$result = $result && change_field_type($table, $field);
/// Define key userid (foreign) to be added to tag
$table = new XMLDBTable('tag');
$key = new XMLDBKey('userid');
@ -1825,7 +1825,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add key userid
$result = $result && add_key($table, $key);
/// Define index tagiditem (unique) to be dropped form tag_instance
$table = new XMLDBTable('tag_instance');
$index = new XMLDBIndex('tagiditem');
@ -1833,7 +1833,7 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch drop index tagiditem
$result = $result && drop_index($table, $index);
/// Changing type of field tagid on table tag_instance to int
$table = new XMLDBTable('tag_instance');
$field = new XMLDBField('tagid');
@ -1841,14 +1841,14 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch change of type for field tagid
$result = $result && change_field_type($table, $field);
/// Define key tagid (foreign) to be added to tag_instance
$table = new XMLDBTable('tag_instance');
$key = new XMLDBKey('tagid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('tagid'), 'tag', array('id'));
/// Launch add key tagid
$result = $result && add_key($table, $key);
$result = $result && add_key($table, $key);
/// Changing sign of field itemid on table tag_instance to unsigned
$table = new XMLDBTable('tag_instance');
@ -1857,15 +1857,15 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch change of sign for field itemid
$result = $result && change_field_unsigned($table, $field);
/// Changing sign of field ordering on table tag_instance to unsigned
$table = new XMLDBTable('tag_instance');
$field = new XMLDBField('ordering');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'itemid');
/// Launch change of sign for field ordering
$result = $result && change_field_unsigned($table, $field);
$result = $result && change_field_unsigned($table, $field);
/// Define index itemtype-itemid-tagid (unique) to be added to tag_instance
$table = new XMLDBTable('tag_instance');
$index = new XMLDBIndex('itemtype-itemid-tagid');
@ -1873,15 +1873,15 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add index itemtype-itemid-tagid
$result = $result && add_index($table, $index);
/// Define index tagid (unique) to be dropped form tag_correlation
$table = new XMLDBTable('tag_correlation');
$index = new XMLDBIndex('tagid');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('tagid'));
/// Launch drop index tagid
$result = $result && drop_index($table, $index);
$result = $result && drop_index($table, $index);
/// Changing type of field tagid on table tag_correlation to int
$table = new XMLDBTable('tag_correlation');
$field = new XMLDBField('tagid');
@ -1889,8 +1889,8 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch change of type for field tagid
$result = $result && change_field_type($table, $field);
/// Define key tagid (foreign) to be added to tag_correlation
$table = new XMLDBTable('tag_correlation');
$key = new XMLDBKey('tagid');
@ -1898,8 +1898,8 @@ function xmldb_main_upgrade($oldversion=0) {
/// Launch add key tagid
$result = $result && add_key($table, $key);
}
}
if ($result && $oldversion < 2007082801) {
@ -2064,6 +2064,35 @@ function xmldb_main_upgrade($oldversion=0) {
}
if ($result && $oldversion < 2007091800) {
/// Define field display to be added to grade_items
$table = new XMLDBTable('grade_items');
$field = new XMLDBField('display');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '-1', 'sortorder');
/// Launch add field display
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2007091800) {
/// Define table grade_letters to be created
$table = new XMLDBTable('grade_letters');
/// Adding fields to table grade_letters
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('lowerboundary', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('letter', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table grade_letters
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Launch create table for grade_letters
$result = $result && create_table($table);
}
/*
/// drop old gradebook tables

@ -198,6 +198,12 @@ class grade_item extends grade_object {
*/
var $sortorder = 0;
/**
* Display type of the grades (Real, Percentage, Letter, or default).
* @var int $display
*/
var $display = null;
/**
* 0 if visible, 1 always hidden or date not visible until
* @var int $hidden

@ -171,7 +171,7 @@ class grade_category_test extends grade_test {
$id = $grade_category->insert_course_category($this->courseid);
$this->assertNotNull($id);
$this->assertEqual('course grade category', $grade_category->fullname);
$this->assertEqual('Course grade category', $grade_category->fullname);
$this->assertEqual(GRADE_AGGREGATE_MEAN, $grade_category->aggregate);
$this->assertEqual("/$id/", $grade_category->path);
$this->assertEqual(1, $grade_category->depth);

@ -65,6 +65,7 @@ class grade_test extends UnitTestCase {
var $grade_outcomes = array();
var $scale = array();
var $activities = array();
var $courseid = 1;
var $userid = 1;
@ -74,7 +75,15 @@ class grade_test extends UnitTestCase {
* Override $CFG->prefix while these tests run.
*/
function setUp() {
// Set global category settings to -1 (not force)
global $CFG;
$CFG->grade_droplow = -1;
$CFG->grade_keephigh = -1;
$CFG->grade_aggregation = -1;
$CFG->grade_aggregateonlygraded = -1;
$CFG->grade_aggregateoutcomes = -1;
$CFG->grade_aggregatesubcats = -1;
$CFG->old_prefix = $CFG->prefix;
$CFG->prefix .= 'unittest_';
if (!$this->prepare_test_tables()) {
@ -94,6 +103,69 @@ class grade_test extends UnitTestCase {
function prepare_test_tables() {
$result = true;
/// Define table course_modules to be created
$table = new XMLDBTable('course_modules');
if (!table_exists($table)) {
/// Adding fields to table course_modules
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('module', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('section', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('idnumber', XMLDB_TYPE_CHAR, '100', XMLDB_UNSIGNED, null, null, null, null, null);
$table->addFieldInfo('added', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('score', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('indent', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('visible', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('visibleold', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('groupmode', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('groupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('groupmembersonly', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table course_modules
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('groupingid', XMLDB_KEY_FOREIGN, array('groupingid'), 'groupings', array('id'));
/// Adding indexes to table course_modules
$table->addIndexInfo('visible', XMLDB_INDEX_NOTUNIQUE, array('visible'));
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
$table->addIndexInfo('module', XMLDB_INDEX_NOTUNIQUE, array('module'));
$table->addIndexInfo('instance', XMLDB_INDEX_NOTUNIQUE, array('instance'));
$table->addIndexInfo('idnumber-course', XMLDB_INDEX_NOTUNIQUE, array('idnumber', 'course'));
/// Launch create table for course_modules
$result = $result && create_table($table, true, false);
} else {
delete_records($table->name);
}
/// Define table modules to be created
$table = new XMLDBTable('modules');
if (!table_exists($table)) {
/// Adding fields to table modules
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('version', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('cron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('lastcron', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('search', XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('visible', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
/// Adding keys to table modules
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table modules
$table->addIndexInfo('name', XMLDB_INDEX_NOTUNIQUE, array('name'));
/// Launch create table for modules
$result = $result && create_table($table, true, false);
} else {
delete_records($table->name);
}
/// Define table grade_items to be created
$table = new XMLDBTable('grade_items');
@ -288,6 +360,50 @@ class grade_test extends UnitTestCase {
delete_records($table->name);
}
/// Define table quiz to be created
$table = new XMLDBTable('quiz');
if ($result && !table_exists($table)) {
/// Adding fields to table quiz
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('timeclose', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('optionflags', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('penaltyscheme', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('attempts', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('attemptonlast', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('grademethod', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('decimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '2');
$table->addFieldInfo('review', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('questionsperpage', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('shufflequestions', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('shuffleanswers', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('questions', XMLDB_TYPE_TEXT, 'small', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('sumgrades', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('grade', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('timelimit', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('password', XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('subnet', XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('popup', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('delay1', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('delay2', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table quiz
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table quiz
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
/// Launch create table for quiz
$result = $result && create_table($table, true, false);
} else {
delete_records($table->name);
}
return $result;
}
@ -728,6 +844,106 @@ class grade_test extends UnitTestCase {
}
}
/**
* Load module entries in modules table\
*/
function load_modules() {
$module = new stdClass();
$module->name = 'assignment';
if ($module->id = insert_record('modules', $module)) {
$this->modules[0] = $module;
}
$module = new stdClass();
$module->name = 'quiz';
if ($module->id = insert_record('modules', $module)) {
$this->modules[1] = $module;
}
$module = new stdClass();
$module->name = 'forum';
if ($module->id = insert_record('modules', $module)) {
$this->modules[2] = $module;
}
}
/**
* Load module instance entries in course_modules table
*/
function load_course_modules() {
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 1;
$quiz->instance = 2;
if ($course_module->id = insert_record('course_modules', $course_module)) {
$this->course_module[0] = $course_module;
}
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 2;
$quiz->instance = 1;
if ($course_module->id = insert_record('course_modules', $course_module)) {
$this->course_module[0] = $course_module;
}
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 2;
$quiz->instance = 5;
if ($course_module->id = insert_record('course_modules', $course_module)) {
$this->course_module[0] = $course_module;
}
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 3;
$quiz->instance = 3;
if ($course_module->id = insert_record('course_modules', $course_module)) {
$this->course_module[0] = $course_module;
}
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 3;
$quiz->instance = 7;
if ($course_module->id = insert_record('course_modules', $course_module)) {
$this->course_module[0] = $course_module;
}
$course_module = new stdClass();
$course_module->course = $this->courseid;
$quiz->module = 3;
$quiz->instance = 9;
if ($course_module->id = insert_record('course_modules', $course_module)) {
$this->course_module[0] = $course_module;
}
}
/**
* Load test quiz data into the database
*/
function load_quiz_activities() {
$quiz = new stdClass();
$quiz->course = $this->courseid;
$quiz->name = 'test quiz';
$quiz->intro = 'let us quiz you!';
$quiz->questions = '1,2';
if ($quiz->id = insert_record('quiz', $quiz)) {
$this->activities[0] = $quiz;
}
$quiz = new stdClass();
$quiz->course = $this->courseid;
$quiz->name = 'test quiz 2';
$quiz->intro = 'let us quiz you again!';
$quiz->questions = '1,3';
if ($quiz->id = insert_record('quiz', $quiz)) {
$this->activities[1] = $quiz;
}
}
/**
* Load grade_item data into the database, and adds the corresponding objects to this class' variable.
*/

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2007091702; // YYYYMMDD = date
$version = 2007091800; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 Beta +'; // Human-friendly version name