Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'm23_MDL-33053_AICC_flattened_TOC' of git://github.com/s…

…cara/moodle into MOODLE_23_STABLE
  • Loading branch information...
commit 6253f69246b9af7ed5d6cc10a3f8e562975b3e77 2 parents 49ac5de + 8ac8aae
@danpoltawski danpoltawski authored
Showing with 55 additions and 48 deletions.
  1. +53 −47 mod/scorm/datamodels/aicclib.php
  2. +2 −1  mod/scorm/locallib.php
View
100 mod/scorm/datamodels/aicclib.php
@@ -197,7 +197,10 @@ function scorm_parse_aicc($scorm) {
if (preg_match($regexp, $rows[$i], $matches)) {
for ($j=0; $j<count($columns->columns); $j++) {
if ($j != $columns->mastercol) {
- $courses[$courseid]->elements[substr(trim($matches[$j+1]), 1 , -1)]->parent = substr(trim($matches[$columns->mastercol+1]), 1, -1);
+ $element = substr(trim($matches[$j+1]), 1 , -1);
+ if (!empty($element)) {
+ $courses[$courseid]->elements[$element]->parent = substr(trim($matches[$columns->mastercol+1]), 1, -1);
+ }
}
}
}
@@ -275,58 +278,61 @@ function scorm_parse_aicc($scorm) {
} else {
$sco->parent = $element->parent;
}
+ $sco->launch = '';
+ $sco->scormtype = '';
+ $sco->previous = 0;
+ $sco->next = 0;
+ $id = null;
+ // Is it an Assignable Unit (AU)?
if (isset($element->file_name)) {
$sco->launch = $element->file_name;
$sco->scormtype = 'sco';
- $sco->previous = 0;
- $sco->next = 0;
- $id = null;
- if ($oldscoid = scorm_array_search('identifier', $sco->identifier, $oldscoes)) {
- $sco->id = $oldscoid;
- $DB->update_record('scorm_scoes', $sco);
- $id = $oldscoid;
- $DB->delete_records('scorm_scoes_data', array('scoid'=>$oldscoid));
- unset($oldscoes[$oldscoid]);
- } else {
- $id = $DB->insert_record('scorm_scoes', $sco);
+ }
+ if ($oldscoid = scorm_array_search('identifier', $sco->identifier, $oldscoes)) {
+ $sco->id = $oldscoid;
+ $DB->update_record('scorm_scoes', $sco);
+ $id = $oldscoid;
+ $DB->delete_records('scorm_scoes_data', array('scoid'=>$oldscoid));
+ unset($oldscoes[$oldscoid]);
+ } else {
+ $id = $DB->insert_record('scorm_scoes', $sco);
+ }
+ if (!empty($id)) {
+ $scodata = new stdClass();
+ $scodata->scoid = $id;
+ if (isset($element->web_launch)) {
+ $scodata->name = 'parameters';
+ $scodata->value = $element->web_launch;
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
- if (!empty($id)) {
- $scodata = new stdClass();
- $scodata->scoid = $id;
- if (isset($element->web_launch)) {
- $scodata->name = 'parameters';
- $scodata->value = $element->web_launch;
- $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
- }
- if (isset($element->prerequisites)) {
- $scodata->name = 'prerequisites';
- $scodata->value = $element->prerequisites;
- $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
- }
- if (isset($element->max_time_allowed)) {
- $scodata->name = 'max_time_allowed';
- $scodata->value = $element->max_time_allowed;
- $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
- }
- if (isset($element->time_limit_action)) {
- $scodata->name = 'time_limit_action';
- $scodata->value = $element->time_limit_action;
- $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
- }
- if (isset($element->mastery_score)) {
- $scodata->name = 'mastery_score';
- $scodata->value = $element->mastery_score;
- $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
- }
- if (isset($element->core_vendor)) {
- $scodata->name = 'datafromlms';
- $scodata->value = preg_replace('/<cr>/i', "\r\n", $element->core_vendor);
- $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
- }
+ if (isset($element->prerequisites)) {
+ $scodata->name = 'prerequisites';
+ $scodata->value = $element->prerequisites;
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
+ }
+ if (isset($element->max_time_allowed)) {
+ $scodata->name = 'max_time_allowed';
+ $scodata->value = $element->max_time_allowed;
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
- if ($launch==0) {
- $launch = $id;
+ if (isset($element->time_limit_action)) {
+ $scodata->name = 'time_limit_action';
+ $scodata->value = $element->time_limit_action;
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
+ if (isset($element->mastery_score)) {
+ $scodata->name = 'mastery_score';
+ $scodata->value = $element->mastery_score;
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
+ }
+ if (isset($element->core_vendor)) {
+ $scodata->name = 'datafromlms';
+ $scodata->value = preg_replace('/<cr>/i', "\r\n", $element->core_vendor);
+ $dataid = $DB->insert_record('scorm_scoes_data', $scodata);
+ }
+ }
+ if ($launch==0) {
+ $launch = $id;
}
}
}
View
3  mod/scorm/locallib.php
@@ -1338,7 +1338,8 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$isvisible = true;
}
if ($parents[$level] != $sco->parent) {
- if ($newlevel = array_search($sco->parent,$parents)) {
+ $newlevel = array_search($sco->parent,$parents);
+ if ($newlevel !== false) {
for ($i=0; $i<($level-$newlevel); $i++) {
$result->toc .= "\t\t</li></ul></li>\n";
}
Please sign in to comment.
Something went wrong with that request. Please try again.