Permalink
Browse files

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

…relationships
  • Loading branch information...
1 parent 9372820 commit 2f64dd6dc83e6d90c7f161612e2ded3c7e8c6e48 @danmarsden danmarsden committed Jan 11, 2013
Showing with 22 additions and 4 deletions.
  1. +3 −1 mod/scorm/datamodels/aicclib.php
  2. +18 −2 mod/scorm/db/upgrade.php
  3. +1 −1 mod/scorm/version.php
@@ -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;
}
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;
}
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;

0 comments on commit 2f64dd6

Please sign in to comment.