|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00017 require_once("../../config.php"); 00018 require_once('locallib.php'); 00019 00020 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or 00021 $a = optional_param('a', '', PARAM_INT); // scorm ID 00022 $scoid = required_param('scoid', PARAM_INT); // sco ID 00023 $mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode 00024 $attempt = required_param('attempt', PARAM_INT); // new attempt 00025 00026 //IE 6 Bug workaround 00027 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && ini_get('zlib.output_compression') == 'On') { 00028 ini_set('zlib.output_compression', 'Off'); 00029 } 00030 00031 if (!empty($id)) { 00032 if (! $cm = get_coursemodule_from_id('scorm', $id)) { 00033 print_error('invalidcoursemodule'); 00034 } 00035 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 00036 print_error('coursemisconf'); 00037 } 00038 if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) { 00039 print_error('invalidcoursemodule'); 00040 } 00041 } else if (!empty($a)) { 00042 if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) { 00043 print_error('invalidcoursemodule'); 00044 } 00045 if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) { 00046 print_error('coursemisconf'); 00047 } 00048 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { 00049 print_error('invalidcoursemodule'); 00050 } 00051 } else { 00052 print_error('missingparameter'); 00053 } 00054 00055 $url = new moodle_url('/mod/scorm/loaddatamodel.php', array('scoid'=>$scoid, 'id'=>$cm->id, 'attempt'=>$attempt)); 00056 if ($mode !== '') { 00057 $url->param('mode', $mode); 00058 } 00059 $PAGE->set_url($url); 00060 00061 require_login($course, false, $cm); 00062 00063 if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) { 00064 if ((isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} != 'time-out')) || (!scorm_version_check($scorm->version, SCORM_13))) { 00065 foreach ($usertrack as $key => $value) { 00066 $userdata->$key = addslashes_js($value); 00067 } 00068 } else { 00069 $userdata->status = ''; 00070 $userdata->score_raw = ''; 00071 } 00072 } else { 00073 $userdata->status = ''; 00074 $userdata->score_raw = ''; 00075 } 00076 $userdata->student_id = addslashes_js($USER->username); 00077 $userdata->student_name = addslashes_js($USER->lastname .', '. $USER->firstname); 00078 $userdata->mode = 'normal'; 00079 if (isset($mode)) { 00080 $userdata->mode = $mode; 00081 } 00082 if ($userdata->mode == 'normal') { 00083 $userdata->credit = 'credit'; 00084 } else { 00085 $userdata->credit = 'no-credit'; 00086 } 00087 if ($scodatas = scorm_get_sco($scoid, SCO_DATA)) { 00088 foreach ($scodatas as $key => $value) { 00089 $userdata->$key = addslashes_js($value); 00090 } 00091 } else { 00092 print_error('cannotfindsco', 'scorm'); 00093 } 00094 if (!$sco = scorm_get_sco($scoid)) { 00095 print_error('cannotfindsco', 'scorm'); 00096 } 00097 $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe 00098 if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) { 00099 include($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php'); 00100 } else { 00101 include($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php'); 00102 } 00103 // set the start time of this SCO 00104 scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, 'x.start.time', time()); 00105 ?> 00106 00107 var errorCode = "0"; 00108 function underscore(str) { 00109 str = String(str).replace(/.N/g,"."); 00110 return str.replace(/\./g,"__"); 00111 }