Exemple #1
0
}
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');
Exemple #2
0
 /**
  * Trigger the course module viewed event.
  *
  * @param int $scormid the SCORM instance id
  * @param int $scoid the SCO id
  * @return array of warnings and status result
  * @since Moodle 3.1
  * @throws moodle_exception
  */
 public static function launch_sco($scormid, $scoid = 0)
 {
     global $DB;
     $params = self::validate_parameters(self::launch_sco_parameters(), array('scormid' => $scormid, 'scoid' => $scoid));
     $warnings = array();
     // Request and permission validation.
     $scorm = $DB->get_record('scorm', array('id' => $params['scormid']), '*', MUST_EXIST);
     list($course, $cm) = get_course_and_cm_from_instance($scorm, 'scorm');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // If the SCORM is not open this function will throw exceptions.
     scorm_require_available($scorm);
     if (!empty($params['scoid']) and !($sco = scorm_get_sco($params['scoid'], SCO_ONLY))) {
         throw new moodle_exception('cannotfindsco', 'scorm');
     }
     list($sco, $scolaunchurl) = scorm_get_sco_and_launch_url($scorm, $params['scoid'], $context);
     // Trigger the SCO launched event.
     scorm_launch_sco($scorm, $sco, $cm, $context, $scolaunchurl);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }