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; }
// // TOC processing // $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe if (!file_exists($CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php')) { $scorm->version = 'scorm_12'; } require_once $CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php'; $attempt = scorm_get_last_attempt($scorm->id, $USER->id); if ($newattempt == 'on' && ($attempt < $scorm->maxattempt || $scorm->maxattempt == 0)) { $attempt++; $mode = 'normal'; } $attemptstr = '&attempt=' . $attempt; $result = scorm_get_toc($USER, $scorm, 'structurelist', $currentorg, $scoid, $mode, $attempt, true); $sco = $result->sco; if ($mode == 'browse' && $scorm->hidebrowse == 1) { $mode = 'normal'; } if ($mode != 'browse') { if ($trackdata = scorm_get_tracks($sco->id, $USER->id, $attempt)) { if ($trackdata->status == 'completed' || $trackdata->status == 'passed' || $trackdata->status == 'failed') { $mode = 'review'; } else { $mode = 'normal'; } } else { $mode = 'normal'; } }
function scorm_view_display($user, $scorm, $action, $cm, $boxwidth = '') { global $CFG; if ($scorm->updatefreq == UPDATE_EVERYTIME) { require_once $CFG->dirroot . '/mod/scorm/lib.php'; $scorm->instance = $scorm->id; scorm_update_instance($scorm); } $organization = optional_param('organization', '', PARAM_INT); print_simple_box_start('center', $boxwidth); ?> <div class="structurehead"><?php print_string('contents', 'scorm'); ?> </div> <?php if (empty($organization)) { $organization = $scorm->launch; } if ($orgs = get_records_select_menu('scorm_scoes', "scorm='{$scorm->id}' AND organization='' AND launch=''", 'id', 'id,title')) { if (count($orgs) > 1) { ?> <div class='scorm-center'> <?php print_string('organizations', 'scorm'); ?> <form id='changeorg' method='post' action='<?php echo $action; ?> '> <?php choose_from_menu($orgs, 'organization', "{$organization}", '', 'submit()'); ?> </form> </div> <?php } } $orgidentifier = ''; if ($sco = scorm_get_sco($organization, SCO_ONLY)) { if ($sco->organization == '' && $sco->launch == '') { $orgidentifier = $sco->identifier; } else { $orgidentifier = $sco->organization; } } /* $orgidentifier = ''; if ($org = get_record('scorm_scoes','id',$organization)) { if (($org->organization == '') && ($org->launch == '')) { $orgidentifier = $org->identifier; } else { $orgidentifier = $org->organization; } }*/ $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe if (!file_exists($CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php')) { $scorm->version = 'scorm_12'; } require_once $CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php'; $result = scorm_get_toc($user, $scorm, 'structlist', $orgidentifier); $incomplete = $result->incomplete; echo $result->toc; print_simple_box_end(); ?> <div class="scorm-center"> <form id="theform" method="post" action="<?php echo $CFG->wwwroot; ?> /mod/scorm/player.php"> <?php if ($scorm->hidebrowse == 0) { print_string('mode', 'scorm'); echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">' . get_string('browse', 'scorm') . '</label>' . "\n"; echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">' . get_string('normal', 'scorm') . "</label>\n"; } else { echo '<input type="hidden" name="mode" value="normal" />' . "\n"; } if ($incomplete === false && ($result->attemptleft > 0 || $scorm->maxattempt == 0)) { ?> <br /> <input type="checkbox" id="a" name="newattempt" /> <label for="a"><?php print_string('newattempt', 'scorm'); ?> </label> <?php } ?> <br /> <input type="hidden" name="scoid"/> <input type="hidden" name="id" value="<?php echo $cm->id; ?> "/> <input type="hidden" name="currentorg" value="<?php echo $orgidentifier; ?> " /> <input type="submit" value="<?php print_string('enter', 'scorm'); ?> " /> </form> </div> <?php }
} } // TOC processing $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe if (!file_exists($CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php')) { $scorm->version = 'scorm_12'; } require_once $CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php'; $attempt = scorm_get_last_attempt($scorm->id, $USER->id); if ($newattempt == 'on' && ($attempt < $scorm->maxattempt || $scorm->maxattempt == 0)) { $attempt++; $mode = 'normal'; } $attemptstr = '&attempt=' . $attempt; $result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true); $sco = $result->sco; if ($mode == 'browse' && $scorm->hidebrowse == 1) { $mode = 'normal'; } if ($mode != 'browse') { if ($trackdata = scorm_get_tracks($sco->id, $USER->id, $attempt)) { if ($trackdata->status == 'completed' || $trackdata->status == 'passed' || $trackdata->status == 'failed') { $mode = 'review'; } else { $mode = 'normal'; } } else { $mode = 'normal'; } }
function scorm_view_display($user, $scorm, $action, $cm) { global $CFG, $DB, $PAGE, $OUTPUT; if ($scorm->updatefreq == UPDATE_EVERYTIME) { scorm_parse($scorm, false); } $organization = optional_param('organization', '', PARAM_INT); if ($scorm->displaycoursestructure == 1) { echo $OUTPUT->box_start('generalbox boxaligncenter toc'); ?> <div class="structurehead"><?php print_string('contents', 'scorm'); ?> </div> <?php } if (empty($organization)) { $organization = $scorm->launch; } if ($orgs = $DB->get_records_select_menu('scorm_scoes', 'scorm = ? AND ' . $DB->sql_isempty('scorm_scoes', 'launch', false, true) . ' AND ' . $DB->sql_isempty('scorm_scoes', 'organization', false, false), array($scorm->id), 'id', 'id,title')) { if (count($orgs) > 1) { $select = new single_select(new moodle_url($action), 'organization', $orgs, $organization, null); $select->label = get_string('organizations', 'scorm'); $select->class = 'scorm-center'; echo $OUTPUT->render($select); } } $orgidentifier = ''; if ($sco = scorm_get_sco($organization, SCO_ONLY)) { if ($sco->organization == '' && $sco->launch == '') { $orgidentifier = $sco->identifier; } else { $orgidentifier = $sco->organization; } } $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe if (!file_exists($CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php')) { $scorm->version = 'scorm_12'; } require_once $CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . 'lib.php'; $result = scorm_get_toc($user, $scorm, $cm->id, TOCFULLURL, $orgidentifier); $incomplete = $result->incomplete; // do we want the TOC to be displayed? if ($scorm->displaycoursestructure == 1) { echo $result->toc; echo $OUTPUT->box_end(); } // is this the first attempt ? $attemptcount = scorm_get_attempt_count($user->id, $scorm); // do not give the player launch FORM if the SCORM object is locked after the final attempt if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) { ?> <div class="scorm-center"> <form id="theform" method="post" action="<?php echo $CFG->wwwroot; ?> /mod/scorm/player.php"> <?php if ($scorm->hidebrowse == 0) { print_string('mode', 'scorm'); echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">' . get_string('browse', 'scorm') . '</label>' . "\n"; echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">' . get_string('normal', 'scorm') . "</label>\n"; } else { echo '<input type="hidden" name="mode" value="normal" />' . "\n"; } if ($scorm->forcenewattempt == 1) { if ($incomplete === false) { echo '<input type="hidden" name="newattempt" value="on" />' . "\n"; } } else { if (!empty($attemptcount) && $incomplete === false && ($result->attemptleft > 0 || $scorm->maxattempt == 0)) { ?> <br /> <input type="checkbox" id="a" name="newattempt" /> <label for="a"><?php print_string('newattempt', 'scorm'); ?> </label> <?php } } ?> <br /> <input type="hidden" name="scoid"/> <input type="hidden" name="cm" value="<?php echo $cm->id; ?> "/> <input type="hidden" name="currentorg" value="<?php echo $orgidentifier; ?> " /> <input type="submit" value="<?php print_string('enter', 'scorm'); ?> " /> </form> </div> <?php } }