MDL-52206 quiz: Integration bug fixes

This commit is contained in:
Peter Dias
2021-10-08 07:33:05 +02:00
committed by Sara Arjona
parent edb655e35c
commit 7ab2d7d7bd
2 changed files with 6 additions and 5 deletions
@@ -41,9 +41,7 @@ Feature: Pass grade activity completion information in the LTI activity
And I log out
Scenario: View automatic completion items as a teacher
Given I log in as "teacher1"
And I am on "Course 1" course homepage
When I follow "Music history"
Given I am on the "Music history" "lti activity" page logged in as teacher1
Then "Music history" should have the "View" completion condition
And "Music history" should have the "Receive a grade" completion condition
And "Music history" should have the "Receive a passing grade" completion condition
+5 -2
View File
@@ -65,7 +65,7 @@ function xmldb_quiz_upgrade($oldversion) {
$field = new xmldb_field('completionpass');
if ($dbman->field_exists($table, $field)) {
$sql = "SELECT q.id " .
$sql = "SELECT q.id, m.id as quizid " .
"FROM {quiz} q " .
"INNER JOIN {course_modules} cm ON cm.instance = q.id " .
"INNER JOIN {modules} m ON m.id = cm.module " .
@@ -74,13 +74,16 @@ function xmldb_quiz_upgrade($oldversion) {
/** @var moodle_recordset $records */
$records = $DB->get_recordset_sql($sql, ['name' => 'quiz', 'completionpass' => 1], 0, 1000);
while ($records->valid()) {
$quizmodule = null;
foreach ($records as $record) {
$ids[] = $record->id;
$quizmodule = $record->quizid;
}
if ($ids) {
list($insql, $params) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED);
$DB->set_field_select('course_modules', 'completionpassgrade', 1, "instance $insql", $params);
$DB->set_field_select('course_modules', 'completionpassgrade', 1,
"module = :quiz AND instance $insql", $params + ['quiz' => $quizmodule]);
// Reset the value so it doesn't get picked on the next run. The field will be dropped later.
$DB->set_field_select('quiz', 'completionpass', 0, "id $insql", $params);