Merge branch 'master_MDL-44938' of git://github.com/danmarsden/moodle
authorMarina Glancy <marina@moodle.com>
Tue, 8 Apr 2014 00:53:58 +0000 (08:53 +0800)
committerMarina Glancy <marina@moodle.com>
Tue, 8 Apr 2014 00:53:58 +0000 (08:53 +0800)
1  2 
mod/scorm/db/upgrade.php

diff --combined mod/scorm/db/upgrade.php
@@@ -83,6 -83,7 +83,7 @@@ function xmldb_scorm_upgrade($oldversio
  
      // Remove old imsrepository type - convert any existing records to external type to help prevent major errors.
      if ($oldversion < 2013081301) {
+         require_once($CFG->dirroot . '/mod/scorm/lib.php');
          $scorms = $DB->get_recordset('scorm', array('scormtype' => 'imsrepository'));
          foreach ($scorms as $scorm) {
              $scorm->scormtype = SCORM_TYPE_EXTERNAL;
          upgrade_mod_savepoint(true, 2013110501, 'scorm');
      }
  
 -    if ($oldversion < 2014021700) {
 +    if ($oldversion < 2014031700) {
 +        // Define field displayactivityname to be added to scorm.
 +        $table = new xmldb_table('scorm');
 +        $field = new xmldb_field(
 +            'displayactivityname',
 +            XMLDB_TYPE_INTEGER,
 +            '4',
 +            null,
 +            XMLDB_NOTNULL,
 +            null,
 +            '1',
 +            'completionscorerequired'
 +        );
 +
 +        // Conditionally launch add field displayactivityname.
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
 +
 +        // Scorm savepoint reached.
 +        upgrade_mod_savepoint(true, 2014031700, 'scorm');
 +    }
 +
 +    if ($oldversion < 2014040200) {
          // Fix invalid $scorm->launch records that launch an org sco instead of a real sco.
          $sql = "SELECT s.*, c.identifier
                   FROM {scorm} s
          }
          $scorms->close();
  
 -        upgrade_mod_savepoint(true, 2014021700, 'scorm');
 -    }
 -
 -    if ($oldversion < 2014031700) {
 -        // Define field displayactivityname to be added to scorm.
 -        $table = new xmldb_table('scorm');
 -        $field = new xmldb_field(
 -            'displayactivityname',
 -            XMLDB_TYPE_INTEGER,
 -            '4',
 -            null,
 -            XMLDB_NOTNULL,
 -            null,
 -            '1',
 -            'completionscorerequired'
 -        );
 -
 -        // Conditionally launch add field displayactivityname.
 -        if (!$dbman->field_exists($table, $field)) {
 -            $dbman->add_field($table, $field);
 -        }
 -
 -        // Scorm savepoint reached.
 -        upgrade_mod_savepoint(true, 2014031700, 'scorm');
 +        upgrade_mod_savepoint(true, 2014040200, 'scorm');
      }
  
      return true;