本文整理汇总了PHP中scorm_get_sco函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_get_sco函数的具体用法?PHP scorm_get_sco怎么用?PHP scorm_get_sco使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_get_sco函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scorm_view_display
function scorm_view_display($user, $scorm, $action, $cm, $boxwidth = '')
{
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');
?>
<div class="structurehead"><?php
print_string('contents', 'scorm');
?>
</div>
<?php
}
if (empty($organization)) {
$organization = $scorm->launch;
}
if ($orgs = $DB->get_records_menu('scorm_scoes', array('scorm' => $scorm->id, 'organization' => '', '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
$select = new html_select();
$select->options = $orgs;
$select->name = 'organization';
$select->selectedvalue = $organization;
$select->add_action('change', 'submit_form_by_id', array('id' => 'changeorg'));
echo $OUTPUT->select($select);
?>
</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 = $DB->get_record('scorm_scoes', array('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;
// 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, $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";
}
} elseif ($attemptcount != 0 && $incomplete === false && ($result->attemptleft > 0 || $scorm->maxattempt == 0)) {
?>
<br />
<input type="checkbox" id="a" name="newattempt" />
<label for="a"><?php
//.........这里部分代码省略.........
示例2: scorm_check_launchable_sco
/**
* Check if the current sco is launchable
* If not, find the next launchable sco
*
* @param stdClass $scorm Scorm object
* @param integer $scoid id of scorm_scoes record.
* @return integer scoid of correct sco to launch or empty if one cannot be found, which will trigger first sco.
*/
function scorm_check_launchable_sco($scorm, $scoid) {
global $DB;
if ($sco = scorm_get_sco($scoid, SCO_ONLY)) {
if ($sco->launch == '') {
// This scoid might be a top level org that can't be launched, find the first launchable sco after this sco.
$scoes = $DB->get_records_select('scorm_scoes',
'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true).
' AND id > ?', array($scorm->id, $sco->id), 'sortorder, id', 'id', 0, 1);
if (!empty($scoes)) {
$sco = reset($scoes); // Get first item from the list.
return $sco->id;
}
} else {
return $sco->id;
}
}
// Returning 0 will cause default behaviour which will find the first launchable sco in the package.
return 0;
}
示例3: scorm_get_parent
function scorm_get_parent($sco)
{
global $DB;
if ($sco->parent != '/') {
if ($parent = $DB->get_record('scorm_scoes', array('scorm' => $sco->scorm, 'identifier' => $sco->parent))) {
return scorm_get_sco($parent->id);
}
}
return null;
}
示例4: JLMS_LoadSCOSCORM
function JLMS_LoadSCOSCORM($option)
{
global $JLMS_DB, $my, $Itemid;
$JLMS_CONFIG =& JLMSFactory::getConfig();
$id = intval(mosGetParam($_REQUEST, 'id', 0));
$delayseconds = 20;
// Delay time before sco launch, used to give time to browser to define API
$delayseconds_nojs = 2;
// if API were defined earlier than timer is passed - SCO will be launched
if ($id) {
$query = "SELECT * FROM #__lms_n_scorm WHERE id = {$id}";
$JLMS_DB->SetQuery($query);
$scorm = $JLMS_DB->LoadObject();
if (is_object($scorm)) {
$scoid = intval(mosGetParam($_REQUEST, 'scoid', 0));
if (!empty($scoid)) {
//
// Direct SCO request
//
if ($sco = scorm_get_sco($scoid)) {
// (DEN) check if this $scoid from our SCORM !!!!
if ($sco->launch == '') {
// Search for the next launchable sco
$query = "SELECT * FROM #__lms_n_scorm_scoes WHERE scorm = {$scorm->id} AND launch <> '' AND id > {$sco->id} ORDER BY id ASC";
$JLMS_DB->SetQuery($query);
$scoes = $JLMS_DB->LoadObjectList();
//if ($scoes = get_records_select('scorm_scoes','scorm='.$scorm->id." AND launch<>'' AND id>".$sco->id,'id ASC')) {
if (!empty($scoes)) {
$sco = current($scoes);
}
}
}
}
//
// If no sco was found get the first of SCORM package
//
if (!isset($sco)) {
$query = "SELECT * FROM #__lms_n_scorm_scoes WHERE scorm = {$scorm->id} AND launch <> '' ORDER BY id ASC";
$JLMS_DB->SetQuery($query);
$scoes = $JLMS_DB->LoadObjectList();
//$scoes = get_records_select('scorm_scoes','scorm='.$scorm->id." AND launch<>''",'id ASC');
$sco = current($scoes);
}
if (!empty($sco)) {
if ($sco->scormtype == 'asset') {
$attempt = scorm_get_last_attempt($scorm->id, $my->id);
$element = $scorm->version == 'scorm_13' ? 'cmi.completion_status' : 'cmi.core.lesson_status';
$value = 'completed';
$result = scorm_insert_track($my->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
}
//
// Forge SCO URL
//
$connector = '';
$version = substr($scorm->version, 0, 4);
if (isset($sco->parameters) && !empty($sco->parameters) || $version == 'AICC') {
/**
* 06.10.2007 (DEN) "''." - is added for compatibility with Joomla compatibility :)) library compat.php50x.php (on line 105 in PHP 4.4.7 there was a notice)
*/
if (stripos('' . $sco->launch, '?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
if (isset($sco->parameters) && !empty($sco->parameters) && $sco->parameters[0] == '?') {
$sco->parameters = substr($sco->parameters, 1);
}
}
if ($version == 'AICC') {
if (isset($sco->parameters) && !empty($sco->parameters)) {
$sco->parameters = '&' . $sco->parameters;
}
//$launcher = $sco->launch.$connector.'aicc_sid='.$my->id.'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
$launcher = $sco->launch . $connector . 'aicc_sid=' . $my->id . '&aicc_url=' . $JLMS_CONFIG->get('live_site') . "/index.php?option={$option}&Itemid={$Itemid}&task=aicc_task&course_id={$course_id}" . $sco->parameters;
// (DEN) check this URL /\ !!!!!!!!!
} else {
if (isset($sco->parameters) && !empty($sco->parameters)) {
$launcher = $sco->launch . $connector . $sco->parameters;
} else {
$launcher = $sco->launch;
}
}
$query = "SELECT * FROM #__lms_scorm_packages WHERE id = {$scorm->scorm_package}";
$JLMS_DB->SetQuery($query);
$scorm_ref = $JLMS_DB->LoadObject();
//$reference = $CFG->dataroot.'/'.$courseid.'/'.$reference;
//$row->reference = _JOOMLMS_SCORM_FOLDER_PATH . "/" . $scorm_ref->package_srv_name;
$reference_folder = $JLMS_CONFIG->get('live_site') . "/" . _JOOMLMS_SCORM_PLAYER . "/" . $scorm_ref->folder_srv_name;
//$reference_folder = _JOOMLMS_SCORM_FOLDER_PATH . "/" . $scorm_ref->folder_srv_name;
// (DEN) we don't use external links nor repositry (but maybe...maybe...)
/*if (scorm_external_link($sco->launch)) {
// Remote learning activity
$result = $launcher;
} else if ($scorm->reference[0] == '#') {
// Repository
require_once($repositoryconfigfile);
$result = $CFG->repositorywebroot.substr($scorm->reference,1).'/'.$sco->launch;
} else {*/
if (true) {
//.........这里部分代码省略.........
示例5: scorm_get_sco_and_launch_url
/**
* Return a SCO object and the SCO launch URL
*
* @param stdClass $scorm SCORM object
* @param int $scoid The SCO id in database
* @param stdClass $context context object
* @return array the SCO object and URL
* @since Moodle 3.1
*/
function scorm_get_sco_and_launch_url($scorm, $scoid, $context) {
global $CFG, $DB;
if (!empty($scoid)) {
// Direct SCO request.
if ($sco = scorm_get_sco($scoid)) {
if ($sco->launch == '') {
// Search for the next launchable sco.
if ($scoes = $DB->get_records_select(
'scorm_scoes',
'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true).' AND id > ?',
array($scorm->id, $sco->id),
'sortorder, id')) {
$sco = current($scoes);
}
}
}
}
// If no sco was found get the first of SCORM package.
if (!isset($sco)) {
$scoes = $DB->get_records_select(
'scorm_scoes',
'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true),
array($scorm->id),
'sortorder, id'
);
$sco = current($scoes);
}
$connector = '';
$version = substr($scorm->version, 0, 4);
if ((isset($sco->parameters) && (!empty($sco->parameters))) || ($version == 'AICC')) {
if (stripos($sco->launch, '?') !== false) {
$connector = '&';
} else {
$connector = '?';
}
if ((isset($sco->parameters) && (!empty($sco->parameters))) && ($sco->parameters[0] == '?')) {
$sco->parameters = substr($sco->parameters, 1);
}
}
if ($version == 'AICC') {
require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
$aiccsid = scorm_aicc_get_hacp_session($scorm->id);
if (empty($aiccsid)) {
$aiccsid = sesskey();
}
$scoparams = '';
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$scoparams = '&'. $sco->parameters;
}
$launcher = $sco->launch.$connector.'aicc_sid='.$aiccsid.'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$scoparams;
} else {
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$launcher = $sco->launch.$connector.$sco->parameters;
} else {
$launcher = $sco->launch;
}
}
if (scorm_external_link($sco->launch)) {
// TODO: does this happen?
$scolaunchurl = $launcher;
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
// Remote learning activity.
$scolaunchurl = dirname($scorm->reference).'/'.$launcher;
} else if ($scorm->scormtype === SCORM_TYPE_LOCAL && strtolower($scorm->reference) == 'imsmanifest.xml') {
// This SCORM content sits in a repository that allows relative links.
$scolaunchurl = "$CFG->wwwroot/pluginfile.php/$context->id/mod_scorm/imsmanifest/$scorm->revision/$launcher";
} else if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
// Note: do not convert this to use moodle_url().
// SCORM does not work without slasharguments and moodle_url() encodes querystring vars.
$scolaunchurl = "$CFG->wwwroot/pluginfile.php/$context->id/mod_scorm/content/$scorm->revision/$launcher";
}
return array($sco, $scolaunchurl);
}
示例6: scorm_randomize_children_process
function scorm_randomize_children_process($scoid, $userid)
{
$sco = scorm_get_sco($scoid);
if (!scorm_is_leaf($sco)) {
if (!scorm_seq_is('suspended', $scoid, $userid) && !scorm_seq_is('active', $scoid, $userid)) {
$r = get_record('scorm_scoes_track', 'scoid', $scoid, 'userid', $userid, 'element', 'randomizationtiming');
switch ($r->value) {
case 'never':
break;
case 'oneachnewattempt':
case 'once':
if (!scorm_seq_is('activityprogressstatus', $scoid, $userid)) {
if (scorm_seq_is('randomizechildren', $scoid, $userid)) {
$childlist = array();
$res = scorm_get_available_children($sco);
$i = sizeof($res) - 1;
$children = $res->value;
while ($i >= 0) {
$pos = array_rand($children);
array_push($childlist, $children[$pos]);
array_splice($children, $pos, 1);
$i--;
}
$clist = serialize($childlist);
scorm_seq_set('availablechildren', $scoid, $userid, false);
scorm_seq_set('availablechildren', $scoid, $userid, $clist);
}
}
break;
}
}
}
}
示例7: scorm_get_toc
function scorm_get_toc($user, $scorm, $liststyle, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false, $tocheader = false)
{
global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll', 'scorm');
$modestr = '';
if ($mode == 'browse') {
$modestr = '&mode=' . $mode;
}
$result = new stdClass();
//$result->toc = "<ul id='s0' class='$liststyle'>\n";
if ($tocheader) {
$result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">';
$result->toc .= '<div id="scorm_tree">';
}
$result->toc .= '<ul>';
$tocmenus = array();
$result->prerequisites = true;
$incomplete = false;
//
// Get the current organization infos
//
if (!empty($currentorg)) {
if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm' => $scorm->id, 'identifier' => $currentorg))) != '') {
if ($play) {
$result->toctitle = "{$organizationtitle}";
} else {
$result->toc .= "\t<li>{$organizationtitle}</li>\n";
}
$tocmenus[] = $organizationtitle;
}
}
//
// If not specified retrieve the last attempt number
//
if (empty($attempt)) {
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
}
$result->attemptleft = $scorm->maxattempt - $attempt;
if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
//
// Retrieve user tracking data for each learning object
//
$usertracks = array();
foreach ($scoes as $sco) {
if (!empty($sco->launch)) {
if (empty($scoid)) {
$scoid = $sco->id;
}
if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) {
if ($usertrack->status == '') {
$usertrack->status = 'notattempted';
}
$usertracks[$sco->identifier] = $usertrack;
}
}
}
$level = 0;
$sublist = 1;
$previd = 0;
$nextid = 0;
$findnext = false;
$parents[$level] = '/';
foreach ($scoes as $pos => $sco) {
$isvisible = false;
$sco->title = $sco->title;
if (!isset($sco->isvisible) || isset($sco->isvisible) && $sco->isvisible == 'true') {
$isvisible = true;
}
if ($parents[$level] != $sco->parent) {
if ($newlevel = array_search($sco->parent, $parents)) {
for ($i = 0; $i < $level - $newlevel; $i++) {
$result->toc .= "\t\t</li></ul></li>\n";
}
$level = $newlevel;
} else {
$i = $level;
$closelist = '';
while ($i > 0 && $parents[$level] != $sco->parent) {
$closelist .= "\t\t</li></ul></li>\n";
$i--;
}
if ($i == 0 && $sco->parent != $currentorg) {
$style = '';
if (isset($_COOKIE['hide:SCORMitem' . $sco->id])) {
$style = ' style="display: none;"';
}
//$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
$result->toc .= "\t\t<ul>\n";
$level++;
} else {
$result->toc .= $closelist;
$level = $i;
}
$parents[$level] = $sco->parent;
}
}
if ($isvisible) {
$result->toc .= "\t\t<li>";
}
//.........这里部分代码省略.........
示例8: get_scorm_default
/**
* Sets up $userdata array and default values for AICC package.
*
* @param stdClass $userdata an empty stdClass variable that should be set up with user values
* @param object $scorm package record
* @param string $scoid SCO Id
* @param string $attempt attempt number for the user
* @param string $mode scorm display mode type
* @return array The default values that should be used for AICC package
*/
function get_scorm_default(&$userdata, $scorm, $scoid, $attempt, $mode)
{
global $USER;
$aiccuserid = get_config('scorm', 'aiccuserid');
if (!empty($aiccuserid)) {
$userdata->student_id = $USER->id;
} else {
$userdata->student_id = $USER->username;
}
$userdata->student_name = $USER->lastname . ', ' . $USER->firstname;
if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) {
foreach ($usertrack as $key => $value) {
$userdata->{$key} = $value;
}
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
foreach ($scodatas as $key => $value) {
$userdata->{$key} = $value;
}
} else {
print_error('cannotfindsco', 'scorm');
}
if (!($sco = scorm_get_sco($scoid))) {
print_error('cannotfindsco', 'scorm');
}
$userdata->mode = 'normal';
if (!empty($mode)) {
$userdata->mode = $mode;
}
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
if (isset($userdata->status)) {
if ($userdata->status == '') {
$userdata->entry = 'ab-initio';
} else {
if (isset($userdata->{'cmi.core.exit'}) && $userdata->{'cmi.core.exit'} == 'suspend') {
$userdata->entry = 'resume';
} else {
$userdata->entry = '';
}
}
}
$def = array();
$def['cmi.core.student_id'] = $userdata->student_id;
$def['cmi.core.student_name'] = $userdata->student_name;
$def['cmi.core.credit'] = $userdata->credit;
$def['cmi.core.entry'] = $userdata->entry;
$def['cmi.launch_data'] = scorm_isset($userdata, 'datafromlms');
$def['cmi.core.lesson_mode'] = $userdata->mode;
$def['cmi.student_data.attempt_number'] = scorm_isset($userdata, 'cmi.student_data.attempt_number');
$def['cmi.student_data.mastery_score'] = scorm_isset($userdata, 'mastery_score');
$def['cmi.student_data.max_time_allowed'] = scorm_isset($userdata, 'max_time_allowed');
$def['cmi.student_data.time_limit_action'] = scorm_isset($userdata, 'time_limit_action');
$def['cmi.student_data.tries_during_lesson'] = scorm_isset($userdata, 'cmi.student_data.tries_during_lesson');
$def['cmi.core.lesson_location'] = scorm_isset($userdata, 'cmi.core.lesson_location');
$def['cmi.core.lesson_status'] = scorm_isset($userdata, 'cmi.core.lesson_status');
$def['cmi.core.exit'] = scorm_isset($userdata, 'cmi.core.exit');
$def['cmi.core.score.raw'] = scorm_isset($userdata, 'cmi.core.score.raw');
$def['cmi.core.score.max'] = scorm_isset($userdata, 'cmi.core.score.max');
$def['cmi.core.score.min'] = scorm_isset($userdata, 'cmi.core.score.min');
$def['cmi.core.total_time'] = scorm_isset($userdata, 'cmi.core.total_time', '00:00:00');
$def['cmi.suspend_data'] = scorm_isset($userdata, 'cmi.suspend_data');
$def['cmi.comments'] = scorm_isset($userdata, 'cmi.comments');
return $def;
}
示例9: scorm_seq_set
function scorm_seq_set($what, $scoid, $userid, $attempt = 0, $value = 'true')
{
/// set passed activity to active or not
if ($value == false) {
delete_record('scorm_scoes_track', 'scoid', $scoid, 'userid', $userid, 'element', $what);
} else {
$sco = scorm_get_sco($scoid);
scorm_insert_track($userid, $sco->scorm, $sco->id, 0, $what, $value);
}
}
示例10: array
$scorm = $DB->get_record("scorm", array("id" => $cm->instance), '*', MUST_EXIST);
} else {
if (!empty($a)) {
$scorm = $DB->get_record("scorm", array("id" => $a), '*', MUST_EXIST);
$course = $DB->get_record("course", array("id" => $scorm->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id, false, MUST_EXIST);
} else {
print_error('missingparameter');
}
}
$PAGE->set_url('/mod/scorm/datamodels/sequencinghandler.php', array('scoid' => $scoid, 'attempt' => $attempt, 'id' => $cm->id, 'function' => $function, 'request' => $request));
require_login($course, false, $cm);
if (!empty($scoid) && !empty($function)) {
require_once $CFG->dirroot . '/mod/scorm/datamodels/scorm_13lib.php';
if (has_capability('mod/scorm:savetrack', context_module::instance($cm->id))) {
$result = null;
switch ($function) {
case 'scorm_seq_flow':
if ($request == 'forward' || $request == 'backward') {
$seq = scorm_seq_navigation($scoid, $USER->id, $request . '_', $attempt);
$sco = scorm_get_sco($scoid);
$seq = scorm_seq_flow($sco, $request, $seq, true, $USER->id);
if (!empty($seq->nextactivity)) {
scorm_seq_end_attempt($sco, $USER->id, $seq);
}
}
echo json_encode($seq);
break;
}
}
}
示例11: addslashes
} else {
$userdata->status = '';
$userdata->score_raw = '';
}
$userdata->student_id = addslashes($USER->username);
$userdata->student_name = addslashes($USER->lastname . ', ' . $USER->firstname);
$userdata->mode = 'normal';
if (isset($mode)) {
$userdata->mode = $mode;
}
if ($userdata->mode == 'normal') {
$userdata->credit = 'credit';
} else {
$userdata->credit = 'no-credit';
}
if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) {
foreach ($scodatas as $key => $value) {
$userdata->{$key} = $value;
}
} else {
error('Sco not found');
}
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR));
// Just to be safe
if (file_exists($CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . '.js.php')) {
include_once $CFG->dirroot . '/mod/scorm/datamodels/' . $scorm->version . '.js.php';
} else {
include_once $CFG->dirroot . '/mod/scorm/datamodels/scorm_12.js.php';
}
?>
示例12: require_login
$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 = '';
if (isset($courseformat->coursedisplay) && $courseformat->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
$sectionid = $cm->sectionnum;
示例13: scorm_get_toc
function scorm_get_toc($user, $scorm, $cmid, $toclink = TOCJSLINK, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false, $tocheader = false)
{
global $CFG, $DB, $OUTPUT;
if (empty($attempt)) {
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
}
$result = new stdClass();
$organizationsco = null;
if ($tocheader) {
$result->toc = html_writer::start_div('yui3-g-r', array('id' => 'scorm_layout'));
$result->toc .= html_writer::start_div('yui3-u-1-5', array('id' => 'scorm_toc'));
$result->toc .= html_writer::div('', '', array('id' => 'scorm_toc_title'));
$result->toc .= html_writer::start_div('', array('id' => 'scorm_tree'));
}
if (!empty($currentorg)) {
$organizationsco = $DB->get_record('scorm_scoes', array('scorm' => $scorm->id, 'identifier' => $currentorg));
if (!empty($organizationsco->title)) {
if ($play) {
$result->toctitle = $organizationsco->title;
}
}
}
$scoes = scorm_get_toc_object($user, $scorm, $currentorg, $scoid, $mode, $attempt, $play, $organizationsco);
$treeview = scorm_format_toc_for_treeview($user, $scorm, $scoes['scoes'][0]->children, $scoes['usertracks'], $cmid, $toclink, $currentorg, $attempt, $play, $organizationsco, false);
if ($tocheader) {
$result->toc .= $treeview->toc;
} else {
$result->toc = $treeview->toc;
}
if (!empty($scoes['scoid'])) {
$scoid = $scoes['scoid'];
}
if (empty($scoid)) {
// If this is a normal package with an org sco and child scos get the first child.
if (!empty($scoes['scoes'][0]->children)) {
$result->sco = $scoes['scoes'][0]->children[0];
} else {
// This package only has one sco - it may be a simple external AICC package.
$result->sco = $scoes['scoes'][0];
}
} else {
$result->sco = scorm_get_sco($scoid);
}
if ($scorm->hidetoc == SCORM_TOC_POPUP) {
$tocmenu = scorm_format_toc_for_droplist($scorm, $scoes['scoes'][0]->children, $scoes['usertracks'], $currentorg, $organizationsco);
$modestr = '';
if ($mode != 'normal') {
$modestr = '&mode=' . $mode;
}
$url = new moodle_url('/mod/scorm/player.php?a=' . $scorm->id . '¤torg=' . $currentorg . $modestr);
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenu, $result->sco->id, null, "tocmenu");
}
$result->prerequisites = $treeview->prerequisites;
$result->incomplete = $treeview->incomplete;
$result->attemptleft = $treeview->attemptleft;
if ($tocheader) {
$result->toc .= html_writer::end_div() . html_writer::end_div();
$result->toc .= html_writer::start_div('', array('id' => 'scorm_toc_toggle'));
$result->toc .= html_writer::tag('button', '', array('id' => 'scorm_toc_toggle_btn')) . html_writer::end_div();
$result->toc .= html_writer::start_div('', array('id' => 'scorm_content'));
$result->toc .= html_writer::div('', '', array('id' => 'scorm_navpanel'));
$result->toc .= html_writer::end_div() . html_writer::end_div();
}
return $result;
}
示例14: get_scorm_sco_tracks
/**
* Retrieves SCO tracking data for the given user id and attempt number
*
* @param int $scoid the sco id
* @param int $userid the user id
* @param int $attempt the attempt number
* @return array warnings and the scoes data
* @since Moodle 3.0
*/
public static function get_scorm_sco_tracks($scoid, $userid, $attempt = 0)
{
global $USER, $DB;
$params = self::validate_parameters(self::get_scorm_sco_tracks_parameters(), array('scoid' => $scoid, 'userid' => $userid, 'attempt' => $attempt));
$tracks = array();
$warnings = array();
$sco = scorm_get_sco($params['scoid'], SCO_ONLY);
if (!$sco) {
throw new moodle_exception('cannotfindsco', 'scorm');
}
$scorm = $DB->get_record('scorm', array('id' => $sco->scorm), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
$context = context_module::instance($cm->id);
self::validate_context($context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
// Extra checks so only users with permissions can view other users attempts.
if ($USER->id != $user->id) {
require_capability('mod/scorm:viewreport', $context);
}
scorm_require_available($scorm, true, $context);
if (empty($params['attempt'])) {
$params['attempt'] = scorm_get_last_attempt($scorm->id, $user->id);
}
$attempted = false;
if ($scormtracks = scorm_get_tracks($sco->id, $params['userid'], $params['attempt'])) {
// Check if attempted.
if ($scormtracks->status != '') {
$attempted = true;
foreach ($scormtracks as $element => $value) {
$tracks[] = array('element' => $element, 'value' => $value);
}
}
}
if (!$attempted) {
$warnings[] = array('item' => 'attempt', 'itemid' => $params['attempt'], 'warningcode' => 'notattempted', 'message' => get_string('notattempted', 'scorm'));
}
$result = array();
$result['data']['attempt'] = $params['attempt'];
$result['data']['tracks'] = $tracks;
$result['warnings'] = $warnings;
return $result;
}
示例15: scorm_get_toc
function scorm_get_toc($user, $scorm, $liststyle, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false)
{
global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll', 'scorm');
$modestr = '';
if ($mode == 'browse') {
$modestr = '&mode=' . $mode;
}
$result = new stdClass();
$result->toc = "<ul id='s0' class='{$liststyle}'>\n";
$tocmenus = array();
$result->prerequisites = true;
$incomplete = false;
//
// Get the current organization infos
//
if (!empty($currentorg)) {
if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm' => $scorm->id, 'identifier' => $currentorg))) != '') {
$result->toc .= "\t<li>{$organizationtitle}</li>\n";
$tocmenus[] = $organizationtitle;
}
}
//
// If not specified retrieve the last attempt number
//
if (empty($attempt)) {
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
}
$result->attemptleft = $scorm->maxattempt - $attempt;
$conditions['scorm'] = $scorm->id;
if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
//
// Retrieve user tracking data for each learning object
//
$usertracks = array();
foreach ($scoes as $sco) {
if (!empty($sco->launch)) {
if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) {
if ($usertrack->status == '') {
$usertrack->status = 'notattempted';
}
$usertracks[$sco->identifier] = $usertrack;
}
}
}
$level = 0;
$sublist = 1;
$previd = 0;
$nextid = 0;
$findnext = false;
$parents[$level] = '/';
foreach ($scoes as $pos => $sco) {
$isvisible = false;
$sco->title = $sco->title;
if (!isset($sco->isvisible) || isset($sco->isvisible) && $sco->isvisible == 'true') {
$isvisible = true;
}
if ($parents[$level] != $sco->parent) {
if ($newlevel = array_search($sco->parent, $parents)) {
for ($i = 0; $i < $level - $newlevel; $i++) {
$result->toc .= "\t\t</ul></li>\n";
}
$level = $newlevel;
} else {
$i = $level;
$closelist = '';
while ($i > 0 && $parents[$level] != $sco->parent) {
$closelist .= "\t\t</ul></li>\n";
$i--;
}
if ($i == 0 && $sco->parent != $currentorg) {
$style = '';
if (isset($_COOKIE['hide:SCORMitem' . $sco->id])) {
$style = ' style="display: none;"';
}
$result->toc .= "\t\t<li><ul id='s{$sublist}' class='{$liststyle}'{$style}>\n";
$level++;
} else {
$result->toc .= $closelist;
$level = $i;
}
$parents[$level] = $sco->parent;
}
}
if ($isvisible) {
$result->toc .= "\t\t<li>";
}
if (isset($scoes[$pos + 1])) {
$nextsco = $scoes[$pos + 1];
} else {
$nextsco = false;
}
$nextisvisible = false;
if ($nextsco !== false && (!isset($nextsco->isvisible) || isset($nextsco->isvisible) && $nextsco->isvisible == 'true')) {
$nextisvisible = true;
}
if ($nextisvisible && $nextsco !== false && $sco->parent != $nextsco->parent && ($level == 0 || $level > 0 && $nextsco->parent == $sco->identifier)) {
$sublist++;
$icon = 'minus';
if (isset($_COOKIE['hide:SCORMitem' . $nextsco->id])) {
//.........这里部分代码省略.........