Example #1
0
function scorm_simple_play($scorm, $user, $context, $cmid)
{
    global $DB;
    $result = false;
    if (has_capability('mod/scorm:viewreport', $context)) {
        //if this user can view reports, don't skipview so they can see links to reports.
        return $result;
    }
    if ($scorm->scormtype != SCORM_TYPE_LOCAL && $scorm->updatefreq == SCORM_UPDATE_EVERYTIME) {
        scorm_parse($scorm, false);
    }
    $scoes = $DB->get_records_select('scorm_scoes', 'scorm = ? AND ' . $DB->sql_isnotempty('scorm_scoes', 'launch', false, true), array($scorm->id), 'sortorder, id', 'id');
    if ($scoes) {
        $orgidentifier = '';
        if ($sco = scorm_get_sco($scorm->launch, SCO_ONLY)) {
            if ($sco->organization == '' && $sco->launch == '') {
                $orgidentifier = $sco->identifier;
            } else {
                $orgidentifier = $sco->organization;
            }
        }
        if ($scorm->skipview >= SCORM_SKIPVIEW_FIRST) {
            $sco = current($scoes);
            $url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id, 'currentorg' => $orgidentifier, 'scoid' => $sco->id));
            if ($scorm->skipview == SCORM_SKIPVIEW_ALWAYS || !scorm_has_tracks($scorm->id, $user->id)) {
                if (!empty($scorm->forcenewattempt)) {
                    $result = scorm_get_toc($user, $scorm, $cmid, TOCFULLURL, $orgidentifier);
                    if ($result->incomplete === false) {
                        $url->param('newattempt', 'on');
                    }
                }
                redirect($url);
            }
        }
    }
    return $result;
}
Example #2
0
$forcejs = get_config('scorm', 'forcejavascript');
if (!empty($forcejs)) {
    $PAGE->add_body_class('forcejavascript');
}
require_login($course, false, $cm);
$context = context_course::instance($course->id);
$contextmodule = context_module::instance($cm->id);
$launch = false;
// Does this automatically trigger a launch based on skipview.
if (!empty($scorm->popup)) {
    $orgidentifier = '';
    $scoid = 0;
    if ($scorm->skipview >= SCORM_SKIPVIEW_FIRST && has_capability('mod/scorm:skipview', $contextmodule) && !has_capability('mod/scorm:viewreport', $contextmodule)) {
        // Don't skip users with the capability to view reports.
        // do we launch immediately and redirect the parent back ?
        if ($scorm->skipview == SCORM_SKIPVIEW_ALWAYS || !scorm_has_tracks($scorm->id, $USER->id)) {
            $orgidentifier = '';
            if ($sco = scorm_get_sco($scorm->launch, SCO_ONLY)) {
                if ($sco->organization == '' && $sco->launch == '') {
                    $orgidentifier = $sco->identifier;
                } else {
                    $orgidentifier = $sco->organization;
                }
                $scoid = $sco->id;
            }
            $launch = true;
        }
    }
    // Redirect back to the section with one section per page ?
    $courseformat = course_get_format($course)->get_course();
    $sectionid = '';