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

@@@ -2762,36 -2762,27 +2762,58 @@@ function xmldb_main_upgrade($oldversion
          upgrade_main_savepoint(true, 2021052500.20);
      }
  
 -    if ($oldversion < 2021052500.23) {
 +    if ($oldversion < 2021052500.24) {
 +        // 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, 2021052500.24);
 +    }
 +
 +    if ($oldversion < 2021052500.26) {
 +        // 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, 2021052500.26);
 +    }
 +
++    if ($oldversion < 2021052500.27) {
+         // 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, 2021052500.23);
++        upgrade_main_savepoint(true, 2021052500.27);
+     }
      return true;
  }
diff --cc version.php
@@@ -29,7 -29,7 +29,7 @@@
  
  defined('MOODLE_INTERNAL') || die();
  
- $version  = 2021052500.26;              // YYYYMMDD      = weekly release date of this DEV branch.
 -$version  = 2021052500.23;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2021052500.27;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.
  $release  = '4.0dev (Build: 20201016)'; // Human-friendly version name