Commit 7f91fb03 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

Merge branch 'MDL-60366_feedback_upgrade' of git://github.com/davosmith/moodle

parents fd39db29 5ef66eaf
......@@ -146,17 +146,20 @@ function xmldb_feedback_upgrade($oldversion) {
// Related values in feedback_value won't be deleted (they won't be used and can be kept there as a backup).
$sql = "SELECT MAX(id) as maxid, userid, feedback, courseid
FROM {feedback_completed}
WHERE userid <> 0
WHERE userid <> 0 AND anonymous_response = :notanonymous
GROUP BY userid, feedback, courseid
HAVING COUNT(id) > 1";
$params = ['notanonymous' => 2]; // FEEDBACK_ANONYMOUS_NO.
$duplicatedrows = $DB->get_recordset_sql($sql);
$duplicatedrows = $DB->get_recordset_sql($sql, $params);
foreach ($duplicatedrows as $row) {
$DB->delete_records_select('feedback_completed', 'userid = ? AND feedback = ? AND courseid = ? AND id <> ?', array(
$row->userid,
$row->feedback,
$row->courseid,
$row->maxid,
$DB->delete_records_select('feedback_completed', 'userid = ? AND feedback = ? AND courseid = ? AND id <> ?'.
' AND anonymous_response = ?', array(
$row->userid,
$row->feedback,
$row->courseid,
$row->maxid,
2, // FEEDBACK_ANONYMOUS_NO.
));
}
$duplicatedrows->close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment