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 }
/** * Function to be run periodically according to the moodle cron * This function searches for things that need to be done, such * as sending out mail, toggling flags etc ... * * @return boolean */ function scorm_cron() { global $CFG; require_once 'locallib.php'; $sitetimezone = $CFG->timezone; /// Now see if there are any digest mails waiting to be sent, and if we should send them if (!isset($CFG->scorm_updatetimelast)) { // To catch the first time set_config('scorm_updatetimelast', 0); } $timenow = time(); $updatetime = usergetmidnight($timenow, $sitetimezone) + $CFG->scorm_updatetime * 3600; if ($CFG->scorm_updatetimelast < $updatetime and $timenow > $updatetime) { set_config('scorm_updatetimelast', $timenow); mtrace('Updating scorm packages which require daily update'); //We are updating $scormsupdate = get_records('scorm', 'updatefreq', UPDATE_EVERYDAY); if (!empty($scormsupdate)) { foreach ($scormsupdate as $scormupdate) { $scormupdate->instance = $scormupdate->id; $id = scorm_update_instance($scormupdate); } } } return true; }