From 6b4c13b7b2e6608f06f6017535dc2227677c6bd9 Mon Sep 17 00:00:00 2001 From: bobopinna Date: Thu, 1 Jul 2004 13:34:10 +0000 Subject: [PATCH] Refined time data model parsing and fixed the credit/no-credit model --- mod/scorm/api1_2.php | 53 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/mod/scorm/api1_2.php b/mod/scorm/api1_2.php index 0592914ba4..d2066dcd08 100644 --- a/mod/scorm/api1_2.php +++ b/mod/scorm/api1_2.php @@ -25,17 +25,23 @@ function SCORMapi() { cmi.core.student_id = "username; ?>"; cmi.core.student_name = "firstname." ".$USER->lastname; ?>"; cmi.core.lesson_location = "cmi_core_lesson_location; ?>"; - cmi.core.credit = "credit"; + cmi.core.credit = ""; cmi.core.lesson_status = "cmi_core_lesson_status; ?>"; cmi.core.exit = "cmi_core_exit ?>"; - cmi.core.entry = "cmi_core_lesson_status=='not attempted') + cmi.core.entry = "cmi_core_lesson_status == 'not attempted') { echo 'ab-initio'; - else - if ($sco_user->cmi_core_lesson_status!='completed') + } else { + if ($sco_user->cmi_core_lesson_status != 'completed') { echo 'resume'; - else - echo '';?>"; - cmi.core.session_time = ""; + } else { + echo ''; + } + }?>"; + cmi.core.session_time = "00:00:00"; cmi.core.total_time = "cmi_core_total_time; ?>"; cmi.core.lesson_mode = ""; cmi.core.score = new Object(); @@ -65,7 +71,7 @@ function SCORMapi() { function LMSGetValue (param) { if (Initialized) { - //top.status="GET "+param; + //top.alert("GET "+param); switch (param) { case "cmi.core._children": case "cmi.core.student_id": @@ -101,24 +107,27 @@ function SCORMapi() { function LMSSetValue (param,value) { if (Initialized) { - //top.status="SET "+param+" = "+value; //top.alert("SET "+param+" = "+value); switch (param) { case "cmi.core.session_time": - //top.alert(typeof(value)); if (typeof(value) == "string") { - var parsedtime = value.match(/[0-9]{2,4}/g); - //top.alert(parsedtime); - if (((parsedtime.length == 3) || (parsedtime.length == 4)) && (parsedtime[0]>=0) && (parsedtime[0]<=9999) && (parsedtime[1]>=0) && (parsedtime[1]<=59) && (parsedtime[2]>=0) && (parsedtime[2]<=59)) { - if ((parsedtime.length == 4) && (parsedtime[3]<=0) && (parsedtime[3]>=99)) { - errorCode = 405; - return "false"; + var matchedtime = value.match(/([0-9]{2,4}):([0-9]{2}):([0-9]{2})/g); + if (matchedtime != null) { + var parsedtime = value.match(/[0-9]+/g); + if (((parsedtime.length == 3) || (parsedtime.length == 4)) && (parsedtime[0]>=0) && (parsedtime[0]<=9999) && (parsedtime[1]>=0) && (parsedtime[1]<=59) && (parsedtime[2]>=0) && (parsedtime[2]<=59)) { + if ((parsedtime.length == 4) && (parsedtime[3]<=0) && (parsedtime[3]>=99)) { + errorCode = 405; + return "false"; + } + eval(param+'="'+value+'";'); + errorCode = 0; + return "true"; + } else { + errorCode = 405; + return "false"; } - eval(param+'="'+value+'";'); - errorCode = 0; - return "true"; - } else { - errorCode = 405; + } else { + errorCode = 405; return "false"; } } else { @@ -138,7 +147,6 @@ function SCORMapi() { case "cmi.core.score.raw": case "cmi.core.score.min": case "cmi.core.score.max": - //top.alert("SET "+param+" = "+value); if ((parseFloat(value,10)).toString() != value) { errorCode = 405; return "false"; @@ -186,7 +194,6 @@ function SCORMapi() { case "nav.event": if ((value == "previous") || (value == "continue")) { eval(param+'="'+value+'";'); - //changeSco(value); errorCode = 0; return "true"; } else { -- 2.39.5