Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 402 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Grader report upgrade steps.
  19   *
  20   * @package    gradereport_grader
  21   * @copyright  2023 Ilya Tregubov <ilya@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Function to upgrade grader report.
  29   *
  30   * @param int $oldversion the version we are upgrading from
  31   * @return bool result
  32   */
  33  function xmldb_gradereport_grader_upgrade(int $oldversion): bool {
  34      global $DB;
  35  
  36      if ($oldversion < 2023032100) {
  37          // Remove grade_report_showquickfeedback, grade_report_enableajax, grade_report_showeyecons,
  38          // grade_report_showlocks, grade_report_showanalysisicon preferences for every user.
  39          $DB->delete_records('user_preferences', ['name' => 'grade_report_showquickfeedback']);
  40          $DB->delete_records('user_preferences', ['name' => 'grade_report_enableajax']);
  41          $DB->delete_records('user_preferences', ['name' => 'grade_report_showeyecons']);
  42          $DB->delete_records('user_preferences', ['name' => 'grade_report_showlocks']);
  43          $DB->delete_records('user_preferences', ['name' => 'grade_report_showanalysisicon']);
  44  
  45          // Remove grade_report_showactivityicons, grade_report_showcalculations preferences for every user.
  46          $DB->delete_records('user_preferences', ['name' => 'grade_report_showactivityicons']);
  47          $DB->delete_records('user_preferences', ['name' => 'grade_report_showcalculations']);
  48  
  49          // The grade_report_showquickfeedback, grade_report_enableajax, grade_report_showeyecons,
  50          // grade_report_showlocks, grade_report_showanalysisicon settings have been removed.
  51          unset_config('grade_report_showquickfeedback');
  52          unset_config('grade_report_enableajax');
  53          unset_config('grade_report_showeyecons');
  54          unset_config('grade_report_showlocks');
  55          unset_config('grade_report_showanalysisicon');
  56  
  57          // The grade_report_showactivityicons, grade_report_showcalculations settings have been removed.
  58          unset_config('grade_report_showactivityicons');
  59          unset_config('grade_report_showcalculations');
  60  
  61          // Main savepoint reached.
  62          upgrade_plugin_savepoint(true, 2023032100, 'gradereport', 'grader');
  63      }
  64  
  65      if ($oldversion < 2023032700) {
  66          unset_config('grade_report_studentsperpage');
  67          upgrade_plugin_savepoint(true, 2023032700, 'gradereport', 'grader');
  68      }
  69  
  70      if ($oldversion < 2023032800) {
  71          // Remove plugin entry created by previously incorrect 2023032100 savepoint.
  72          $DB->delete_records('config_plugins', ['plugin' => 'grade_gradereport_grader']);
  73          upgrade_plugin_savepoint(true, 2023032800, 'gradereport', 'grader');
  74      }
  75  
  76      // Automatically generated Moodle v4.2.0 release upgrade line.
  77      // Put any upgrade step following this.
  78  
  79      // Automatically generated Moodle v4.3.0 release upgrade line.
  80      // Put any upgrade step following this.
  81  
  82      return true;
  83  }