mirror of
https://github.com/moodle/moodle.git
synced 2025-03-13 20:26:32 +01:00
MDL-23106 removing unused ratings upgrade code
This commit is contained in:
parent
63bfc7d6c0
commit
936a54ca05
@ -396,59 +396,3 @@ function upgrade_cleanup_unwanted_block_contexts($contextidarray) {
|
||||
$DB->delete_records_select('role_names', 'contextid IN ('.$blockcontextidsstring.')');
|
||||
$DB->delete_records_select('context', 'id IN ('.$blockcontextidsstring.')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Shifts ratings from modules into the central rating table
|
||||
*
|
||||
* @param string $ratingssql sql to return the module's rating
|
||||
* @param string $modulename the name of the module
|
||||
* @return boolean success flag
|
||||
*/
|
||||
/*function upgrade_module_ratings($ratingssql, $modulename) {
|
||||
global $DB;
|
||||
$contextid = null;
|
||||
$contextarray = array();
|
||||
$result = true;
|
||||
$i=0;
|
||||
|
||||
$ratings = $DB->get_recordset_sql($ratingssql);
|
||||
|
||||
foreach ($ratings as $old_rating) {
|
||||
if($i++%500==0) {
|
||||
upgrade_set_timeout(60);//prevent a timeout
|
||||
}
|
||||
|
||||
//all posts within a given forum, glossary etc will have the same context id so store them in an array
|
||||
if( !array_key_exists($old_rating->mid, $contextarray) ) {
|
||||
$sql = "SELECT cxt.id
|
||||
FROM {context} cxt
|
||||
JOIN {course_modules} cm ON cm.id = cxt.instanceid
|
||||
JOIN {modules} m ON cm.module = m.id
|
||||
WHERE m.name = :modulename AND cm.instance = :moduleinstanceid AND cxt.contextlevel = :contextmodule";
|
||||
$params = array();
|
||||
$params['modulename'] = $modulename;
|
||||
$params['moduleinstanceid'] = $old_rating->mid;
|
||||
$params['contextmodule'] = CONTEXT_MODULE;
|
||||
$results = $DB->get_record_sql($sql, $params);
|
||||
$contextarray[$old_rating->mid] = $results->id;
|
||||
}
|
||||
$contextid = $contextarray[$old_rating->mid];
|
||||
|
||||
$rating = new stdclass();
|
||||
$rating->contextid = $contextid;
|
||||
$rating->scaleid = $old_rating->scale;
|
||||
$rating->itemid = $old_rating->itemid;
|
||||
$rating->rating = $old_rating->rating;
|
||||
$rating->userid = $old_rating->userid;
|
||||
$rating->timecreated = $old_rating->timecreated;
|
||||
$rating->timemodified = $old_rating->timemodified;
|
||||
|
||||
if( !$DB->insert_record('rating', $rating) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$ratings->close();
|
||||
|
||||
return true;
|
||||
}*/
|
@ -256,7 +256,6 @@ function xmldb_data_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2010042800) {
|
||||
//migrate data ratings to the central rating table
|
||||
require_once($CFG->dirroot . '/lib/db/upgradelib.php');
|
||||
$table = new xmldb_table('data_ratings');
|
||||
if ($dbman->table_exists($table)) {
|
||||
//data ratings didnt store time created and modified so Im using the times from the record the rating was attached to
|
||||
|
@ -258,20 +258,20 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2010042800) {
|
||||
//migrate forumratings to the central rating table
|
||||
require_once($CFG->dirroot . '/lib/db/upgradelib.php');
|
||||
$table = new xmldb_table('forum_ratings');
|
||||
if ($dbman->table_exists($table)) {
|
||||
//forum ratings only have a single time column so use it for both time created and modified
|
||||
$sql = "INSERT INTO {rating} (contextid, scaleid, itemid, rating, userid, timecreated, timemodified)
|
||||
SELECT cxt.id, f.scale, r.post AS itemid, r.rating, r.userid, r.time AS timecreated, r.time AS timemodified
|
||||
FROM {forum_ratings} r
|
||||
JOIN {forum_posts} p ON p.id=r.post
|
||||
JOIN {forum_discussions} d ON d.id=p.discussion
|
||||
JOIN {forum} f ON f.id=d.forum
|
||||
JOIN {course_modules} cm ON cm.instance=f.id
|
||||
JOIN {context} cxt ON cxt.instanceid=cm.id
|
||||
JOIN {modules} m ON m.id=cm.module
|
||||
WHERE m.name = :modname AND cxt.contextlevel = :contextlevel";
|
||||
|
||||
SELECT cxt.id, f.scale, r.post AS itemid, r.rating, r.userid, r.time AS timecreated, r.time AS timemodified
|
||||
FROM {forum_ratings} r
|
||||
JOIN {forum_posts} p ON p.id=r.post
|
||||
JOIN {forum_discussions} d ON d.id=p.discussion
|
||||
JOIN {forum} f ON f.id=d.forum
|
||||
JOIN {course_modules} cm ON cm.instance=f.id
|
||||
JOIN {context} cxt ON cxt.instanceid=cm.id
|
||||
JOIN {modules} m ON m.id=cm.module
|
||||
WHERE m.name = :modname AND cxt.contextlevel = :contextlevel";
|
||||
$params['modname'] = 'forum';
|
||||
$params['contextlevel'] = CONTEXT_MODULE;
|
||||
|
||||
|
@ -262,8 +262,6 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2010042800) {
|
||||
//migrate glossary_ratings to the central rating table
|
||||
require_once($CFG->dirroot . '/lib/db/upgradelib.php');
|
||||
|
||||
$table = new xmldb_table('glossary_ratings');
|
||||
if ($dbman->table_exists($table)) {
|
||||
//glossary ratings only have a single time column so use it for both time created and modified
|
||||
|
Loading…
x
Reference in New Issue
Block a user