function opigno_scorm_ui_player_integrate_sco in Opigno 7
Integrate a SCO object and return it (wrapped if necessary).
This page callback bypasses the Drupal page rendering and includes the SCO directly.
Parameters
object $sco:
1 string reference to 'opigno_scorm_ui_player_integrate_sco'
- opigno_scorm_ui_menu in modules/
scorm/ ui/ opigno_scorm_ui.module - Implements hook_menu().
File
- modules/
scorm/ ui/ includes/ opigno_scorm_ui.player.inc, line 98 - Player logic.
Code
function opigno_scorm_ui_player_integrate_sco($sco) {
// @todo Use hooks for different SCO types.
// Does the SCO have a launch property ?
if (!empty($sco->launch)) {
$query = array();
// Load the SCO data.
$scorm = opigno_scorm_scorm_load($sco->scorm_id);
// Remove the URL parameters from the launch URL.
if (!empty($sco->attributes['parameters'])) {
$sco->launch .= $sco->attributes['parameters'];
}
$parts = explode('?', $sco->launch);
$launch = array_shift($parts);
if (!empty($parts)) {
// Failsafe - in case a launch URL has 2 or more '?'.
$parameters = implode('&', $parts);
}
// Get the SCO location on the filesystem
$sco_location = "{$scorm->extracted_dir}/{$launch}";
$sco_path = file_create_url($sco_location);
// Where there any parameters ? If so, prepare them for Drupal.
if (!empty($parameters)) {
foreach (explode('&', $parameters) as $param) {
list($key, $value) = explode('=', $param);
$query[$key] = !empty($value) ? $value : '';
}
}
drupal_goto($sco_path, array(
'query' => $query,
));
}
else {
drupal_not_found();
}
}