Skip to content

Commit

Permalink
MDL-10757 adding some more table indexes for grades code
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 9, 2007
1 parent 8851fdf commit 90274c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/db/install.xml
Expand Up @@ -1371,8 +1371,9 @@
<INDEXES>
<INDEX NAME="locktime" UNIQUE="false" FIELDS="locktime" COMMENT="locktime index" NEXT="locked"/>
<INDEX NAME="locked" UNIQUE="false" FIELDS="locked" COMMENT="locked index" PREVIOUS="locktime" NEXT="itemtype"/>
<INDEX NAME="itemtype" UNIQUE="false" FIELDS="itemtype" COMMENT="itemtypeindex" PREVIOUS="locked" NEXT="needsupdate"/>
<INDEX NAME="needsupdate" UNIQUE="false" FIELDS="needsupdate" COMMENT="needsupdate index" PREVIOUS="itemtype"/>
<INDEX NAME="itemtype" UNIQUE="false" FIELDS="itemtype" COMMENT="itemtypeindex" PREVIOUS="locked" NEXT="itemtype-needsupdate"/>
<INDEX NAME="itemtype-needsupdate" UNIQUE="false" FIELDS="itemtype, needsupdate" COMMENT="used in grading cron" PREVIOUS="itemtype" NEXT="gradetype"/>
<INDEX NAME="gradetype" UNIQUE="false" FIELDS="gradetype" COMMENT="index for gradetype" PREVIOUS="itemtype-needsupdate"/>
</INDEXES>
</TABLE>
<TABLE NAME="grade_grades" COMMENT="grade_grades This table keeps individual grades for each user and each item, exactly as imported or submitted by modules. The rawgrademax/min and rawscaleid are stored here to record the values at the time the grade was stored, because teachers might change this for an activity! All the results are normalised/resampled for the final grade value." PREVIOUS="grade_items" NEXT="grade_grades_text">
Expand Down
19 changes: 14 additions & 5 deletions lib/db/upgrade.php
Expand Up @@ -1129,7 +1129,8 @@ function xmldb_main_upgrade($oldversion=0) {
$table->addIndexInfo('locktime', XMLDB_INDEX_NOTUNIQUE, array('locktime'));
$table->addIndexInfo('locked', XMLDB_INDEX_NOTUNIQUE, array('locked'));
$table->addIndexInfo('itemtype', XMLDB_INDEX_NOTUNIQUE, array('itemtype'));
$table->addIndexInfo('needsupdate', XMLDB_INDEX_NOTUNIQUE, array('needsupdate'));
$table->addIndexInfo('itemtype-needsupdate', XMLDB_INDEX_NOTUNIQUE, array('itemtype', 'needsupdate'));
$table->addIndexInfo('gradetype', XMLDB_INDEX_NOTUNIQUE, array('gradetype'));

/// Launch create table for grade_items
$result = $result && create_table($table);
Expand Down Expand Up @@ -1662,7 +1663,7 @@ function xmldb_main_upgrade($oldversion=0) {
$result = $result && add_field($table, $field);
}

if ($result && $oldversion < 2007080901) {
if ($result && $oldversion < 2007080902) {
/// Define index
$table = new XMLDBTable('grade_grades');
$index = new XMLDBIndex('locktime');
Expand Down Expand Up @@ -1713,17 +1714,25 @@ function xmldb_main_upgrade($oldversion=0) {
$result = $result && add_index($table, $index);
}

/// Define index itemtype-needsupdate (not unique) to be added to grade_items
$table = new XMLDBTable('grade_items');
$index = new XMLDBIndex('itemtype-needsupdate');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('itemtype', 'needsupdate'));
if (!index_exists($table, $index)) {
/// Launch add index itemtype-needsupdate
$result = $result && add_index($table, $index);
}

/// Define index
$table = new XMLDBTable('grade_items');
$index = new XMLDBIndex('needsupdate');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('needsupdate'));
$index = new XMLDBIndex('gradetype');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('gradetype'));

if (!index_exists($table, $index)) {
/// Launch add index
$result = $result && add_index($table, $index);
}


}

/*
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -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 = 2007080901; // YYYYMMDD = date
$version = 2007080902; // YYYYMMDD = date
// XY = increments within a single day

$release = '1.9 dev'; // Human-friendly version name
Expand Down

0 comments on commit 90274c7

Please sign in to comment.