Permalink
Browse files

Several change to db fields, a complete redesign of user data track

  • Loading branch information...
1 parent cd0a36f commit 4928a2f3235d2f3cfec5940c3e74a665afc172d6 bobopinna committed Apr 1, 2005
View
@@ -4,6 +4,7 @@
optional_variable($id); // Course Module ID, or
optional_variable($a); // scorm ID
+ optional_variable($userid); // user ID
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -31,6 +32,12 @@
}
require_login($course->id, false, $cm);
+
+ if (empty($userid) || !isteacher($course->id)) {
+ $user = $USER;
+ } else {
+ $user = get_user_info_from_db('id', $userid);
+ }
?>
function SCOFinish(){
@@ -39,17 +46,8 @@ function SCOFinish(){
} */
}
-function closeMain() {
- if (document.all) {
- document.cookie = "SCORMpopup=" + escape(",top="+top.main.screenTop+",left="+top.main.screenLeft);
- } else {
- document.cookie = "SCORMpopup=" + escape(",top="+top.main.screenY+",left="+top.main.screenX);
- }
- top.main.close();
-}
-
//
-// SCORM API Implementation Call
+// SCORM Call Implementation
//
var errorCode = "0";
@@ -58,7 +56,7 @@ function SCORM_Call (call,param) {
alert ("Invalid SCORM_Call function call: too few arguments.\nYou need pass at least 2 parameters");
}
var myRequest = NewHttpReq();
- result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php?id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&call="+call+param);
+ result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&call="+call+param);
//alert('Call: '+call+'\nParam: '+param+'\nResult: '+result);
results = result.split('\n');
@@ -70,195 +68,9 @@ function SCORM_Call (call,param) {
// SCORM 1.2 API Implementation
//
function SCORMapi1_2() {
- var Initialized = false;
- <?php include_once ('datamodels/scorm1_2.js'); ?>
-
- function LMSInitialize (param) {
- if (param == "") {
- if (!Initialized) {
- Initialized = true;
- errorCode = "0";
- return "true";
- } else {
- errorCode = "101";
- }
- } else {
- errorCode = "201";
- }
- return "false";
- }
- function LMSFinish (param) {
- if (param == "") {
- if (Initialized) {
- LMSCommit("");
- Initialized = false;
- errorCode = "0";
- return "true";
- } else {
- errorCode = "301";
- }
- } else {
- errorCode = "201";
- }
- }
+ <?php include_once ('datamodels/scorm1_2.js.php'); ?>
- function LMSGetValue (element) {
- if (Initialized) {
- if (element !="") {
- expression = new RegExp(CMIIndex,'g');
- element = element.replace(expression,'.n.');
- if ((typeof eval('datamodel["'+element+'"]')) != "undefined") {
- if (eval('datamodel["'+element+'"].mod') != 'w') {
- errorCode = "0";
- return eval(element);
- } else {
- errorCode = eval('datamodel["'+element+'"].readerror');
- }
- } else {
- errorCode = "401"
- }
- } else {
- errorCode = "201";
- }
- } else {
- errorCode = "301";
- }
- return "";
- }
-
- function LMSSetValue (element,value) {
- if (Initialized) {
- if (element != "") {
- expression = new RegExp(CMIIndex,'g');
- elementmodel = element.replace(expression,'.n.');
- if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
- if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
- expression.compile(eval('datamodel["'+elementmodel+'"].format'));
- value = value+'';
- matches = value.match(expression);
- if (matches != null) {
- //Create dynamic data model element
- if (element != elementmodel) {
- elementIndexes = element.split('.');
- subelement = 'cmi';
- for (i=1;i<elementIndexes.length-1;i++) {
- elementIndex = elementIndexes[i];
- if (elementIndexes[i+1].match(/^\d+$/)) {
- //alert(eval(subelement+'.'+elementIndex+'._count')+1.0);
- //if (elementIndexes[i+1] > eval(subelement+'.'+elementIndex+'._count')) {
- // if (elementIndexes[i+1] == eval(subelement+'.'+elementIndex+'._count')) {
- // eval(subelement+'.'+elementIndex+'._count')+1.0;
- // }
- subelement = subelement.concat('.'+elementIndex+'_'+elementIndexes[i+1]);
- i++;
- //}
- } else {
- subelement = subelement.concat('.'+elementIndex);
- }
-
- if ((typeof eval(subelement)) == "undefined") {
- eval(subelement+' = new Object();');
- /*if (elementIndexes[i].match(/^\d+$/)) {
- alert(subelement.substring(0,subelement.length-elementIndexes[i]-1));
- if ((typeof eval(subelement.substring(0,subelement.length-elementIndexes[i]-1))) == "undefined") {
- // create new count
- }
- } */
- }
- }
- element = subelement.concat('.'+elementIndexes[elementIndexes.length-1]);
- //alert('LMSSetValue: '+element+'\nModel: '+elementmodel+'\nValue: '+value+'\nMatches: '+matches);
- }
- //Store data
- if ((typeof eval('datamodel["'+elementmodel+'"].range')) != "undefined") {
- range = eval('datamodel["'+elementmodel+'"].range');
- ranges = range.split('#');
- value = value+0.0;
- if ((value >= ranges[0]) && (value <= ranges[1])) {
- eval(element+'="'+value+'";');
- errorCode = "0";
- return "true";
- } else {
- errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
- }
- } else {
- eval(element+'="'+value+'";');
- errorCode = "0";
- return "true";
- }
- } else {
- errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
- }
- } else {
- errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
- }
- } else {
- errorCode = "401"
- }
- } else {
- errorCode = "201";
- }
- } else {
- errorCode = "301";
- }
- alert('LMSSetValue: '+element+'\nValue: '+value+'\nPattern: '+expression+'\nMatches: '+matches+'\nError Code: '+errorCode);
- return "false";
- }
-
- function LMSCommit (param) {
- if (param == "") {
- if (Initialized) {
- errorCode = "0";
- return "true";
- } else {
- errorCode = "301";
- }
- } else {
- errorCode = "201";
- }
- return "false";
- }
-
- function LMSGetLastError () {
- return errorCode;
- }
-
- function LMSGetErrorString (param) {
- if (param != "") {
- var errorString = new Array();
- errorString["0"] = "No error";
- errorString["101"] = "General exception";
- errorString["201"] = "Invalid argument error";
- errorString["202"] = "Element cannot have children";
- errorString["203"] = "Element not an array - cannot have count";
- errorString["301"] = "Not initialized";
- errorString["401"] = "Not implemented error";
- errorString["402"] = "Invalid set value, element is a keyword";
- errorString["403"] = "Element is read only";
- errorString["404"] = "Element is write only";
- errorString["405"] = "Incorrect data type";
- return errorString[param];
- } else {
- return "";
- }
- }
-
- function LMSGetDiagnostic (param) {
- if (param == "") {
- param = errorCode;
- }
- return param;
- }
-
- this.LMSInitialize = LMSInitialize;
- this.LMSFinish = LMSFinish;
- this.LMSGetValue = LMSGetValue;
- this.LMSSetValue = LMSSetValue;
- this.LMSCommit = LMSCommit;
- this.LMSGetLastError = LMSGetLastError;
- this.LMSGetErrorString = LMSGetErrorString;
- this.LMSGetDiagnostic = LMSGetDiagnostic;
}
var API = new SCORMapi1_2();
@@ -268,73 +80,8 @@ function LMSGetDiagnostic (param) {
//
function SCORMapi2004() {
- function Initialize (param) {
- return SCORM_Call('Initialize',param);
- }
-
- function Terminate (param) {
- return SCORM_Call('Terminate',param);
- }
-
- function GetValue (element) {
- return SCORM_Call('GetValue',element);
- }
-
- function SetValue (element, value) {
- return SCORM_Call('SetValue',element,value);
- }
-
- function Commit (param) {
- return SCORM_Call('Commit',param);
- }
-
- function GetLastError () {
- return errorCode;
- }
-
- function GetErrorString (param) {
- var errorString = new Array();
- errorString["0"] = "No error";
- errorString["101"] = "General exception";
- errorString["102"] = "General Inizialization Failure";
- errorString["103"] = "Already Initialized";
- errorString["104"] = "Content Instance Terminated";
- errorString["111"] = "General Termination Failure";
- errorString["112"] = "Termination Before Inizialization";
- errorString["113"] = "Termination After Termination";
- errorString["122"] = "Retrieve Data Before Initialization";
- errorString["123"] = "Retrieve Data After Termination";
- errorString["132"] = "Store Data Before Inizialization";
- errorString["133"] = "Store Data After Termination";
- errorString["142"] = "Commit Before Inizialization";
- errorString["143"] = "Commit After Termination";
- errorString["201"] = "General Argument Error";
- errorString["301"] = "General Get Failure";
- errorString["351"] = "General Set Failure";
- errorString["391"] = "General Commit Failure";
- errorString["401"] = "Undefinited Data Model";
- errorString["402"] = "Unimplemented Data Model Element";
- errorString["403"] = "Data Model Element Value Not Initialized";
- errorString["404"] = "Data Model Element Is Read Only";
- errorString["405"] = "Data Model Element Is Write Only";
- errorString["406"] = "Data Model Element Type Mismatch";
- errorString["407"] = "Data Model Element Value Out Of Range";
- errorString["408"] = "Data Model Dependency Not Established";
- return errorString[param];
- }
-
- function GetDiagnostic (param) {
- return SCORM_Call('GetDiagnostic',param);
- }
+ <?php include_once ('datamodels/scorm1_3.js.php'); ?>
- this.Initialize = Initialize;
- this.Terminate = Terminate;
- this.GetValue = GetValue;
- this.SetValue = SetValue;
- this.Commit = Commit;
- this.GetLastError = GetLastError;
- this.GetErrorString = GetErrorString;
- this.GetDiagnostic = GetDiagnostic;
}
var API_1484_11 = new SCORMapi2004();
Oops, something went wrong.

0 comments on commit 4928a2f

Please sign in to comment.