MDL-44753 SCORM: add check during SCORM restore to make sure valid launch sco is set
This commit is contained in:
@@ -199,6 +199,16 @@ class restore_scorm_activity_structure_step extends restore_activity_structure_s
|
||||
$scormid = $this->get_new_parentid('scorm');
|
||||
$scorm = $DB->get_record('scorm', array('id' => $scormid));
|
||||
$scorm->launch = $this->get_mappingid('scorm_sco', $scorm->launch, '');
|
||||
|
||||
if (!empty($scorm->launch)) {
|
||||
// Check that this sco has a valid launch value.
|
||||
$scolaunch = $DB->get_field('scorm_scoes', 'launch', array('id' => $scorm->launch));
|
||||
if (empty($scolaunch)) {
|
||||
// This is not a valid sco - set to empty so we can find a valid launch sco.
|
||||
$scorm->launch = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($scorm->launch)) {
|
||||
// This scorm has an invalid launch param - we need to calculate it and get the first launchable sco.
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true);
|
||||
|
||||
+25
-25
@@ -202,7 +202,30 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
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
|
||||
@@ -249,30 +272,7 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
}
|
||||
$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;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2014032600; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2014040200; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2013110500; // Requires this Moodle version.
|
||||
$plugin->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics).
|
||||
$plugin->cron = 300;
|
||||
|
||||
Reference in New Issue
Block a user