mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
82 lines
2.9 KiB
PHP
82 lines
2.9 KiB
PHP
<?php
|
|
|
|
require_once("../../config.php");
|
|
require_once('locallib.php');
|
|
|
|
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
|
|
$a = optional_param('a', '', PARAM_INT); // scorm ID
|
|
$scoid = required_param('scoid', PARAM_INT); // sco ID
|
|
$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
|
|
$attempt = required_param('attempt', PARAM_INT); // new attempt
|
|
|
|
if (!empty($id)) {
|
|
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
|
print_error('invalidcoursemodule');
|
|
}
|
|
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
|
print_error('coursemisconf');
|
|
}
|
|
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
|
print_error('invalidcoursemodule');
|
|
}
|
|
} else if (!empty($a)) {
|
|
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
|
print_error('invalidcoursemodule');
|
|
}
|
|
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
|
print_error('coursemisconf');
|
|
}
|
|
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
|
print_error('invalidcoursemodule');
|
|
}
|
|
} else {
|
|
print_error('missingparameter');
|
|
}
|
|
|
|
require_login($course->id, false, $cm);
|
|
|
|
if ($usertrack = scorm_get_tracks($scoid,$USER->id,$attempt)) {
|
|
if ((isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} != 'time-out')) || ($scorm->version != "SCORM_1.3")) {
|
|
foreach ($usertrack as $key => $value) {
|
|
$userdata->$key = addslashes_js($value);
|
|
}
|
|
} else {
|
|
$userdata->status = '';
|
|
$userdata->score_raw = '';
|
|
}
|
|
} else {
|
|
$userdata->status = '';
|
|
$userdata->score_raw = '';
|
|
}
|
|
$userdata->student_id = addslashes_js($USER->username);
|
|
$userdata->student_name = addslashes_js($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 = addslashes_js($value);
|
|
}
|
|
} else {
|
|
print_error('cannotfindsco', 'scorm');
|
|
}
|
|
$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');
|
|
}
|
|
?>
|
|
|
|
var errorCode = "0";
|
|
function underscore(str) {
|
|
str = String(str).replace(/.N/g,".");
|
|
return str.replace(/\./g,"__");
|
|
}
|