本文整理汇总了PHP中scorm_parse函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_parse函数的具体用法?PHP scorm_parse怎么用?PHP scorm_parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_parse函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scorm_simple_play
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;
}
示例2: scorm_update_instance
/**
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will update an existing instance with new data.
*
* @param mixed $scorm Form data
* @return int
*/
function scorm_update_instance($scorm)
{
global $CFG;
require_once 'locallib.php';
$scorm->parse = 0;
if (($packagedata = scorm_check_package($scorm)) != null) {
$scorm->pkgtype = $packagedata->pkgtype;
if ($packagedata->launch == 0) {
$scorm->launch = $packagedata->launch;
$scorm->datadir = $packagedata->datadir;
$scorm->parse = 1;
if (!scorm_external_link($scorm->reference)) {
$scorm->md5hash = md5_file($CFG->dataroot . '/' . $scorm->course . '/' . $scorm->reference);
} else {
$scorm->dir = $CFG->dataroot . '/' . $scorm->course . '/moddata/scorm';
$scorm->md5hash = md5_file($scorm->dir . $scorm->datadir . '/' . basename($scorm->reference));
}
}
}
$scorm->timemodified = time();
$scorm->id = $scorm->instance;
$scorm = scorm_option2text($scorm);
$scorm->width = str_replace('%', '', $scorm->width);
$scorm->height = str_replace('%', '', $scorm->height);
if (!isset($scorm->whatgrade)) {
$scorm->whatgrade = 0;
}
$scorm->grademethod = $scorm->whatgrade * 10 + $scorm->grademethod;
// Check if scorm manifest needs to be reparsed
if ($scorm->parse == 1) {
$scorm->dir = $CFG->dataroot . '/' . $scorm->course . '/moddata/scorm';
if (is_dir($scorm->dir . '/' . $scorm->id)) {
scorm_delete_files($scorm->dir . '/' . $scorm->id);
}
if (isset($scorm->datadir) && $scorm->datadir != $scorm->id && (scorm_external_link($scorm->reference) || basename($scorm->reference) != 'imsmanifest.xml' && $scorm->reference[0] != '#')) {
rename($scorm->dir . $scorm->datadir, $scorm->dir . '/' . $scorm->id);
}
$scorm->launch = scorm_parse($scorm);
} else {
$oldscorm = get_record('scorm', 'id', $scorm->id);
$scorm->reference = $oldscorm->reference;
// This fix a problem with Firefox when the teacher choose Cancel on overwrite question
}
if ($result = update_record('scorm', $scorm)) {
scorm_grade_item_update(stripslashes_recursive($scorm));
}
return $result;
}
示例3: scorm_simple_play
function scorm_simple_play($scorm, $user)
{
$result = false;
if ($scorm->updatefreq == UPDATE_EVERYTIME) {
scorm_parse($scorm);
}
$scoes = get_records_select('scorm_scoes', 'scorm=' . $scorm->id . ' AND launch<>\'' . sql_empty() . '\'');
if ($scoes) {
if ($scorm->skipview >= 1) {
$sco = current($scoes);
if (scorm_get_tracks($sco->id, $user->id) === false) {
header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id);
$result = true;
} else {
if ($scorm->skipview == 2) {
header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id);
$result = true;
}
}
}
}
return $result;
}
示例4: scorm_cron
/**
* 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 ...
*
* @global stdClass
* @global object
* @return boolean
*/
function scorm_cron () {
global $CFG, $DB;
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$sitetimezone = $CFG->timezone;
// Now see if there are any scorm updates to be done.
if (!isset($CFG->scorm_updatetimelast)) { // To catch the first time.
set_config('scorm_updatetimelast', 0);
}
$timenow = time();
$updatetime = usergetmidnight($timenow, $sitetimezone);
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 = $DB->get_records('scorm', array('updatefreq' => SCORM_UPDATE_EVERYDAY));
foreach ($scormsupdate as $scormupdate) {
scorm_parse($scormupdate, true);
}
// Now clear out AICC session table with old session data.
$cfgscorm = get_config('scorm');
if (!empty($cfgscorm->allowaicchacp)) {
$expiretime = time() - ($cfgscorm->aicchacpkeepsessiondata * 24 * 60 * 60);
$DB->delete_records_select('scorm_aicc_session', 'timemodified < ?', array($expiretime));
}
}
return true;
}
示例5: scorm_simple_play
function scorm_simple_play($scorm, $user, $context)
{
global $DB;
$result = false;
if ($scorm->updatefreq == UPDATE_EVERYTIME) {
scorm_parse($scorm, 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;
}
$scoes = $DB->get_records_select('scorm_scoes', 'scorm = ? AND ' . $DB->sql_isnotempty('scorm_scoes', 'launch', false, true), array($scorm->id), '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 >= 1) {
$sco = current($scoes);
if (scorm_get_tracks($sco->id, $user->id) === false) {
header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id . '¤torg=' . $orgidentifier);
$result = true;
} else {
if ($scorm->skipview == 2) {
header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id . '¤torg=' . $orgidentifier);
$result = true;
}
}
}
}
return $result;
}
示例6: array
$scorm->id = $scormid;
$scorm->reference = $filename;
$scorm->md5hash = '';
$scorm->sha1hash = $hash;
$DB->update_record('scorm', $scorm);
// 2. The 'instance' field in the {course_modules} table of the record,
// where ('id' => $scorm->coursemodule) is set to the new record ID from step 1
$DB->set_field('course_modules', 'instance', $scormid, array('id' => $cmid));
// Get the whole SCORM object data
$scorm = $DB->get_record('scorm', array('id' => $scormid));
// Extra fields required in grade related functions.
$scorm->course = $courseid;
$scorm->cmidnumber = '';
$scorm->cmid = $cmid;
xlog("Configuring SCORM module '{$scormname}'");
scorm_parse($scorm, true);
scorm_grade_item_update($scorm);
// Specific settings for the SCORM package
$scormsettings = new stdClass();
$scormsettings->id = $scormid;
$scormsettings->introformat = 0;
$scormsettings->maxgrade = 100;
$scormsettings->grademethod = 1;
$scormsettings->whatgrade = 0;
$scormsettings->maxattempt = 0;
$scormsettings->forcecompleted = 1;
$scormsettings->forcenewattempt = 1;
$scormsettings->lastattemptlock = 0;
$scormsettings->displayattemptstatus = 0;
$scormsettings->displaycoursestructure = 0;
$scormsettings->updatefreq = 0;
示例7: scorm_cron
/**
* 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 ...
*
* @global stdClass
* @global object
* @return boolean
*/
function scorm_cron()
{
global $CFG, $DB;
require_once $CFG->dirroot . '/mod/scorm/locallib.php';
$sitetimezone = $CFG->timezone;
/// Now see if there are any scorm updates to be done
if (!isset($CFG->scorm_updatetimelast)) {
// To catch the first time
set_config('scorm_updatetimelast', 0);
}
$timenow = time();
$updatetime = usergetmidnight($timenow, $sitetimezone);
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 = $DB->get_records('scorm', array('updatefreq' => UPDATE_EVERYDAY));
foreach ($scormsupdate as $scormupdate) {
scorm_parse($scormupdate, true);
}
}
return true;
}
示例8: scorm_simple_play
function scorm_simple_play($scorm, $user, $context)
{
$result = false;
if ($scorm->updatefreq == UPDATE_EVERYTIME) {
scorm_parse($scorm);
}
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;
}
$scoes = get_records_select('scorm_scoes', 'scorm=' . $scorm->id . ' AND launch<>\'' . sql_empty() . '\'', 'id', 'id');
if ($scoes) {
if ($scorm->skipview >= 1) {
$sco = current($scoes);
if (scorm_get_tracks($sco->id, $user->id) === false) {
header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id);
$result = true;
} else {
if ($scorm->skipview == 2) {
header('Location: player.php?a=' . $scorm->id . '&scoid=' . $sco->id);
$result = true;
}
}
}
}
return $result;
}