function opigno_scorm_extract_item_sequencing_objectives in Opigno 7
Extract the manifest SCO item sequencing objective.
This extracts sequencing objectives from an item. Objectives allow the system to know how to "grade" the SCORM object.
Parameters
array $item_manifest:
Return value
array
1 call to opigno_scorm_extract_item_sequencing_objectives()
- _opigno_scorm_extract_manifest_scos_items in modules/
scorm/ includes/ opigno_scorm.manifest.inc - Helper function to recursively extract the manifest SCO items.
File
- modules/
scorm/ includes/ opigno_scorm.manifest.inc, line 387 - Manifest file extraction logic.
Code
function opigno_scorm_extract_item_sequencing_objectives($item_manifest) {
$objectives = array();
foreach ($item_manifest['children'] as $child) {
if ($child['name'] == OPIGNO_SCORM_MANIFEST_OBJECTIVES) {
foreach ($child['children'] as $child_objective) {
if (!empty($child_objective['attrs'][OPIGNO_SCORM_MANIFEST_OBJECTIVE_ID_ATTR])) {
$id = $child_objective['attrs'][OPIGNO_SCORM_MANIFEST_OBJECTIVE_ID_ATTR];
}
else {
$id = uniqid();
}
if ($child_objective['name'] == OPIGNO_SCORM_MANIFEST_PRIMARY_OBJECTIVE) {
// Note: boolean attributes are stored as a strings. PHP does not know
// how to cast 'false' to FALSE. Use string comparisons to bypass
// this limitation by PHP. See below.
$satisfied_by_measure = FALSE;
if (!empty($child_objective['attrs'][OPIGNO_SCORM_MANIFEST_OBJECTIVE_SATISFIED_BY_MEASURE_ATTR])) {
$satisfied_by_measure = strtolower($child_objective['attrs'][OPIGNO_SCORM_MANIFEST_OBJECTIVE_SATISFIED_BY_MEASURE_ATTR]) === 'true';
}
$objective = array(
'primary' => TRUE,
'secondary' => FALSE,
'id' => $id,
'satisfied_by_measure' => $satisfied_by_measure,
);
foreach ($child_objective['children'] as $primary_obj_child) {
if ($primary_obj_child['name'] == OPIGNO_SCORM_MANIFEST_MIN_NORMALIZED_MEASURE) {
$objective['min_normalized_measure'] = $primary_obj_child['tagData'];
}
elseif ($primary_obj_child['name'] == OPIGNO_SCORM_MANIFEST_MAX_NORMALIZED_MEASURE) {
$objective['max_normalized_measure'] = $primary_obj_child['tagData'];
}
}
$objectives[] = $objective;
}
elseif ($child_objective['name'] == OPIGNO_SCORM_MANIFEST_OBJECTIVE) {
$objectives[] = array(
'primary' => FALSE,
'secondary' => TRUE,
'id' => $id,
);
}
}
}
}
return $objectives;
}