adding some strings
[moodle-linuxchix.git] / mod / scorm / datamodels / scorm_12.js.php
blob2e31a3fb285eafc835d189d875c78652d604a596
1 <?php
2 if (isset($userdata->status)) {
3 if ($userdata->status == '') {
4 $userdata->entry = 'ab-initio';
5 } else {
6 if (isset($userdata->{'cmi.core.exit'}) && ($userdata->{'cmi.core.exit'} == 'suspend')) {
7 $userdata->entry = 'resume';
8 } else {
9 $userdata->entry = '';
15 // SCORM 1.2 API Implementation
17 function SCORMapi1_2() {
18 // Standard Data Type Definition
19 CMIString256 = '^.{0,255}$';
20 CMIString4096 = '^.{0,4096}$';
21 //CMIString256 = '^[.\\n\\r]{0,255}$';
22 //CMIString4096 = '^[.\\n\\r]{0,4095}$';
23 CMITime = '^([0-2]{1}[0-9]{1}):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})(\.[0-9]{1,2})?$';
24 CMITimespan = '^([0-9]{2,4}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$';
25 CMIInteger = '^\\d+$';
26 CMISInteger = '^-?([0-9]+)$';
27 CMIDecimal = '^-?([0-9]{0,3})(\.[0-9]{1,2})?$';
28 CMIIdentifier = '^\\w{1,255}$';
29 CMIFeedback = CMIString256; // This must be redefined
30 CMIIndex = '[._](\\d+).';
31 // Vocabulary Data Type Definition
32 CMIStatus = '^passed$|^completed$|^failed$|^incomplete$|^browsed$';
33 CMIStatus2 = '^passed$|^completed$|^failed$|^incomplete$|^browsed$|^not attempted$';
34 CMIExit = '^time-out$|^suspend$|^logout$|^$';
35 CMIType = '^true-false$|^choice$|^fill-in$|^matching$|^performance$|^sequencing$|^likert$|^numeric$';
36 CMIResult = '^correct$|^wrong$|^unanticipated$|^neutral$|^([0-9]{0,3})?(\.[0-9]{1,2})?$';
37 NAVEvent = '^previous$|^continue$';
38 // Children lists
39 cmi_children = 'core, suspend_data, launch_data, comments, objectives, student_data, student_preference, interactions';
40 core_children = 'student_id, student_name, lesson_location, credit, lesson_status, entry, score, total_time, lesson_mode, exit, session_time';
41 score_children = 'raw, min, max';
42 objectives_children = 'id, score, status';
43 student_data_children = 'mastery_score, max_time_allowed, time_limit_action';
44 student_preference_children = 'audio, language, speed, text';
45 interactions_children = 'id, objectives, time, type, correct_responses, weighting, student_response, result, latency';
46 // Data ranges
47 score_range = '0#100';
48 audio_range = '-1#100';
49 speed_range = '-100#100';
50 weighting_range = '-100#100';
51 text_range = '-1#1';
52 // The SCORM 1.2 data model
53 var datamodel = {
54 'cmi._children':{'defaultvalue':cmi_children, 'mod':'r', 'writeerror':'402'},
55 'cmi._version':{'defaultvalue':'3.4', 'mod':'r', 'writeerror':'402'},
56 'cmi.core._children':{'defaultvalue':core_children, 'mod':'r', 'writeerror':'402'},
57 'cmi.core.student_id':{'defaultvalue':'<?php echo $userdata->student_id ?>', 'mod':'r', 'writeerror':'403'},
58 'cmi.core.student_name':{'defaultvalue':'<?php echo addslashes($userdata->student_name) ?>', 'mod':'r', 'writeerror':'403'},
59 'cmi.core.lesson_location':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.lesson_location'})?$userdata->{'cmi.core.lesson_location'}:'' ?>', 'format':CMIString256, 'mod':'rw', 'writeerror':'405'},
60 'cmi.core.credit':{'defaultvalue':'<?php echo $userdata->credit ?>', 'mod':'r', 'writeerror':'403'},
61 'cmi.core.lesson_status':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.lesson_status'})?$userdata->{'cmi.core.lesson_status'}:'' ?>', 'format':CMIStatus, 'mod':'rw', 'writeerror':'405'},
62 'cmi.core.entry':{'defaultvalue':'<?php echo $userdata->entry ?>', 'mod':'r', 'writeerror':'403'},
63 'cmi.core.score._children':{'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'},
64 'cmi.core.score.raw':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.score.raw'})?$userdata->{'cmi.core.score.raw'}:'' ?>', 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
65 'cmi.core.score.max':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.score.max'})?$userdata->{'cmi.core.score.max'}:'' ?>', 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
66 'cmi.core.score.min':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.score.min'})?$userdata->{'cmi.core.score.min'}:'' ?>', 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
67 'cmi.core.total_time':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.total_time'})?$userdata->{'cmi.core.total_time'}:'00:00:00' ?>', 'mod':'r', 'writeerror':'403'},
68 'cmi.core.lesson_mode':{'defaultvalue':'<?php echo $userdata->mode ?>', 'mod':'r', 'writeerror':'403'},
69 'cmi.core.exit':{'defaultvalue':'<?php echo isset($userdata->{'cmi.core.exit'})?$userdata->{'cmi.core.exit'}:'' ?>', 'format':CMIExit, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
70 'cmi.core.session_time':{'format':CMITimespan, 'mod':'w', 'defaultvalue':'00:00:00', 'readerror':'404', 'writeerror':'405'},
71 'cmi.suspend_data':{'defaultvalue':'<?php echo isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
72 'cmi.launch_data':{'defaultvalue':'<?php echo isset($userdata->datafromlms)?$userdata->datafromlms:'' ?>', 'mod':'r', 'writeerror':'403'},
73 'cmi.comments':{'defaultvalue':'<?php echo isset($userdata->{'cmi.comments'})?$userdata->{'cmi.comments'}:'' ?>', 'format':CMIString4096, 'mod':'rw', 'writeerror':'405'},
74 'cmi.comments_from_lms':{'mod':'r', 'writeerror':'403'},
75 'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r', 'writeerror':'402'},
76 'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
77 'cmi.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'rw', 'writeerror':'405'},
78 'cmi.objectives.n.score._children':{'pattern':CMIIndex, 'mod':'r', 'writeerror':'402'},
79 'cmi.objectives.n.score.raw':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
80 'cmi.objectives.n.score.min':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
81 'cmi.objectives.n.score.max':{'defaultvalue':'', 'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'},
82 'cmi.objectives.n.status':{'pattern':CMIIndex, 'format':CMIStatus2, 'mod':'rw', 'writeerror':'405'},
83 'cmi.student_data._children':{'defaultvalue':student_data_children, 'mod':'r', 'writeerror':'402'},
84 'cmi.student_data.mastery_score':{'defaultvalue':'<?php echo isset($userdata->masteryscore)?$userdata->masteryscore:'' ?>', 'mod':'r', 'writeerror':'403'},
85 'cmi.student_data.max_time_allowed':{'defaultvalue':'<?php echo isset($userdata->maxtimeallowed)?$userdata->maxtimeallowed:'' ?>', 'mod':'r', 'writeerror':'403'},
86 'cmi.student_data.time_limit_action':{'defaultvalue':'<?php echo isset($userdata->timelimitaction)?$userdata->timelimitaction:'' ?>', 'mod':'r', 'writeerror':'403'},
87 'cmi.student_preference._children':{'defaultvalue':student_preference_children, 'mod':'r', 'writeerror':'402'},
88 'cmi.student_preference.audio':{'defaultvalue':'0', 'format':CMISInteger, 'range':audio_range, 'mod':'rw', 'writeerror':'405'},
89 'cmi.student_preference.language':{'defaultvalue':'', 'format':CMIString256, 'mod':'rw', 'writeerror':'405'},
90 'cmi.student_preference.speed':{'defaultvalue':'0', 'format':CMISInteger, 'range':speed_range, 'mod':'rw', 'writeerror':'405'},
91 'cmi.student_preference.text':{'defaultvalue':'0', 'format':CMISInteger, 'range':text_range, 'mod':'rw', 'writeerror':'405'},
92 'cmi.interactions._children':{'defaultvalue':interactions_children, 'mod':'r', 'writeerror':'402'},
93 'cmi.interactions._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
94 'cmi.interactions.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
95 'cmi.interactions.n.objectives._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
96 'cmi.interactions.n.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
97 'cmi.interactions.n.time':{'pattern':CMIIndex, 'format':CMITime, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
98 'cmi.interactions.n.type':{'pattern':CMIIndex, 'format':CMIType, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
99 'cmi.interactions.n.correct_responses._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'},
100 'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
101 'cmi.interactions.n.weighting':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':weighting_range, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
102 'cmi.interactions.n.student_response':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
103 'cmi.interactions.n.result':{'pattern':CMIIndex, 'format':CMIResult, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
104 'cmi.interactions.n.latency':{'pattern':CMIIndex, 'format':CMITimespan, 'mod':'w', 'readerror':'404', 'writeerror':'405'},
105 'nav.event':{'defaultvalue':'', 'format':NAVEvent, 'mod':'w', 'readerror':'404', 'writeerror':'405'}
108 // Datamodel inizialization
110 var cmi = new Object();
111 cmi.core = new Object();
112 cmi.core.score = new Object();
113 cmi.objectives = new Object();
114 cmi.student_data = new Object();
115 cmi.student_preference = new Object();
116 cmi.interactions = new Object();
118 // Navigation Object
119 var nav = new Object();
121 for (element in datamodel) {
122 if (element.match(/\.n\./) == null) {
123 if ((typeof eval('datamodel["'+element+'"].defaultvalue')) != 'undefined') {
124 eval(element+' = datamodel["'+element+'"].defaultvalue;');
125 } else {
126 eval(element+' = "";');
131 <?php
132 $count = 0;
133 $objectives = '';
134 foreach($userdata as $element => $value){
135 if (substr($element,0,14) == 'cmi.objectives') {
136 preg_match('/\.(\d+)\./',$element,$matches);
137 $element = preg_replace('/\.(\d+)\./',".\$1.",$element);
138 if ($matches[1] == $count) {
139 $count++;
140 $end = strpos($element,$matches[1])+strlen($matches[1]);
141 $subelement = substr($element,0,$end);
142 echo ' '.$subelement." = new Object();\n";
143 echo ' '.$subelement.".score = new Object();\n";
144 echo ' '.$subelement.".score._children = score_children;\n";
145 echo ' '.$subelement.".score.raw = '';\n";
146 echo ' '.$subelement.".score.min = '';\n";
147 echo ' '.$subelement.".score.max = '';\n";
149 echo ' '.$element.' = \''.$value."';\n";
152 if ($count > 0) {
153 echo ' cmi.objectives._count = '.$count.";\n";
157 if (cmi.core.lesson_status == '') {
158 cmi.core.lesson_status = 'not attempted';
162 // API Methods definition
164 var Initialized = false;
166 function LMSInitialize (param) {
167 errorCode = "0";
168 if (param == "") {
169 if (!Initialized) {
170 <?php
171 if (debugging('',DEBUG_DEVELOPER)) {
172 echo 'alert("Initialized SCORM 1.2");';
175 Initialized = true;
176 errorCode = "0";
177 return "true";
178 } else {
179 errorCode = "101";
181 } else {
182 errorCode = "201";
184 return "false";
187 function LMSFinish (param) {
188 errorCode = "0";
189 if (param == "") {
190 if (Initialized) {
191 <?php
192 if (debugging('',DEBUG_DEVELOPER)) {
193 echo 'alert("Finished SCORM 1.2");';
196 Initialized = false;
197 result = StoreData(cmi,true);
198 if (nav.event != '') {
199 if (nav.event == 'continue') {
200 setTimeout('top.document.location=top.next;',500);
201 } else {
202 setTimeout('top.document.location=top.prev;',500);
204 } else {
205 if (<?php echo $scorm->auto ?> == 1) {
206 setTimeout('top.document.location=top.next;',500);
209 return "true";
210 } else {
211 errorCode = "301";
213 } else {
214 errorCode = "201";
216 return "false";
219 function LMSGetValue (element) {
220 errorCode = "0";
221 if (Initialized) {
222 if (element !="") {
223 expression = new RegExp(CMIIndex,'g');
224 elementmodel = element.replace(expression,'.n.');
225 if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
226 if (eval('datamodel["'+elementmodel+'"].mod') != 'w') {
227 element = element.replace(expression, "_$1.");
228 elementIndexes = element.split('.');
229 subelement = 'cmi';
230 i = 1;
231 while ((i < elementIndexes.length) && (typeof eval(subelement) != "undefined")) {
232 subelement += '.'+elementIndexes[i++];
234 if (subelement == element) {
235 errorCode = "0";
236 <?php
237 if (debugging('',DEBUG_DEVELOPER)) {
238 echo 'alert(element+": "+eval(element));';
241 return eval(element);
242 } else {
243 errorCode = "0"; // Need to check if it is the right errorCode
245 } else {
246 errorCode = eval('datamodel["'+elementmodel+'"].readerror');
248 } else {
249 childrenstr = '._children';
250 countstr = '._count';
251 if (elementmodel.substr(elementmodel.length-childrenstr.length,elementmodel.length) == childrenstr) {
252 parentmodel = elementmodel.substr(0,elementmodel.length-childrenstr.length);
253 if ((typeof eval('datamodel["'+parentmodel+'"]')) != "undefined") {
254 errorCode = "202";
255 } else {
256 errorCode = "201";
258 } else if (elementmodel.substr(elementmodel.length-countstr.length,elementmodel.length) == countstr) {
259 parentmodel = elementmodel.substr(0,elementmodel.length-countstr.length);
260 if ((typeof eval('datamodel["'+parentmodel+'"]')) != "undefined") {
261 errorCode = "203";
262 } else {
263 errorCode = "201";
265 } else {
266 errorCode = "201";
269 } else {
270 errorCode = "201";
272 } else {
273 errorCode = "301";
275 return "";
278 function LMSSetValue (element,value) {
279 errorCode = "0";
280 if (Initialized) {
281 if (element != "") {
282 expression = new RegExp(CMIIndex,'g');
283 elementmodel = element.replace(expression,'.n.');
284 if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
285 if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
286 expression = new RegExp(eval('datamodel["'+elementmodel+'"].format'));
287 value = value+'';
288 matches = value.match(expression);
289 if (matches != null) {
290 //Create dynamic data model element
291 if (element != elementmodel) {
292 elementIndexes = element.split('.');
293 subelement = 'cmi';
294 for (i=1;i < elementIndexes.length-1;i++) {
295 elementIndex = elementIndexes[i];
296 if (elementIndexes[i+1].match(/^\d+$/)) {
297 if ((typeof eval(subelement+'.'+elementIndex)) == "undefined") {
298 eval(subelement+'.'+elementIndex+' = new Object();');
299 eval(subelement+'.'+elementIndex+'._count = 0;');
301 if (elementIndexes[i+1] == eval(subelement+'.'+elementIndex+'._count')) {
302 eval(subelement+'.'+elementIndex+'._count++;');
304 if (elementIndexes[i+1] > eval(subelement+'.'+elementIndex+'._count')) {
305 errorCode = "201";
307 subelement = subelement.concat('.'+elementIndex+'_'+elementIndexes[i+1]);
308 i++;
309 } else {
310 subelement = subelement.concat('.'+elementIndex);
312 if ((typeof eval(subelement)) == "undefined") {
313 eval(subelement+' = new Object();');
314 if (subelement.substr(0,14) == 'cmi.objectives') {
315 eval(subelement+'.score = new Object();');
316 eval(subelement+'.score._children = score_children;');
317 eval(subelement+'.score.raw = "";');
318 eval(subelement+'.score.min = "";');
319 eval(subelement+'.score.max = "";');
321 if (subelement.substr(0,16) == 'cmi.interactions') {
322 eval(subelement+'.objectives = new Object();');
323 eval(subelement+'.objectives._count = 0;');
324 eval(subelement+'.correct_responses = new Object();');
325 eval(subelement+'.correct_responses._count = 0;');
329 element = subelement.concat('.'+elementIndexes[elementIndexes.length-1]);
331 //Store data
332 if (errorCode == "0") {
333 if ((typeof eval('datamodel["'+elementmodel+'"].range')) != "undefined") {
334 range = eval('datamodel["'+elementmodel+'"].range');
335 ranges = range.split('#');
336 value = value*1.0;
337 if ((value >= ranges[0]) && (value <= ranges[1])) {
338 eval(element+'=value;');
339 errorCode = "0";
340 <?php
341 if (debugging('',DEBUG_DEVELOPER)) {
342 echo 'alert(element+":= "+value);';
345 return "true";
346 } else {
347 errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
349 } else {
350 if (element == 'cmi.comments') {
351 eval(element+'=value;');
352 } else {
353 eval(element+'=value;');
355 errorCode = "0";
356 <?php
357 if (debugging('',DEBUG_DEVELOPER)) {
358 echo 'alert(element+":= "+value);';
361 return "true";
364 } else {
365 errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
367 } else {
368 errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
370 } else {
371 errorCode = "201"
373 } else {
374 errorCode = "201";
376 } else {
377 errorCode = "301";
379 return "false";
382 function LMSCommit (param) {
383 errorCode = "0";
384 if (param == "") {
385 if (Initialized) {
386 result = StoreData(cmi,false);
387 <?php
388 if (debugging('',DEBUG_DEVELOPER)) {
389 echo 'alert("Data Commited");';
392 return "true";
393 } else {
394 errorCode = "301";
396 } else {
397 errorCode = "201";
399 return "false";
402 function LMSGetLastError () {
403 return errorCode;
406 function LMSGetErrorString (param) {
407 if (param != "") {
408 var errorString = new Array();
409 errorString["0"] = "No error";
410 errorString["101"] = "General exception";
411 errorString["201"] = "Invalid argument error";
412 errorString["202"] = "Element cannot have children";
413 errorString["203"] = "Element not an array - cannot have count";
414 errorString["301"] = "Not initialized";
415 errorString["401"] = "Not implemented error";
416 errorString["402"] = "Invalid set value, element is a keyword";
417 errorString["403"] = "Element is read only";
418 errorString["404"] = "Element is write only";
419 errorString["405"] = "Incorrect data type";
420 return errorString[param];
421 } else {
422 return "";
426 function LMSGetDiagnostic (param) {
427 if (param == "") {
428 param = errorCode;
430 return param;
433 function AddTime (first, second) {
434 var sFirst = first.split(":");
435 var sSecond = second.split(":");
436 var cFirst = sFirst[2].split(".");
437 var cSecond = sSecond[2].split(".");
438 var change = 0;
440 FirstCents = 0; //Cents
441 if (cFirst.length > 1) {
442 FirstCents = parseInt(cFirst[1],10);
444 SecondCents = 0;
445 if (cSecond.length > 1) {
446 SecondCents = parseInt(cSecond[1],10);
448 var cents = FirstCents + SecondCents;
449 change = Math.floor(cents / 100);
450 cents = cents - (change * 100);
451 if (Math.floor(cents) < 10) {
452 cents = "0" + cents.toString();
455 var secs = parseInt(cFirst[0],10)+parseInt(cSecond[0],10)+change; //Seconds
456 change = Math.floor(secs / 60);
457 secs = secs - (change * 60);
458 if (Math.floor(secs) < 10) {
459 secs = "0" + secs.toString();
462 mins = parseInt(sFirst[1],10)+parseInt(sSecond[1],10)+change; //Minutes
463 change = Math.floor(mins / 60);
464 mins = mins - (change * 60);
465 if (mins < 10) {
466 mins = "0" + mins.toString();
469 hours = parseInt(sFirst[0],10)+parseInt(sSecond[0],10)+change; //Hours
470 if (hours < 10) {
471 hours = "0" + hours.toString();
474 if (cents != '0') {
475 return hours + ":" + mins + ":" + secs + '.' + cents;
476 } else {
477 return hours + ":" + mins + ":" + secs;
481 function TotalTime() {
482 total_time = AddTime(cmi.core.total_time, cmi.core.session_time);
483 return '&'+underscore('cmi.core.total_time')+'='+encodeURIComponent(total_time);
486 function CollectData(data,parent) {
487 var datastring = '';
488 for (property in data) {
489 if (typeof data[property] == 'object') {
490 datastring += CollectData(data[property],parent+'.'+property);
491 } else {
492 element = parent+'.'+property;
493 expression = new RegExp(CMIIndex,'g');
494 elementmodel = element.replace(expression,'.n.');
495 if (elementmodel != "cmi.core.session_time") {
496 if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
497 if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
498 elementstring = '&'+underscore(element)+'='+encodeURIComponent(data[property]);
499 if ((typeof eval('datamodel["'+elementmodel+'"].defaultvalue')) != "undefined") {
500 if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property]) {
501 datastring += elementstring;
503 } else {
504 datastring += elementstring;
511 return datastring;
514 function StoreData(data,storetotaltime) {
515 if (storetotaltime) {
516 if (cmi.core.lesson_status == 'not attempted') {
517 cmi.core.lesson_status = 'completed';
519 if (cmi.core.lesson_mode == 'normal') {
520 if (cmi.core.credit == 'credit') {
521 if (cmi.core.lesson_status == 'completed') {
522 if (cmi.student_data.mastery_score != '') {
523 if (parseFloat(cmi.core.score.raw) >= parseFloat(cmi.student_data.mastery_score)) {
524 cmi.core.lesson_status = 'passed';
525 } else {
526 cmi.core.lesson_status = 'failed';
532 if (cmi.core.lesson_mode == 'browse') {
533 if (datamodel['cmi.core.lesson_status'].defaultvalue == '') {
534 cmi.core.lesson_status = 'browsed';
537 datastring = CollectData(data,'cmi');
538 datastring += TotalTime();
539 } else {
540 datastring = CollectData(data,'cmi');
542 datastring += '&attempt=<?php echo $attempt ?>';
543 datastring += '&scoid=<?php echo $scoid ?>';
545 var myRequest = NewHttpReq();
546 result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
547 results = result.split('\n');
548 errorCode = results[1];
549 return results[0];
552 this.LMSInitialize = LMSInitialize;
553 this.LMSFinish = LMSFinish;
554 this.LMSGetValue = LMSGetValue;
555 this.LMSSetValue = LMSSetValue;
556 this.LMSCommit = LMSCommit;
557 this.LMSGetLastError = LMSGetLastError;
558 this.LMSGetErrorString = LMSGetErrorString;
559 this.LMSGetDiagnostic = LMSGetDiagnostic;
562 var API = new SCORMapi1_2();