. require_once('../../config.php'); require_once($CFG->dirroot.'/mod/scorm/locallib.php'); $id = optional_param('id', '', PARAM_INT); // Course Module ID, or $a = optional_param('a', '', PARAM_INT); // scorm ID $scoid = required_param('scoid', PARAM_INT); // sco ID. $delayseconds = 2; // Delay time before sco launch, used to give time to browser to define API. if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { print_error('invalidcoursemodule'); } if (! $course = $DB->get_record('course', array('id' => $cm->course))) { print_error('coursemisconf'); } if (! $scorm = $DB->get_record('scorm', array('id' => $cm->instance))) { print_error('invalidcoursemodule'); } } else if (!empty($a)) { if (! $scorm = $DB->get_record('scorm', array('id' => $a))) { print_error('coursemisconf'); } if (! $course = $DB->get_record('course', array('id' => $scorm->course))) { print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { print_error('invalidcoursemodule'); } } else { print_error('missingparameter'); } $PAGE->set_url('/mod/scorm/loadSCO.php', array('scoid' => $scoid, 'id' => $cm->id)); if (!isloggedin()) { // Prevent login page from being shown in iframe. // Using simple html instead of exceptions here as shown inside iframe/object. echo html_writer::start_tag('html'); echo html_writer::tag('head', ''); echo html_writer::tag('body', get_string('loggedinnot')); echo html_writer::end_tag('html'); exit; } require_login($course, false, $cm, false); // Call require_login anyway to set up globals correctly. // Check if SCORM is available. scorm_require_available($scorm); $context = context_module::instance($cm->id); // Forge SCO URL. list($sco, $scolaunchurl) = scorm_get_sco_and_launch_url($scorm, $scoid, $context); if ($sco->scormtype == 'asset') { $attempt = scorm_get_last_attempt($scorm->id, $USER->id); $element = (scorm_version_check($scorm->version, SCORM_13)) ? 'cmi.completion_status' : 'cmi.core.lesson_status'; $value = 'completed'; scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value); } // Trigger the SCO launched event. scorm_launch_sco($scorm, $sco, $cm, $context, $scolaunchurl); header('Content-Type: text/html; charset=UTF-8'); if ($sco->scormtype == 'asset') { // HTTP 302 Found => Moved Temporarily. header('Location: ' . $scolaunchurl); // Provide a short feedback in case of slow network connection. echo html_writer::start_tag('html'); echo html_writer::tag('body', html_writer::tag('p', get_string('activitypleasewait', 'scorm'))); echo html_writer::end_tag('html'); exit; } // We expect a SCO: select which API are we looking for. $lmsapi = (scorm_version_check($scorm->version, SCORM_12) || empty($scorm->version)) ? 'API' : 'API_1484_11'; echo html_writer::start_tag('html'); echo html_writer::start_tag('head'); echo html_writer::tag('title', 'LoadSCO'); ?> "doredirect();")); echo html_writer::end_tag('html');