Commit 41a9a921 authored by Dan Poltawski's avatar Dan Poltawski Committed by Eloy Lafuente
Browse files

MDL-56303 quiz: lack of quiz filtering

Also, correctly feed completiongradeitemnumber with grade item numbers
and not with grade item ids.
parent f73f9384
......@@ -222,21 +222,24 @@ function xmldb_quiz_upgrade($oldversion) {
if ($oldversion < 2016100300) {
// Find quizzes with the combination of require passing grade and grade to pass 0.
$quizzes = $DB->get_records_sql("
SELECT gi.id, gi.iteminstance
$gradeitems = $DB->get_records_sql("
SELECT gi.id, gi.itemnumber, cm.id AS cmid
FROM {quiz} q
INNER JOIN {course_modules} cm ON q.id = cm.instance
INNER JOIN {grade_items} gi ON q.id = gi.iteminstance
INNER JOIN {modules} m ON m.id = cm.module
WHERE q.completionpass = 1
AND gi.gradepass = 0
AND cm.completiongradeitemnumber IS NULL");
if ($quizzes) {
foreach ($quizzes as $quiz) {
$DB->execute("UPDATE {course_modules}
SET completiongradeitemnumber = :gradeitemid
WHERE instance = :quizid",
array('gradeitemid' => $quiz->id, 'quizid' => $quiz->iteminstance));
}
AND cm.completiongradeitemnumber IS NULL
AND gi.itemmodule = m.name
AND gi.itemtype = ?
AND m.name = ?", array('mod', 'quiz'));
foreach ($gradeitems as $gradeitem) {
$DB->execute("UPDATE {course_modules}
SET completiongradeitemnumber = :itemnumber
WHERE id = :cmid",
array('itemnumber' => $gradeitem->itemnumber, 'cmid' => $gradeitem->cmid));
}
// Quiz savepoint reached.
upgrade_mod_savepoint(true, 2016100300, 'quiz');
......
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