Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  // This file keeps track of upgrades to
   3  // the choice module
   4  //
   5  // Sometimes, changes between versions involve
   6  // alterations to database structures and other
   7  // major things that may break installations.
   8  //
   9  // The upgrade function in this file will attempt
  10  // to perform all the necessary actions to upgrade
  11  // your older installation to the current version.
  12  //
  13  // If there's something it cannot do itself, it
  14  // will tell you what you need to do.
  15  //
  16  // The commands in here will all be database-neutral,
  17  // using the methods of database_manager class
  18  //
  19  // Please do not forget to use upgrade_set_timeout()
  20  // before any action that may take longer time to finish.
  21  
  22  defined('MOODLE_INTERNAL') || die();
  23  
  24  function xmldb_choice_upgrade($oldversion) {
  25      global $CFG, $DB;
  26  
  27      $dbman = $DB->get_manager();
  28  
  29      // Automatically generated Moodle v3.9.0 release upgrade line.
  30      // Put any upgrade step following this.
  31  
  32      if ($oldversion < 2020061600) {
  33          // Define field showavailable to be added to choice.
  34          $table = new xmldb_table('choice');
  35          $field = new xmldb_field('showavailable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completionsubmit');
  36  
  37          if (!$dbman->field_exists($table, $field)) {
  38              $dbman->add_field($table, $field);
  39          }
  40  
  41          // Choice savepoint reached.
  42          upgrade_mod_savepoint(true, 2020061600, 'choice');
  43      }
  44      // Automatically generated Moodle v4.0.0 release upgrade line.
  45      // Put any upgrade step following this.
  46  
  47      // Automatically generated Moodle v4.1.0 release upgrade line.
  48      // Put any upgrade step following this.
  49  
  50      return true;
  51  }