rating MDL-21657 Switched from table ratings to rating

This commit is contained in:
Andrew Davis
2010-03-16 08:57:57 +00:00
parent 560ad965ec
commit 54e42e0bf2
3 changed files with 11 additions and 11 deletions
+6 -6
View File
@@ -3052,10 +3052,10 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
}
if ($result && $oldversion < 2010031600) {
//create the ratings table (replaces module specific ratings implementations)
$table = new xmldb_table('ratings');
//create the rating table (replaces module specific rating implementations)
$table = new xmldb_table('rating');
/// Adding fields to table ratings
/// Adding fields to table rating
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
@@ -3067,12 +3067,12 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table ratings
/// Adding keys to table rating
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
/// Adding indexes to table ratings
/// Adding indexes to table rating
$table->add_index('itemid', XMLDB_INDEX_NOTUNIQUE, array('itemid'));
/// Create table for ratings
@@ -3080,7 +3080,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
$dbman->create_table($table);
}
//migrate ratings out of the modules into the central ratings table
//migrate ratings out of the modules into the central rating table
//migrate forumratings
//forum ratings only have a single time column so use it for both time created and modified
+1 -1
View File
@@ -433,7 +433,7 @@ where m.name=:modulename and cm.instance=:moduleinstanceid and cxt.contextlevel=
$rating->timecreated = $old_rating->timecreated;
$rating->timemodified = $old_rating->timemodified;
$result = $result && $DB->insert_record('ratings', $rating);
$result = $result && $DB->insert_record('rating', $rating);
}
//$ratings->close();
+4 -4
View File
@@ -67,7 +67,7 @@ function update_rating($rating) {
global $DB;
$data = new stdclass();
$table = 'ratings';
$table = 'rating';
$item = new stdclass();
$item->id = $this->itemid;
@@ -153,7 +153,7 @@ public static function load_ratings_for_item($context, $itemid, $sort) {
$sql = "SELECT r.id, r.rating, r.itemid, r.userid, r.timemodified,
u.firstname, u.lastname, u.imagealt, u.picture
FROM {ratings} r
FROM {rating} r
LEFT JOIN {user} u ON r.userid = u.id
WHERE
r.contextid = :contextid AND
@@ -202,8 +202,8 @@ public static function load_ratings($context, $items, $aggregate=RATING_AGGREGAT
$aggregatestr(r.rating) AS aggrrating,
COUNT(r.rating) AS numratings,
ur.rating AS usersrating
FROM {ratings} r
LEFT JOIN {ratings} ur ON ur.contextid = r.contextid AND
FROM {rating} r
LEFT JOIN {rating} ur ON ur.contextid = r.contextid AND
ur.itemid = r.itemid AND
ur.userid = :userid
WHERE