function opigno_scorm_quiz_load_objective in Opigno 7
Load all objective data for the given SCORM.
Helper function to load objective CMI data that was stored. Pass the ID of the objective to fetch the data for it.
Parameters
int $uid:
int $scorm_id:
string $objective_id:
Return value
object|null
1 call to opigno_scorm_quiz_load_objective()
- opigno_scorm_quiz_opigno_scorm_ui_register_cmi_data in modules/
scorm/ quiz/ opigno_scorm_quiz.module - Implements hook_opigno_scorm_ui_register_cmi_data().
File
- modules/
scorm/ quiz/ opigno_scorm_quiz.module, line 405 - Module hook definitions.
Code
function opigno_scorm_quiz_load_objective($uid, $scorm_id, $objective_id) {
$objectives =& drupal_static(__FUNCTION__);
if (!isset($objectives)) {
// We query the database ourselves here instead of relying on opigno_scorm_scorm_cmi_get(),
// as we need a LIKE query.
$result = db_select('opigno_scorm_scorm_cmi_data', 'o')
->fields('o')
->condition('o.uid', $uid)
->condition('o.scorm_id', $scorm_id)
->condition('o.cmi_key', 'cmi.objectives.%', 'LIKE')
->execute();
while ($row = $result
->fetchObject()) {
// Make sure this is one of ours.
if (preg_match('/^cmi\\.objectives\\.[0-9]+$/', $row->cmi_key)) {
$data = unserialize($row->value);
// Allow modules to alter the data.
$context = array(
'uid' => $uid,
'scorm_id' => $scorm_id,
'original_value' => $data,
);
drupal_alter('opigno_scorm_scorm_cmi_get', $data, $row->cmi_key, $context);
$objectives[$data->id] = $data;
}
}
}
return isset($objectives[$objective_id]) ? $objectives[$objective_id] : NULL;
}