[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/scorm/db/ -> upgrade.php (source)

   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   * Upgrade script for the scorm module.
  19   *
  20   * @package    mod_scorm
  21   * @copyright  1999 onwards Martin Dougiamas  {@link http://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   * @global moodle_database $DB
  29   * @param int $oldversion
  30   * @return bool
  31   */
  32  function xmldb_scorm_upgrade($oldversion) {
  33      global $CFG, $DB;
  34  
  35      $dbman = $DB->get_manager();
  36  
  37      if ($oldversion < 2014072500) {
  38  
  39          // Define field autocommit to be added to scorm.
  40          $table = new xmldb_table('scorm');
  41          $field = new xmldb_field('autocommit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayactivityname');
  42  
  43          // Conditionally launch add field autocommit.
  44          if (!$dbman->field_exists($table, $field)) {
  45              $dbman->add_field($table, $field);
  46          }
  47  
  48          // Scorm savepoint reached.
  49          upgrade_mod_savepoint(true, 2014072500, 'scorm');
  50      }
  51  
  52      // Moodle v2.8.0 release upgrade line.
  53      // Put any upgrade step following this.
  54  
  55      if ($oldversion < 2015031800) {
  56  
  57          // Check to see if this site has any AICC packages - if so set the aiccuserid to pass the username
  58          // so that the data remains consistent with existing packages.
  59          $alreadyset = $DB->record_exists('config_plugins', array('plugin' => 'scorm', 'name' => 'aiccuserid'));
  60          if (!$alreadyset) {
  61              $hasaicc = $DB->record_exists('scorm', array('version' => 'AICC'));
  62              if ($hasaicc) {
  63                  set_config('aiccuserid', 0, 'scorm');
  64              } else {
  65                  // We set the config value to hide this from upgrades as most users will not know what AICC is anyway.
  66                  set_config('aiccuserid', 1, 'scorm');
  67              }
  68          }
  69          // Scorm savepoint reached.
  70          upgrade_mod_savepoint(true, 2015031800, 'scorm');
  71      }
  72  
  73      // Moodle v2.9.0 release upgrade line.
  74      // Put any upgrade step following this.
  75  
  76      if ($oldversion < 2015091400) {
  77          $table = new xmldb_table('scorm');
  78  
  79          // Changing the default of field forcecompleted on table scorm to 0.
  80          $field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'maxattempt');
  81          // Launch change of default for field forcecompleted.
  82          $dbman->change_field_default($table, $field);
  83  
  84          // Changing the default of field displaycoursestructure on table scorm to 0.
  85          $field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'displayattemptstatus');
  86          // Launch change of default for field displaycoursestructure.
  87          $dbman->change_field_default($table, $field);
  88  
  89          // Scorm savepoint reached.
  90          upgrade_mod_savepoint(true, 2015091400, 'scorm');
  91      }
  92  
  93      // Moodle v3.0.0 release upgrade line.
  94      // Put any upgrade step following this.
  95  
  96      // MDL-50620 Add mastery override option.
  97      if ($oldversion < 2016021000) {
  98          $table = new xmldb_table('scorm');
  99  
 100          $field = new xmldb_field('masteryoverride', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'lastattemptlock');
 101          if (!$dbman->field_exists($table, $field)) {
 102              $dbman->add_field($table, $field);
 103          }
 104  
 105          upgrade_mod_savepoint(true, 2016021000, 'scorm');
 106      }
 107  
 108      // Moodle v3.1.0 release upgrade line.
 109      // Put any upgrade step following this.
 110  
 111      return true;
 112  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1