Merge branch 'MOODLE_310_STABLE-MDL-68284' of https://github.com/yao9394/moodle into...
authorAdrian Greeve <abgreeve@gmail.com>
Tue, 20 Oct 2020 00:49:06 +0000 (08:49 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Tue, 20 Oct 2020 00:49:06 +0000 (08:49 +0800)
1  2 
lib/db/upgrade.php
version.php

@@@ -2763,35 -2763,26 +2763,57 @@@ function xmldb_main_upgrade($oldversion
      }
  
      if ($oldversion < 2020101300.01) {
 -        upgrade_main_savepoint(true, 2020101300.01);
 +        // Define fields tutorial and example to be added to h5p_libraries.
 +        $table = new xmldb_table('h5p_libraries');
 +
 +        // Add tutorial field.
 +        $field = new xmldb_field('tutorial', XMLDB_TYPE_TEXT, null, null, null, null, null, 'metadatasettings');
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        // Add example field.
 +        $field = new xmldb_field('example', XMLDB_TYPE_TEXT, null, null, null, null, null, 'tutorial');
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        // Main savepoint reached.
 +        upgrade_main_savepoint(true, 2020101300.01);
 +    }
 +
 +    if ($oldversion < 2020101600.01) {
 +        // Delete orphaned course_modules_completion rows; these were not deleted properly
 +        // by remove_course_contents function.
 +        $DB->delete_records_subquery('course_modules_completion', 'id', 'id',
 +               "SELECT cmc.id
 +                  FROM {course_modules_completion} cmc
 +             LEFT JOIN {course_modules} cm ON cm.id = cmc.coursemoduleid
 +                 WHERE cm.id IS NULL");
 +        upgrade_main_savepoint(true, 2020101600.01);
 +    }
 +
++    if ($oldversion < 2020101600.02) {
+         // Script to fix incorrect records of "hidden" field in existing grade items.
+         $sql = "SELECT cm.instance, cm.course
+                   FROM {course_modules} cm
+                   JOIN {modules} m ON m.id = cm.module
+                  WHERE m.name = :module AND cm.visible = :visible";
+         $hidequizlist = $DB->get_recordset_sql($sql, ['module' => 'quiz', 'visible' => 0]);
+         foreach ($hidequizlist as $hidequiz) {
+             $params = [
+                 'itemmodule'    => 'quiz',
+                 'courseid'      => $hidequiz->course,
+                 'iteminstance'  => $hidequiz->instance,
+             ];
+             $DB->set_field('grade_items', 'hidden', 1, $params);
+         }
+         $hidequizlist->close();
++        upgrade_main_savepoint(true, 2020101600.02);
+     }
      return true;
  }
diff --cc version.php
@@@ -29,9 -29,9 +29,9 @@@
  
  defined('MOODLE_INTERNAL') || die();
  
- $version  = 2020101600.01;              // YYYYMMDD      = weekly release date of this DEV branch.
 -$version  = 2020101300.01;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2020101600.02;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.
 -$release  = '3.10dev+ (Build: 20201013)';// Human-friendly version name
 +$release  = '3.10dev+ (Build: 20201016)';// Human-friendly version name
  $branch   = '310';                      // This version's branch.
  $maturity = MATURITY_ALPHA;             // This version's maturity level.