diff --git a/mod/scorm/datamodels/aicc.js.php b/mod/scorm/datamodels/aicc.js.php index e141af7c30bc7..dadb18626a2ab 100644 --- a/mod/scorm/datamodels/aicc.js.php +++ b/mod/scorm/datamodels/aicc.js.php @@ -69,7 +69,7 @@ function AICCapi() { 'cmi.core.total_time':{'defaultvalue':'{'cmi.core.total_time'})?$userdata->{'cmi.core.total_time'}:'00:00:00' ?>', 'mod':'r', 'writeerror':'403'}, 'cmi.core.lesson_mode':{'defaultvalue':'mode ?>', 'mod':'r', 'writeerror':'403'}, 'cmi.suspend_data':{'defaultvalue':'{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, - 'cmi.launch_data':{'defaultvalue':'datafromlms ?>', 'mod':'r', 'writeerror':'403'}, + 'cmi.launch_data':{'defaultvalue':'datafromlms)?$userdata->datafromlms:'' ?>', 'mod':'r', 'writeerror':'403'}, 'cmi.comments':{'defaultvalue':'{'cmi.comments'})?$userdata->{'cmi.comments'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, 'cmi.evaluation.comments._count':{'defaultvalue':'0', 'mod':'r', 'writeerror':'402'}, 'cmi.evaluation.comments._children':{'defaultvalue':comments_children, 'mod':'r', 'writeerror':'402'}, @@ -92,9 +92,9 @@ function AICCapi() { 'cmi.student_data.tries.n.score.max':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, 'cmi.student_data.tries.n.status':{'pattern':CMIIndex, 'format':CMIStatus2, 'mod':'rw', 'writeerror':'405'}, 'cmi.student_data.tries.n.time':{'pattern':CMIIndex, 'format':CMITime, 'mod':'rw', 'writeerror':'405'}, - 'cmi.student_data.mastery_score':{'defaultvalue':'masteryscore ?>', 'mod':'r', 'writeerror':'403'}, - 'cmi.student_data.max_time_allowed':{'defaultvalue':'maxtimeallowed ?>', 'mod':'r', 'writeerror':'403'}, - 'cmi.student_data.time_limit_action':{'defaultvalue':'timelimitaction ?>', 'mod':'r', 'writeerror':'403'}, + 'cmi.student_data.mastery_score':{'defaultvalue':'masteryscore)?$userdata->masteryscore:'' ?>', 'mod':'r', 'writeerror':'403'}, + 'cmi.student_data.max_time_allowed':{'defaultvalue':'maxtimeallowed)?$userdata->maxtimeallowed:'' ?>', 'mod':'r', 'writeerror':'403'}, + 'cmi.student_data.time_limit_action':{'defaultvalue':'timelimitaction)?$userdata->timelimitaction:'' ?>', 'mod':'r', 'writeerror':'403'}, 'cmi.student_data.tries_during_lesson':{'defaultvalue':'{'cmi.student_data.tries_during_lesson'})?$userdata->{'cmi.student_data.tries_during_lesson'}:'' ?>', 'mod':'r', 'writeerror':'402'}, 'cmi.student_preference._children':{'defaultvalue':student_preference_children, 'mod':'r', 'writeerror':'402'}, 'cmi.student_preference.audio':{'defaultvalue':'0', 'format':CMISInteger, 'range':audio_range, 'mod':'rw', 'writeerror':'405'}, diff --git a/mod/scorm/datamodels/aicclib.php b/mod/scorm/datamodels/aicclib.php index b39a054d4a101..919a93c44ae53 100644 --- a/mod/scorm/datamodels/aicclib.php +++ b/mod/scorm/datamodels/aicclib.php @@ -171,6 +171,17 @@ function scorm_parse_aicc($pkgdir,$scormid) { } if (isset($id->ort)) { $rows = file($pkgdir.'/'.$id->ort); + $columns = scorm_get_aicc_columns($rows[0],'course_element'); + $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,'); + for ($i=1;$imastercol) { + $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1); + } + } + } + } } if (isset($id->pre)) { $rows = file($pkgdir.'/'.$id->pre); @@ -220,7 +231,8 @@ function scorm_parse_aicc($pkgdir,$scormid) { $sco->scorm = $scormid; $sco->organization = $course->id; $sco->title = $element->title; - if (strtolower($element->parent) == 'root') { + + if (!isset($element->parent) || strtolower($element->parent) == 'root') { $sco->parent = '/'; } else { $sco->parent = $element->parent; @@ -228,37 +240,49 @@ function scorm_parse_aicc($pkgdir,$scormid) { if (isset($element->file_name)) { $sco->launch = $element->file_name; $sco->scormtype = 'sco'; - } else { - $element->file_name = ''; - $sco->scormtype = ''; - } - if (!isset($element->prerequisites)) { - $element->prerequisites = ''; - } - $sco->prerequisites = $element->prerequisites; - if (!isset($element->max_time_allowed)) { - $element->max_time_allowed = ''; - } - $sco->maxtimeallowed = $element->max_time_allowed; - if (!isset($element->time_limit_action)) { - $element->time_limit_action = ''; - } - $sco->timelimitaction = $element->time_limit_action; - if (!isset($element->mastery_score)) { - $element->mastery_score = ''; - } - $sco->masteryscore = $element->mastery_score; - $sco->previous = 0; - $sco->next = 0; - if ($oldscoid = scorm_array_search('identifier',$sco->identifier,$oldscoes)) { - $sco->id = $oldscoid; - $id = update_record('scorm_scoes',$sco); - unset($oldscoes[$oldscoid]); - } else { - $id = insert_record('scorm_scoes',$sco); - } - if ($launch==0) { - $launch = $id; + $sco->previous = 0; + $sco->next = 0; + $id = null; + if ($oldscoid = scorm_array_search('identifier',$sco->identifier,$oldscoes)) { + $sco->id = $oldscoid; + $id = update_record('scorm_scoes',$sco); + delete_records('scorm_scoes_data','scoid',$oldscoid); + unset($oldscoes[$oldscoid]); + } else { + $id = insert_record('scorm_scoes',$sco); + } + if (!empty($id)) { + unset($scodata); + $scodata->scoid = $id; + if (isset($element->web_launch)) { + $scodata->name = 'parameters'; + $scodata->value = $element->web_launch; + $dataid = insert_record('scorm_scoes_data',$scodata); + } + if (isset($element->prerequisites)) { + $scodata->name = 'prerequisites'; + $scodata->value = $element->prerequisites; + $dataid = insert_record('scorm_scoes_data',$scodata); + } + if (isset($element->max_time_allowed)) { + $scodata->name = 'max_time_allowed'; + $scodata->value = $element->max_time_allowed; + $dataid = insert_record('scorm_scoes_data',$scodata); + } + if (isset($element->time_limit_action)) { + $scodata->name = 'time_limit_action'; + $scodata->value = $element->time_limit_action; + $dataid = insert_record('scorm_scoes_data',$scodata); + } + if (isset($element->mastery_score)) { + $scodata->name = 'mastery_score'; + $scodata->value = $element->mastery_score; + $dataid = insert_record('scorm_scoes_data',$scodata); + } + } + if ($launch==0) { + $launch = $id; + } } } } @@ -285,7 +309,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n $scormpixdir = $CFG->modpixpath.'/scorm/pix'; $result = new stdClass(); - $result->toc = "