Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refined time data model parsing and fixed the credit/no-credit model

  • Loading branch information...
commit 6b4c13b7b2e6608f06f6017535dc2227677c6bd9 1 parent eeb2d76
bobopinna authored

Showing 1 changed file with 30 additions and 23 deletions. Show diff stats Hide diff stats

  1. +30 23 mod/scorm/api1_2.php
53 mod/scorm/api1_2.php
@@ -25,17 +25,23 @@ function LMSInitialize (param) {
25 25 cmi.core.student_id = "<?php echo $USER->username; ?>";
26 26 cmi.core.student_name = "<?php echo $USER->firstname." ".$USER->lastname; ?>";
27 27 cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location; ?>";
28   - cmi.core.credit = "credit";
  28 + cmi.core.credit = "<?php if ($mode != 'normal') {
  29 + echo "no-credit";
  30 + } else {
  31 + echo "credit";
  32 + }?>";
29 33 cmi.core.lesson_status = "<?php echo $sco_user->cmi_core_lesson_status; ?>";
30 34 cmi.core.exit = "<?php echo $sco_user->cmi_core_exit ?>";
31   - cmi.core.entry = "<?php if ($sco_user->cmi_core_lesson_status=='not attempted')
  35 + cmi.core.entry = "<?php if ($sco_user->cmi_core_lesson_status == 'not attempted') {
32 36 echo 'ab-initio';
33   - else
34   - if ($sco_user->cmi_core_lesson_status!='completed')
  37 + } else {
  38 + if ($sco_user->cmi_core_lesson_status != 'completed') {
35 39 echo 'resume';
36   - else
37   - echo '';?>";
38   - cmi.core.session_time = "";
  40 + } else {
  41 + echo '';
  42 + }
  43 + }?>";
  44 + cmi.core.session_time = "00:00:00";
39 45 cmi.core.total_time = "<?php echo $sco_user->cmi_core_total_time; ?>";
40 46 cmi.core.lesson_mode = "<?php echo $mode; ?>";
41 47 cmi.core.score = new Object();
@@ -65,7 +71,7 @@ function LMSInitialize (param) {
65 71
66 72 function LMSGetValue (param) {
67 73 if (Initialized) {
68   - //top.status="GET "+param;
  74 + //top.alert("GET "+param);
69 75 switch (param) {
70 76 case "cmi.core._children":
71 77 case "cmi.core.student_id":
@@ -101,24 +107,27 @@ function LMSGetValue (param) {
101 107
102 108 function LMSSetValue (param,value) {
103 109 if (Initialized) {
104   - //top.status="SET "+param+" = "+value;
105 110 //top.alert("SET "+param+" = "+value);
106 111 switch (param) {
107 112 case "cmi.core.session_time":
108   - //top.alert(typeof(value));
109 113 if (typeof(value) == "string") {
110   - var parsedtime = value.match(/[0-9]{2,4}/g);
111   - //top.alert(parsedtime);
112   - 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)) {
113   - if ((parsedtime.length == 4) && (parsedtime[3]<=0) && (parsedtime[3]>=99)) {
114   - errorCode = 405;
115   - return "false";
  114 + var matchedtime = value.match(/([0-9]{2,4}):([0-9]{2}):([0-9]{2})/g);
  115 + if (matchedtime != null) {
  116 + var parsedtime = value.match(/[0-9]+/g);
  117 + 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)) {
  118 + if ((parsedtime.length == 4) && (parsedtime[3]<=0) && (parsedtime[3]>=99)) {
  119 + errorCode = 405;
  120 + return "false";
  121 + }
  122 + eval(param+'="'+value+'";');
  123 + errorCode = 0;
  124 + return "true";
  125 + } else {
  126 + errorCode = 405;
  127 + return "false";
116 128 }
117   - eval(param+'="'+value+'";');
118   - errorCode = 0;
119   - return "true";
120   - } else {
121   - errorCode = 405;
  129 + } else {
  130 + errorCode = 405;
122 131 return "false";
123 132 }
124 133 } else {
@@ -138,7 +147,6 @@ function LMSSetValue (param,value) {
138 147 case "cmi.core.score.raw":
139 148 case "cmi.core.score.min":
140 149 case "cmi.core.score.max":
141   - //top.alert("SET "+param+" = "+value);
142 150 if ((parseFloat(value,10)).toString() != value) {
143 151 errorCode = 405;
144 152 return "false";
@@ -186,7 +194,6 @@ function LMSSetValue (param,value) {
186 194 case "nav.event":
187 195 if ((value == "previous") || (value == "continue")) {
188 196 eval(param+'="'+value+'";');
189   - //changeSco(value);
190 197 errorCode = 0;
191 198 return "true";
192 199 } else {

0 comments on commit 6b4c13b

Please sign in to comment.
Something went wrong with that request. Please try again.