Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-37393 SCORM: Fix existing AICC scoes to use correct parent/child …

…relationships
  • Loading branch information...
commit 2f64dd6dc83e6d90c7f161612e2ded3c7e8c6e48 1 parent 9372820
Dan Marsden danmarsden authored
4 mod/scorm/datamodels/aicclib.php
View
@@ -283,8 +283,10 @@ function scorm_parse_aicc($scorm) {
$sco->organization = $course->id;
$sco->title = $element->title;
- if (!isset($element->parent) || strtolower($element->parent) == 'root') {
+ if (!isset($element->parent)) {
$sco->parent = '/';
+ } else if (strtolower($element->parent) == 'root') {
+ $sco->parent = $course->id;
} else {
$sco->parent = $element->parent;
}
20 mod/scorm/db/upgrade.php
View
@@ -77,8 +77,24 @@ function xmldb_scorm_upgrade($oldversion) {
// Moodle v2.4.0 release upgrade line
- // Put any upgrade step following this
-
+ // Put any upgrade step following this.
+
+ // Fix AICC parent/child relationships (MDL-37394).
+ if ($oldversion < 2012112901) {
+ // Get all AICC packages.
+ $aiccpackages = $DB->get_recordset('scorm', array('version' => 'AICC'), '', 'id');
+ foreach ($aiccpackages as $aicc) {
+ $sql = "UPDATE {scorm_scoes}
+ SET parent = organization
+ WHERE scorm = ?
+ AND " . $DB->sql_isempty('scorm_scoes', 'manifest', false, false) . "
+ AND " . $DB->sql_isnotempty('scorm_scoes', 'organization', false, false) . "
+ AND parent = '/'";
+ $DB->execute($sql, array($aicc->id));
+ }
+ $aiccpackages->close();
+ upgrade_mod_savepoint(true, 2012112901, 'scorm');
+ }
return true;
}
2  mod/scorm/version.php
View
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
-$module->version = 2012112900; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2012112901; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2012112900; // Requires this Moodle version
$module->component = 'mod_scorm'; // Full name of the plugin (used for diagnostics)
$module->cron = 300;
Please sign in to comment.
Something went wrong with that request. Please try again.