Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Latest SCORM from development now merged into stable

  • Loading branch information...
commit 30772a2aaf8e685a12fd5193892b2eb4dd22235d 1 parent 4287e72
authored
162  mod/scorm/api1_2.php
... ...
@@ -1,47 +1,12 @@
1  
-//
2  
-// CMI Initialization SCORM 1.2
3  
-//
4  
-	var cmi= new Object();
5  
-	
6  
-	cmi.core = new Object();
7  
-	cmi.core._children = "student_id,student_name,lesson_location,credit,lesson_status,exit,entry,session_time,total_time,lesson_mode,score,suspend_data,launch_data";
8  
-	cmi.core.student_id = "<?php echo $USER->username; ?>";
9  
-	cmi.core.student_name = "<?php echo $USER->firstname." ".$USER->lastname; ?>";
10  
-	cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location; ?>";
11  
-	cmi.core.credit = "credit";
12  
-	cmi.core.lesson_status = "<?php echo $sco_user->cmi_core_lesson_status; ?>";
13  
-	cmi.core.exit = "<?php echo $sco_user->cmi_core_exit ?>";
14  
-	cmi.core.entry = "<?php if ($sco_user->cmi_core_lesson_status=="not attempted") 
15  
-				    echo 'ab-initio'; 
16  
-				else 
17  
-				    if ($sco_user->cmi_core_lesson_status!="completed") 
18  
-					echo 'resume'; 
19  
-				    else 
20  
-					echo '';?>";
21  
-	cmi.core.session_time = "<?php echo $sco_user->cmi_core_session_time; ?>";
22  
-	cmi.core.total_time = "<?php echo $sco_user->cmi_core_total_time; ?>";
23  
-	cmi.core.lesson_mode = "<?php echo $mode; ?>";
24  
-	
25  
-	cmi.core.score = new Object();
26  
-	cmi.core.score._children = "raw";
27  
-	cmi.core.score.raw = "<?php echo $sco_user->cmi_core_score_raw; ?>";
28  
-	cmi.suspend_data = "<?php echo $sco_user->cmi_suspend_data; ?>";
29  
-	cmi.launch_data = "<?php echo $sco_user->cmi_launch_data; ?>";
30  
-/*	cmi.interactions = new Object();
31  
-	cmi.interactions._children = "id,objectives,time,type,correct_responses,weighting,student_response,result,latency";
32  
-	cmi.interactions._count = 0;
33  
-*/
34  
-	var errorCode = 0;
35  
-
36  
-//
37  
-// end CMI Initialization
38  
-//
39  
-
40  
-
41 1
 // 
42 2
 // SCORM API 1.2 Implementation
43 3
 //
44 4
 function SCORMapi() {
  5
+    var cmi= new Object();
  6
+    var nav = new Object();
  7
+
  8
+    var errorCode = 0;
  9
+    
45 10
     var Initialized = false;
46 11
 
47 12
     function LMSInitialize (param) {
@@ -52,6 +17,52 @@ function LMSInitialize (param) {
52 17
 	if (!Initialized) {
53 18
 	    Initialized = true;
54 19
 	    errorCode = 0;
  20
+	    
  21
+	    //
  22
+	    // CMI Initialization SCORM 1.2
  23
+	    //
  24
+	    cmi.core = new Object();
  25
+	    cmi.core._children = "student_id,student_name,lesson_location,credit,lesson_status,exit,entry,session_time,total_time,lesson_mode,score,suspend_data,launch_data";
  26
+	    cmi.core.student_id = "<?php echo $USER->username; ?>";
  27
+	    cmi.core.student_name = "<?php echo $USER->firstname." ".$USER->lastname; ?>";
  28
+	    cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location; ?>";
  29
+	    cmi.core.credit = "<?php if ($mode != 'normal') {
  30
+	    				 echo "no-credit";
  31
+	    			     } else {
  32
+					 echo "credit";
  33
+				     }?>";
  34
+	    cmi.core.lesson_status = "<?php echo $sco_user->cmi_core_lesson_status; ?>";
  35
+	    cmi.core.exit = "<?php echo $sco_user->cmi_core_exit ?>";
  36
+	    cmi.core.entry = "<?php if ($sco_user->cmi_core_lesson_status == 'not attempted') {
  37
+					echo 'ab-initio'; 
  38
+				    } else {
  39
+					if ($sco_user->cmi_core_lesson_status != 'completed') {
  40
+					    echo 'resume'; 
  41
+				    	} else {
  42
+					    echo '';
  43
+					}
  44
+				    }?>";
  45
+	    cmi.core.session_time = "00:00:00";
  46
+	    cmi.core.total_time = "<?php echo $sco_user->cmi_core_total_time; ?>";
  47
+	    cmi.core.lesson_mode = "<?php echo $mode; ?>";
  48
+	    cmi.core.score = new Object();
  49
+	    cmi.core.score._children = "raw,min,max";
  50
+	    cmi.core.score.raw = "<?php echo $sco_user->cmi_core_score_raw; ?>";
  51
+	    cmi.suspend_data = "<?php echo $sco_user->cmi_suspend_data; ?>";
  52
+	    cmi.launch_data = "<?php echo $sco_user->cmi_launch_data; ?>";
  53
+	    //
  54
+	    // end CMI Initialization
  55
+	    //
  56
+	    
  57
+	    // Navigation Object
  58
+	    <?php 
  59
+	        if ($scorm->auto) {
  60
+	    	    echo 'nav.event = "continue";'."\n";
  61
+	    	} else {
  62
+	            echo 'nav.event = "";'."\n";
  63
+	        }
  64
+	    ?>
  65
+
55 66
 	    return "true";
56 67
 	} else {
57 68
 	    errorCode = 101;
@@ -61,7 +72,7 @@ function LMSInitialize (param) {
61 72
     
62 73
     function LMSGetValue (param) {
63 74
 	if (Initialized) {
64  
-	    //top.status="GET "+param;
  75
+	    //top.alert("GET "+param);
65 76
 	    switch (param) {
66 77
 		case "cmi.core._children":
67 78
 		case "cmi.core.student_id":
@@ -97,14 +108,29 @@ function LMSGetValue (param) {
97 108
     
98 109
     function LMSSetValue (param,value) {
99 110
 	if (Initialized) {
100  
-	    //top.status="SET "+param+" = "+value;
  111
+	    //top.alert("SET "+param+" = "+value);
101 112
 	    switch (param) {
102 113
 		case "cmi.core.session_time":
103  
-		    cmi.core.total_time = AddTime(cmi.core.total_time, value);
104  
-		    //top.status="SET cmi.core.total_time = "+cmi.core.total_time;
105  
-		    eval(param+'="'+value+'";');
106  
-		    errorCode = 0;
107  
-		    return "true";
  114
+		    if (typeof(value) == "string") {
  115
+		        var parsedtime = value.match(/^([0-9]{2,4}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$/);
  116
+		        if (parsedtime != null) {
  117
+		            //top.alert(parsedtime);
  118
+		            if (((parsedtime.length == 4) || (parsedtime.length == 5)) && (parsedtime[2]>=0) && (parsedtime[2]<=59) && (parsedtime[3]>=0) && (parsedtime[3]<=59)) {
  119
+		                eval(param+'="'+value+'";');
  120
+		        	errorCode = 0;
  121
+		        	return "true";
  122
+		            } else {
  123
+		            	errorCode = 405;
  124
+		            	return "false";
  125
+		       	    }
  126
+		       	} else {
  127
+		       	    errorCode = 405;
  128
+		            return "false";
  129
+		       	}
  130
+		    } else {
  131
+		        errorCode = 405;
  132
+		        return "false";
  133
+		    }
108 134
 		break;
109 135
 		case "cmi.core.lesson_status":
110 136
 		    if ((value!="passed")&&(value!="completed")&&(value!="failed")&&(value!="incomplete")&&(value!="browsed")) {
@@ -116,6 +142,8 @@ function LMSSetValue (param,value) {
116 142
 		    return "true";
117 143
 		break;
118 144
 		case "cmi.core.score.raw":
  145
+		case "cmi.core.score.min":
  146
+		case "cmi.core.score.max":
119 147
 		    if ((parseFloat(value,10)).toString() != value) {
120 148
 			errorCode = 405;
121 149
 			return "false";
@@ -160,6 +188,16 @@ function LMSSetValue (param,value) {
160 188
 		    errorCode = 403;
161 189
 		    return "false";
162 190
 		break;
  191
+		case "nav.event":
  192
+		    if ((value == "previous") || (value == "continue")) {
  193
+		        eval(param+'="'+value+'";');
  194
+		    	errorCode = 0;
  195
+		    	return "true";
  196
+		    } else {
  197
+		        erroCode = 405;
  198
+		        return "false";
  199
+		    }
  200
+		break;	
163 201
 		default:
164 202
 		    //errorCode = 401;  This is more correct but may have problem with some SCOes
165 203
 		    errorCode = 0; // With this disable any possible SCO errors alert
@@ -178,14 +216,12 @@ function LMSCommit (param) {
178 216
 	    return "false";
179 217
 	}
180 218
 	if (Initialized) {
181  
-	    if (top.nav.cmi.document.theform) {
182  
-		cmiform = top.nav.cmi.document.forms[0];
  219
+	    if (<?php echo $navObj ?>cmi.document.theform) {
  220
+		cmiform = <?php echo $navObj ?>cmi.document.forms[0];
183 221
 		cmiform.scoid.value = "<?php echo $sco->id; ?>";
184 222
 		cmiform.cmi_core_lesson_location.value = cmi.core.lesson_location;
185 223
 		cmiform.cmi_core_lesson_status.value = cmi.core.lesson_status;
186 224
 		cmiform.cmi_core_exit.value = cmi.core.exit;
187  
-		cmiform.cmi_core_session_time.value = cmi.core.session_time;
188  
-		cmiform.cmi_core_total_time.value = cmi.core.total_time;
189 225
 		cmiform.cmi_core_score_raw.value = cmi.core.score.raw;
190 226
 		cmiform.cmi_suspend_data.value = cmi.suspend_data;
191 227
 		cmiform.submit();
@@ -209,16 +245,25 @@ function LMSFinish (param) {
209 245
 	} else {
210 246
 	    Initialized = false;
211 247
 	    errorCode = 0;
  248
+	    cmi.core.total_time = AddTime(cmi.core.total_time, cmi.core.session_time);
  249
+	    //top.alert(cmi.core.total_time);
  250
+	    if (<?php echo $navObj ?>cmi.document.theform) {
  251
+		cmiform = <?php echo $navObj ?>cmi.document.forms[0];
  252
+		cmiform.scoid.value = "<?php echo $sco->id; ?>";
  253
+		cmiform.cmi_core_total_time.value = cmi.core.total_time;
  254
+		cmiform.submit();
  255
+		
  256
+	    }
  257
+            if (nav.event != "") {
212 258
             <?php
213  
-		 if ($scorm->auto) {
214  
-		     if ($sco != $last) {
215  
-	                 print "setTimeout('top.nav.document.navform.next.click();',500);\n";
216  
-		     } else {
217  
-			 print "exitloc = '".$CFG->wwwroot."/mod/scorm/view.php?id=$cm->id';\n";
218  
-			 print "setTimeout('top.location = exitloc;',500);\n";
219  
-		     }
  259
+		if ($sco != $last) {
  260
+	            echo "setTimeout('top.changeSco(nav.event);',500);\n";
  261
+		} else {
  262
+		    echo "exitloc = '".$CFG->wwwroot."/mod/scorm/view.php?id=".$cm->id."';\n";
  263
+		    echo "setTimeout('top.location = exitloc;',500);\n";
220 264
 		} 
221 265
 	    ?>
  266
+	    }
222 267
 	    return "true";
223 268
 	}    
224 269
     }
@@ -273,6 +318,7 @@ function AddTime (first, second) {
273 318
 	
274 319
 	return hours + ":" + mins + ":" + secs;
275 320
     }
  321
+    
276 322
     this.LMSInitialize = LMSInitialize;
277 323
     this.LMSGetValue = LMSGetValue;
278 324
     this.LMSSetValue = LMSSetValue;
34  mod/scorm/cmi.php
@@ -32,16 +32,25 @@
32 32
 
33 33
     require_login($course->id);
34 34
     
35  
-    if ($_POST["scoid"]) {
36  
-    	set_field("scorm_sco_users","cmi_core_lesson_location",$_POST["cmi_core_lesson_location"],"scoid",$_POST["scoid"],"userid",$USER->id);
37  
-        set_field("scorm_sco_users","cmi_core_lesson_status",$_POST["cmi_core_lesson_status"],"scoid",$_POST["scoid"],"userid",$USER->id);
38  
-        set_field("scorm_sco_users","cmi_core_exit",$_POST["cmi_core_exit"],"scoid",$_POST["scoid"],"userid",$USER->id);
39  
-        set_field("scorm_sco_users","cmi_core_session_time",$_POST["cmi_core_session_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
40  
-        set_field("scorm_sco_users","cmi_core_total_time",$_POST["cmi_core_total_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
41  
-        set_field("scorm_sco_users","cmi_core_score_raw",$_POST["cmi_core_score_raw"],"scoid",$_POST["scoid"],"userid",$USER->id);
42  
-        set_field("scorm_sco_users","cmi_suspend_data",$_POST["cmi_suspend_data"],"scoid",$_POST["scoid"],"userid",$USER->id);
43  
-    /*    if ($scorm->auto)
44  
-            $result="<script language=\"Javascript\">\n\ttop.nav.document.navform.next.click();\n    </script>\n"; */
  35
+    if (!empty($_POST["scoid"])) {
  36
+        if (!empty($_POST["cmi_core_lesson_location"])) {
  37
+    	    set_field("scorm_sco_users","cmi_core_lesson_location",$_POST["cmi_core_lesson_location"],"scoid",$_POST["scoid"],"userid",$USER->id);
  38
+    	}
  39
+    	if (!empty($_POST["cmi_core_lesson_status"])) {
  40
+            set_field("scorm_sco_users","cmi_core_lesson_status",$_POST["cmi_core_lesson_status"],"scoid",$_POST["scoid"],"userid",$USER->id);
  41
+        }
  42
+    	if (!empty($_POST["cmi_core_exit"])) {
  43
+            set_field("scorm_sco_users","cmi_core_exit",$_POST["cmi_core_exit"],"scoid",$_POST["scoid"],"userid",$USER->id);
  44
+        }
  45
+    	if (!empty($_POST["cmi_core_total_time"])) {
  46
+            set_field("scorm_sco_users","cmi_core_total_time",$_POST["cmi_core_total_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
  47
+        }
  48
+    	if (!empty($_POST["cmi_core_score_raw"])) {
  49
+            set_field("scorm_sco_users","cmi_core_score_raw",$_POST["cmi_core_score_raw"],"scoid",$_POST["scoid"],"userid",$USER->id);
  50
+        }
  51
+    	if (!empty($_POST["cmi_suspend_data"])) {
  52
+            set_field("scorm_sco_users","cmi_suspend_data",$_POST["cmi_suspend_data"],"scoid",$_POST["scoid"],"userid",$USER->id);
  53
+        }
45 54
     }
46 55
 ?>
47 56
 <html>
@@ -49,16 +58,15 @@
49 58
    <title>cmi</title>
50 59
 </head>
51 60
 <body>
52  
-   <form name="theform" method="POST" action="<?php echo $_SERVER["PHP_SELF"] ?>?id=<?php echo $cm->id ?>"> 
  61
+   <form name="theform" method="POST" action="<?php echo $ME ?>?id=<?php echo $cm->id ?>"> 
53 62
 	<input type="hidden" name="scoid" />
54 63
 	<input type="hidden" name="cmi_core_lesson_location" />
55 64
 	<input type="hidden" name="cmi_core_lesson_status" />
56 65
 	<input type="hidden" name="cmi_core_exit" />
57 66
 	<input type="hidden" name="cmi_core_session_time" />
58  
-	<input type="hidden" name="cmi_core_total_time" />
  67
+	<input type="hidden" name="cmi_core_total_time"  />
59 68
 	<input type="hidden" name="cmi_core_score_raw" />
60 69
 	<input type="hidden" name="cmi_suspend_data" />
61 70
    </form>
62  
-   <?php echo $result?>
63 71
 </body>
64 72
 </html>
56  mod/scorm/coursefiles.php
@@ -35,7 +35,7 @@ function html_footer() {
35 35
     
36 36
     function html_header($course, $wdir, $formfield=""){
37 37
 
38  
-        global $CFG,$THEME;
  38
+        global $CFG,$THEME,$ME;
39 39
 
40 40
         if (! $site = get_site()) {
41 41
             error("Invalid site!");
@@ -57,9 +57,9 @@ function html_header($course, $wdir, $formfield=""){
57 57
             for ($i=1; $i<$numdirs; $i++) {
58 58
                $navigation .= " -> ";
59 59
                $link .= "/".urlencode($dirs[$i]);
60  
-               $navigation .= "<a href=\"".$_SERVER['PHP_SELF']."?id=$course->id&wdir=$link\">".$dirs[$i]."</a>";
  60
+               $navigation .= "<a href=\"".$ME."?id=$course->id&wdir=$link\">".$dirs[$i]."</a>";
61 61
             }
62  
-            $fullnav = "<a href=\"".$_SERVER['PHP_SELF']."?id=$course->id&wdir=/\">$strfiles</a> $navigation";
  62
+            $fullnav = "<a href=\"".$ME."?id=$course->id&wdir=/\">$strfiles</a> $navigation";
63 63
         }
64 64
 
65 65
         print_header();
@@ -153,7 +153,7 @@ function set_value(txt) {
153 153
 
154 154
                 echo "<P>$struploadafile ($strmaxsize) --> <B>$wdir</B>";
155 155
                 echo "<TABLE><TR><TD COLSPAN=2>";
156  
-                echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"post\" ACTION=\"".$_SERVER['PHP_SELF']."\">";
  156
+                echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"post\" ACTION=\"".$ME."\">";
157 157
                 echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$upload_max_filesize\">";
158 158
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
159 159
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
@@ -163,7 +163,7 @@ function set_value(txt) {
163 163
                 echo " <INPUT TYPE=submit NAME=save VALUE=\"$struploadthisfile\">";
164 164
                 echo "</FORM>";
165 165
                 echo "</TD><TD WIDTH=100%>";
166  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=\"get\">";
  166
+                echo "<FORM ACTION=\"".$ME."\" METHOD=\"get\">";
167 167
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
168 168
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
169 169
                 echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -196,8 +196,8 @@ function set_value(txt) {
196 196
                     print_simple_box_end();
197 197
                     echo "<br />";
198 198
                     notice_yesno (get_string("deletecheckfiles"), 
199  
-                                "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=delete&confirm=1",
200  
-                                "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=cancel");
  199
+                                "".basename($ME)."?id=$id&wdir=$wdir&action=delete&confirm=1",
  200
+                                "".basename($ME)."?id=$id&wdir=$wdir&action=cancel");
201 201
                 } else {
202 202
                     displaydir($wdir);
203 203
                 }
@@ -253,7 +253,7 @@ function set_value(txt) {
253 253
                 html_header($course, $wdir, "form.name");
254 254
                 echo "<P>$strrenamefileto:";
255 255
                 echo "<TABLE><TR><TD>";
256  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=\"post\" NAME=\"form\">";
  256
+                echo "<FORM ACTION=\"".$ME."\" METHOD=\"post\" NAME=\"form\">";
257 257
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
258 258
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
259 259
                 echo " <INPUT TYPE=hidden NAME=action VALUE=rename>";
@@ -262,7 +262,7 @@ function set_value(txt) {
262 262
                 echo " <INPUT TYPE=submit VALUE=\"$strrename\">";
263 263
                 echo "</FORM>";
264 264
                 echo "</TD><TD>";
265  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  265
+                echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
266 266
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
267 267
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
268 268
                 echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -291,7 +291,7 @@ function set_value(txt) {
291 291
                 html_header($course, $wdir, "form.name");
292 292
                 echo "<P>$strcreatefolder:";
293 293
                 echo "<TABLE><TR><TD>";
294  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=post NAME=form>";
  294
+                echo "<FORM ACTION=\"".$ME."\" METHOD=post NAME=form>";
295 295
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
296 296
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
297 297
                 echo " <INPUT TYPE=hidden NAME=action VALUE=mkdir>";
@@ -299,7 +299,7 @@ function set_value(txt) {
299 299
                 echo " <INPUT TYPE=submit VALUE=\"$strcreate\">";
300 300
                 echo "</FORM>";
301 301
                 echo "</TD><TD>";
302  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  302
+                echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
303 303
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
304 304
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
305 305
                 echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -338,7 +338,7 @@ function set_value(txt) {
338 338
                 print_heading("$streditfile");
339 339
 
340 340
                 echo "<TABLE><TR><TD COLSPAN=2>";
341  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=\"post\" NAME=\"form\" $onsubmit>";
  341
+                echo "<FORM ACTION=\"".$ME."\" METHOD=\"post\" NAME=\"form\" $onsubmit>";
342 342
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
343 343
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
344 344
                 echo " <INPUT TYPE=hidden NAME=file VALUE=\"$file\">";
@@ -348,7 +348,7 @@ function set_value(txt) {
348 348
                 echo " <INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\">";
349 349
                 echo "</FORM>";
350 350
                 echo "</TD><TD>";
351  
-                echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  351
+                echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
352 352
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
353 353
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
354 354
                 echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -402,7 +402,7 @@ function set_value(txt) {
402 402
                     echo "<BR>";
403 403
                     echo "<P ALIGN=CENTER>".get_string("whattocallzip");
404 404
                     echo "<TABLE><TR><TD>";
405  
-                    echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=post NAME=form>";
  405
+                    echo "<FORM ACTION=\"".$ME."\" METHOD=post NAME=form>";
406 406
                     echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
407 407
                     echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
408 408
                     echo " <INPUT TYPE=hidden NAME=action VALUE=zip>";
@@ -410,7 +410,7 @@ function set_value(txt) {
410 410
                     echo " <INPUT TYPE=submit VALUE=\"".get_string("createziparchive")."\">";
411 411
                     echo "</FORM>";
412 412
                     echo "</TD><TD>";
413  
-                    echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  413
+                    echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
414 414
                     echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
415 415
                     echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
416 416
                     echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -476,7 +476,7 @@ function set_value(txt) {
476 476
                     print_simple_box_end();
477 477
                 }
478 478
 
479  
-                echo "<CENTER><FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  479
+                echo "<CENTER><FORM ACTION=\"".$ME."\" METHOD=get>";
480 480
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
481 481
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
482 482
                 echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -523,7 +523,7 @@ function set_value(txt) {
523 523
                     }
524 524
                     echo "</table>";
525 525
                 }
526  
-                echo "<br><center><form action=\"".$_SERVER['PHP_SELF']."\" method=get>";
  526
+                echo "<br><center><form action=\"".$ME."\" method=get>";
527 527
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
528 528
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=$wdir>";
529 529
                 echo " <INPUT TYPE=hidden NAME=action VALUE=cancel>";
@@ -670,7 +670,7 @@ function displaydir ($wdir) {
670 670
 
671 671
     global $basedir;
672 672
     global $id;
673  
-    global $USER, $CFG;
  673
+    global $USER, $CFG, $ME;
674 674
 
675 675
     $fullpath = $basedir.$wdir;
676 676
 
@@ -707,7 +707,7 @@ function displaydir ($wdir) {
707 707
     $strchoose   = get_string("choose");
708 708
 
709 709
 
710  
-    echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=post NAME=dirform>";
  710
+    echo "<FORM ACTION=\"".$ME."\" METHOD=post NAME=dirform>";
711 711
     echo "<TABLE BORDER=0 cellspacing=2 cellpadding=2 width=640>";    
712 712
     echo "<TR>";
713 713
     echo "<TH WIDTH=5></TH>";
@@ -737,10 +737,10 @@ function displaydir ($wdir) {
737 737
             echo "<TR>";
738 738
 
739 739
             print_cell("center", "<INPUT TYPE=checkbox NAME=\"file$count\" VALUE=\"$fileurl\">");
740  
-            print_cell("left", "<A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$fileurl\"><IMG SRC=\"$CFG->pixpath/f/folder.gif\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"Folder\"></A> <A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$fileurl\">".htmlspecialchars($dir)."</A>");
  740
+            print_cell("left", "<A HREF=\"".basename($ME)."?id=$id&wdir=$fileurl\"><IMG SRC=\"$CFG->pixpath/f/folder.gif\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"Folder\"></A> <A HREF=\"".basename($ME)."?id=$id&wdir=$fileurl\">".htmlspecialchars($dir)."</A>");
741 741
             print_cell("right", "-");
742 742
             print_cell("right", $filedate);
743  
-            print_cell("right", "<A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</A>");
  743
+            print_cell("right", "<A HREF=\"".basename($ME)."?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</A>");
744 744
     
745 745
             echo "</TR>";
746 746
         }
@@ -790,13 +790,13 @@ function displaydir ($wdir) {
790 790
             $edittext = "<b><a onMouseDown=\"return set_value('$selectfile')\" href=\"\">$strchoose</a></b>&nbsp;";
791 791
 
792 792
             if ($icon == "text.gif" || $icon == "html.gif") {
793  
-                $edittext .= "<a href=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$fileurl&action=edit\">$stredit</a>";
  793
+                $edittext .= "<a href=\"".basename($ME)."?id=$id&wdir=$wdir&file=$fileurl&action=edit\">$stredit</a>";
794 794
             } else if ($icon == "zip.gif") {
795  
-                $edittext .= "<a href=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$fileurl&action=unzip\">$strunzip</a>&nbsp;";
796  
-                $edittext .= "<a href=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$fileurl&action=listzip\">$strlist</a> ";
  795
+                $edittext .= "<a href=\"".basename($ME)."?id=$id&wdir=$wdir&file=$fileurl&action=unzip\">$strunzip</a>&nbsp;";
  796
+                $edittext .= "<a href=\"".basename($ME)."?id=$id&wdir=$wdir&file=$fileurl&action=listzip\">$strlist</a> ";
797 797
             }
798 798
 
799  
-            print_cell("right", "$edittext <A HREF=\"".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</A>");
  799
+            print_cell("right", "$edittext <A HREF=\"".basename($ME)."?id=$id&wdir=$wdir&file=$filesafe&action=rename\">$strrename</A>");
800 800
     
801 801
             echo "</tr>";
802 802
         }
@@ -824,7 +824,7 @@ function displaydir ($wdir) {
824 824
     echo "</FORM>";
825 825
     echo "<TD ALIGN=center>";
826 826
     if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {
827  
-        echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  827
+        echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
828 828
         echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
829 829
         echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
830 830
         echo " <INPUT TYPE=hidden NAME=action VALUE=paste>";
@@ -832,7 +832,7 @@ function displaydir ($wdir) {
832 832
         echo "</FORM>";
833 833
     }
834 834
     echo "<TD ALIGN=right>";
835  
-        echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  835
+        echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
836 836
         echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
837 837
         echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
838 838
         echo " <INPUT TYPE=hidden NAME=action VALUE=mkdir>";
@@ -840,7 +840,7 @@ function displaydir ($wdir) {
840 840
         echo "</FORM>";
841 841
     echo "</TD>";
842 842
     echo "<TD ALIGN=right>";
843  
-        echo "<FORM ACTION=\"".$_SERVER['PHP_SELF']."\" METHOD=get>";
  843
+        echo "<FORM ACTION=\"".$ME."\" METHOD=get>";
844 844
         echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
845 845
         echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
846 846
         echo " <INPUT TYPE=hidden NAME=action VALUE=upload>";
9  mod/scorm/db/mysql.php
@@ -5,14 +5,17 @@ function scorm_upgrade($oldversion) {
5 5
 /// older versions to match current functionality
6 6
     global $CFG;
7 7
     if ($oldversion < 2004033000) {
8  
-    	execute_sql(" ALTER TABLE `{$CFG->prefix}scorm` ADD `auto` TINYINT( 1 ) UNSIGNED DEFAULT '0' NOT NULL AFTER `summary`"); 
  8
+    	table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary"); 
9 9
     }
10 10
     if ($oldversion < 2004040900) {
11  
-    	execute_sql(" ALTER TABLE `{$CFG->prefix}scorm_sco_users` ADD `cmi_core_score_raw` FLOAT( 3 ) DEFAULT '0' NOT NULL AFTER `cmi_core_session_time`"); 
  11
+        table_column("scorm_sco_users", "", "cmi_core_score_raw", "FLOAT", "3", "", "0", "NOT NULL", "cmi_core_session_time");
  12
+    }
  13
+    if ($oldversion < 2004061800) {
  14
+    	table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
  15
+    	table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
12 16
     }
13 17
     return true;
14 18
 }
15 19
 
16 20
 
17 21
 ?>
18  
-
3  mod/scorm/db/mysql.sql
@@ -6,11 +6,12 @@ CREATE TABLE prefix_scorm (
6 6
   id int(10) unsigned NOT NULL auto_increment,
7 7
   course int(10) unsigned NOT NULL default '0',
8 8
   name varchar(255) NOT NULL default '',
9  
-  reference varchar(255) default NULL,
  9
+  reference varchar(255) NOT NULL default '',
10 10
   datadir varchar(255) NOT NULL default '',
11 11
   launch int(10) unsigned NOT NULL default 0,
12 12
   summary text NOT NULL,
13 13
   auto tinyint(1) unsigned NOT NULL default '0',
  14
+  popup varchar(255) NOT NULL default '',
14 15
   timemodified int(10) unsigned NOT NULL default '0',
15 16
   PRIMARY KEY  (id),
16 17
   UNIQUE KEY id (id)
12  mod/scorm/db/postgres7.php
@@ -3,7 +3,17 @@
3 3
 function scorm_upgrade($oldversion) {
4 4
 // This function does anything necessary to upgrade
5 5
 // older versions to match current functionality
6  
-
  6
+    global $CFG;
  7
+    if ($oldversion < 2004033000) {
  8
+    	table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary"); 
  9
+    }
  10
+    if ($oldversion < 2004040900) {
  11
+        table_column("scorm_sco_users", "", "cmi_core_score_raw", "real", "3", "", "0", "NOT NULL", "cmi_core_session_time");
  12
+    }
  13
+    if ($oldversion < 2004061800) {
  14
+    	table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
  15
+    	table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
  16
+    }
7 17
     return true;
8 18
 }
9 19
 
3  mod/scorm/db/postgres7.sql
@@ -6,11 +6,12 @@ CREATE TABLE prefix_scorm (
6 6
   id SERIAL PRIMARY KEY,
7 7
   course integer NOT NULL default '0',
8 8
   name varchar(255) NOT NULL default '',
9  
-  reference varchar(255) default NULL,
  9
+  reference varchar(255) NOT NULL default '',
10 10
   datadir varchar(255) NOT NULL default '',
11 11
   launch integer NOT NULL default '0',
12 12
   summary text NOT NULL default '',
13 13
   auto integer NOT NULL default '0',
  14
+  popup varchar(255) NOT NULL default '',
14 15
   timemodified integer NOT NULL default '0'
15 16
 );
16 17
 
144  mod/scorm/details.php
@@ -79,29 +79,137 @@
79 79
     	echo "<table cellpadding=\"5\" align=\"center\">\n";
80 80
     	echo "    <tr><td align=\"right\" nowrap><p><b>$strname:</b></p></td><td><p>$form->name</p></a></td></tr>\n";
81 81
     	echo "    <tr><td align=\"right\" nowrap><p><b>".get_string("validation","scorm").":</b></p></td><td><p>".get_string($result,"scorm")."</p></a></td></tr>\n";
82  
-    	if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_user","scormid",$form->instance)))
  82
+    	if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance)))
83 83
 	    echo "    <tr><td align=\"center\" colspan=\"2\" nowrap><p><b>".get_string("trackingloose","scorm")."</b></p></td></tr>\n";
84 84
     	echo "</table>\n";
85 85
     	if ($result == "regular") {
  86
+    	    if (empty($form->auto)) {
  87
+		$form->auto = "";
  88
+    	    }
86 89
 	    echo "<form name=\"theform\" method=\"post\" action=\"$form->destination\">\n";
  90
+	    
  91
+	    //$form->popup = $CFG->scorm_popup;
  92
+	    $strnewwindow     = get_string("newwindow", "scorm");
  93
+            $strnewwindowopen = get_string("newwindowopen", "scorm");
  94
+	    foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
  95
+        	$stringname = "str$optionname";
  96
+        	$$stringname = get_string("new$optionname", "scorm");
  97
+        	$window->$optionname = "";
  98
+        	$jsoption[] = "\"$optionname\"";
  99
+            }
  100
+            $alljsoptions = implode(",", $jsoption);
  101
+	    
  102
+            if ($form->instance) {     // Re-editing
  103
+         	if ($form->popup == "") {
  104
+                    $newwindow = "";   // Disable the new window
  105
+                    foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
  106
+                       	$defaultvalue = "scorm_popup$optionname";
  107
+                    	$window->$optionname = $CFG->$defaultvalue;
  108
+         	    }
  109
+         	} else {
  110
+             	    $newwindow = "checked";
  111
+                    $rawoptions = explode(',', $form->popup); 
  112
+                    foreach ($rawoptions as $rawoption) {
  113
+                 	$option = explode('=', trim($rawoption));
  114
+                 	if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) {
  115
+                 	    $optionname = $option[0];
  116
+                 	    $optionvalue = $option[1];
  117
+                 	    if ($optionname == "height" or $optionname == "width") {
  118
+                 	        $window->$optionname = $optionvalue;
  119
+                 	    } else if ($optionvalue == 1) {
  120
+                 	        $window->$optionname = "checked";
  121
+                 	    }
  122
+                 	}
  123
+             	    }
  124
+         	}
  125
+     	    } else {
  126
+            	foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
  127
+                    $defaultvalue = "scorm_popup$optionname";
  128
+                    $window->$optionname = $CFG->$defaultvalue;
  129
+         	}
  130
+         	$newwindow = $CFG->scorm_popup;
  131
+     	    }
  132
+	    
87 133
 ?>
88  
-        <input type="hidden" name="reference"	value="<?php p($form->reference) ?>">
89  
-        <input type="hidden" name="datadir"	value="<?php p(substr($tempdir,strlen($scormdir))) ?>">
90  
-        <input type="hidden" name="summary"	value="<?php p($form->summary) ?>">
91  
-        <input type="hidden" name="auto"	value="<?php p($form->auto) ?>">
92  
-        <input type="hidden" name="name"	value="<?php p($form->name) ?>">
93  
-	<input type="hidden" name="launch"	value="<?php p($form->launch) ?>">
94  
-        <input type="hidden" name="course"	value="<?php p($form->course) ?>">
95  
-        <input type="hidden" name="coursemodule"	value="<?php p($form->coursemodule) ?>">
96  
-        <input type="hidden" name="section"	value="<?php p($form->section) ?>">
97  
-        <input type="hidden" name="module"	value="<?php p($form->module) ?>">
98  
-        <input type="hidden" name="modulename"	value="<?php p($form->modulename) ?>">
99  
-        <input type="hidden" name="instance"	value="<?php p($form->instance) ?>">
100  
-        <input type="hidden" name="mode"	value="<?php p($form->mode) ?>">
101  
-	<center>
102  
-	    <input type="submit" value="<?php print_string("savechanges") ?>">
103  
-	    <input type="submit" name=cancel value="<?php print_string("cancel") ?>">
104  
-	</center>
  134
+	<table cellpadding="5" align="center">
  135
+	  <tr valign=top>
  136
+	    <td align=right><p><b><?php print_string("autocontinue","scorm") ?>:</b></p></td>
  137
+	    <td>
  138
+	    <?php
  139
+	    	$options[]=get_string("no");
  140
+	    	$options[]=get_string("yes");
  141
+	        choose_from_menu ($options, "auto", $form->auto);
  142
+	    ?>
  143
+	    </td>
  144
+	  </tr>
  145
+	  <tr valign="top">
  146
+            <td align="right" nowrap>
  147
+                <p><b><?php p($strnewwindow) ?></b></p>
  148
+            </td>
  149
+            <td>
  150
+                <script>
  151
+                    var subitems = [<?php echo $alljsoptions; ?>];
  152
+                    
  153
+                    function autowindow() {
  154
+                        if (document.theform.newwindow.checked) 
  155
+                            document.theform.auto.disabled=true;
  156
+                        else
  157
+                            document.theform.auto.disabled=false;
  158
+                    }
  159
+                    
  160
+                    <?php
  161
+                        if ($newwindow == "checked")
  162
+                            echo "document.theform.auto.disabled=true;\n";
  163
+                    ?>
  164
+                </script>
  165
+                <input name="setnewwindow" type=hidden value=1 />
  166
+                <input name="newwindow" type=checkbox value=1 <?php p($newwindow) ?> onclick="autowindow();return lockoptions('theform','newwindow', subitems);" /> 
  167
+                <?php p($strnewwindowopen) ?>
  168
+                <ul>
  169
+                <?php
  170
+                    foreach ($window as $name => $value) {
  171
+                        if ($name == "height" or $name == "width") {
  172
+                            continue;
  173
+                        }
  174
+                        echo "\t\t<input name=\"h$name\" type=\"hidden\" value=\"0\" />\n";
  175
+                        echo "\t\t<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." /> ";
  176
+                        $stringname = "str$name";
  177
+                        echo $$stringname."<br />\n";
  178
+                     }
  179
+                ?>
  180
+
  181
+                <input name="hwidth" type=hidden value="0" />
  182
+                <input name="width" type=text size=4 value="<?php p($window->width) ?>" /> <?php p($strwidth) ?><br />
  183
+                <input name="hheight" type=hidden value="0" />
  184
+                <input name="height" type=text size=4 value="<?php p($window->height) ?>" /> <?php p($strheight) ?><br />
  185
+                 <?php
  186
+                     if (!$newwindow) {
  187
+                         echo "<script>\n<!--\n";
  188
+                         echo "\tlockoptions('theform','newwindow', subitems);";
  189
+                         echo "\n-->\n</script>";
  190
+                     }
  191
+                 ?>
  192
+                 </ul>
  193
+                 </p>
  194
+             </td>
  195
+           </tr>
  196
+        </table>
  197
+        <input type="hidden" name="reference"	value="<?php p($form->reference) ?>" />
  198
+        <input type="hidden" name="datadir"	value="<?php p(substr($tempdir,strlen($scormdir))) ?>" />
  199
+        <input type="hidden" name="summary"	value="<?php p($form->summary) ?>" />
  200
+        <input type="hidden" name="name"	value="<?php p($form->name) ?>" />
  201
+	<input type="hidden" name="launch"	value="<?php p($form->launch) ?>" />
  202
+        <input type="hidden" name="course"	value="<?php p($form->course) ?>" />
  203
+        <input type="hidden" name="coursemodule"	value="<?php p($form->coursemodule) ?>" />
  204
+        <input type="hidden" name="section"	value="<?php p($form->section) ?>" />
  205
+        <input type="hidden" name="module"	value="<?php p($form->module) ?>" />
  206
+        <input type="hidden" name="modulename"	value="<?php p($form->modulename) ?>" />
  207
+        <input type="hidden" name="instance"	value="<?php p($form->instance) ?>" />
  208
+        <input type="hidden" name="mode"	value="<?php p($form->mode) ?>" />
  209
+	<div align="center">
  210
+	    <input type="submit" value="<?php print_string("savechanges") ?>" />
  211
+	    <input type="submit" name=cancel value="<?php print_string("cancel") ?>" />
  212
+	</div>
105 213
         </form>
106 214
 <?php
107 215
     	} else {
258  mod/scorm/lib.php
@@ -3,8 +3,28 @@
3 3
 /// Library of functions and constants for module scorm
4 4
 /// (replace scorm with the name of your module and delete this line)
5 5
 
  6
+$SCORM_WINDOW_OPTIONS = array("resizable", "scrollbars", "status", "height", "width");
  7
+
  8
+if (!isset($CFG->scorm_popup)) {
  9
+    set_config("scorm_popup", "");
  10
+}  
  11
+
  12
+foreach ($SCORM_WINDOW_OPTIONS as $popupoption) {
  13
+    $popupoption = "scorm_popup$popupoption";
  14
+    if (!isset($CFG->$popupoption)) {
  15
+        if ($popupoption == "scorm_popupheight") {
  16
+            set_config($popupoption, 450);
  17
+        } else if ($popupoption == "scorm_popupwidth") {
  18
+            set_config($popupoption, 620);
  19
+        } else {
  20
+            set_config($popupoption, "checked");
  21
+        }
  22
+    }  
  23
+}
6 24
 
7  
-$SCORM_FRAME_SIZE = 140;
  25
+if (!isset($CFG->scorm_framesize)) {
  26
+    set_config("scorm_framesize", 140);
  27
+}
8 28
 
9 29
 function scorm_add_instance($scorm) {
10 30
 /// Given an object containing all the necessary data, 
@@ -15,6 +35,23 @@ function scorm_add_instance($scorm) {
15 35
     $scorm->timemodified = time();
16 36
 
17 37
     # May have to add extra stuff in here #
  38
+    global $SCORM_WINDOW_OPTIONS;
  39
+    
  40
+    $scorm->popup = "";
  41
+    
  42
+    $optionlist = array();
  43
+    foreach ($SCORM_WINDOW_OPTIONS as $option) {
  44
+        if (isset($scorm->$option)) {
  45
+            $optionlist[] = $option."=".$scorm->$option;
  46
+        }
  47
+    }
  48
+    $scorm->popup = implode(',', $optionlist);
  49
+    
  50
+
  51
+    if ($scorm->popup != "") {
  52
+    	$scorm->popup .= ',location=0,menubar=0,toolbar=0';
  53
+    	$scorm->auto = '0';
  54
+    }
18 55
     
19 56
     return insert_record("scorm", $scorm);
20 57
 }
@@ -24,12 +61,27 @@ function scorm_update_instance($scorm) {
24 61
 /// Given an object containing all the necessary data, 
25 62
 /// (defined by the form in mod.html) this function 
26 63
 /// will update an existing instance with new data.
27  
-
  64
+    
28 65
     $scorm->timemodified = time();
29 66
     $scorm->id = $scorm->instance;
30 67
 
31 68
     # May have to add extra stuff in here #
  69
+    global $SCORM_WINDOW_OPTIONS;
  70
+    
  71
+    $scorm->popup = "";
  72
+    
  73
+    $optionlist = array();
  74
+    foreach ($SCORM_WINDOW_OPTIONS as $option) {
  75
+        if (isset($scorm->$option)) {
  76
+            $optionlist[] = $option."=".$scorm->$option;
  77
+        }
  78
+    }
  79
+    $scorm->popup = implode(',', $optionlist);
32 80
 
  81
+    if ($scorm->popup != "") {
  82
+    	$scorm->popup .= ',location=0,menubar=0,toolbar=0';
  83
+    	$scorm->auto = '0';
  84
+    }
33 85
     return update_record("scorm", $scorm);
34 86
 }
35 87
 
@@ -38,7 +90,7 @@ function scorm_delete_instance($id) {
38 90
 /// Given an ID of an instance of this module, 
39 91
 /// this function will permanently delete the instance 
40 92
 /// and any data that depends on it.  
41  
-	
  93
+    
42 94
     require('../config.php');
43 95
 
44 96
     if (! $scorm = get_record("scorm", "id", "$id")) {
@@ -109,43 +161,45 @@ function scorm_grades($scormid) {
109 161
 /// Must return an array of grades for a given instance of this module, 
110 162
 /// indexed by user.  It also returns a maximum allowed grade.
111 163
 
112  
-	global $CFG;
113  
-	
  164
+    global $CFG;
  165
+    
  166
+    if (!$return->maxgrade = count_records_select("scorm_scoes","scorm='$scormid' AND launch<>''")) {
  167
+        return NULL;
  168
+    }
  169
+    
114 170
     $return->grades = NULL;
115 171
     if ($sco_users=get_records_select("scorm_sco_users", "scormid='$scormid' GROUP BY userid")) {
116 172
         foreach ($sco_users as $sco_user) {
117  
-        	$user_data=get_records_select("scorm_sco_users","scormid='$scormid' AND userid='$sco_user->userid'");
118  
-        	$scores->completed=0;
119  
-    		$scores->browsed=0;
120  
-    		$scores->incomplete=0;
121  
-    		$scores->failed=0;
122  
-    		$scores->notattempted=0;
123  
-    		$result="";
124  
-    		$data = current($user_data);
125  
-    		foreach ($user_data as $data) {
126  
-    			if ($data->cmi_core_lesson_status=="passed")
127  
-    				$scores->completed++;
128  
-    			else
129  
-    				$scores->{scorm_remove_spaces($data->cmi_core_lesson_status)}++;
130  
-    			
131  
-        	}
132  
-        	if ($scores->completed)
133  
-        		$result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string("completed","scorm")."\" title=\"".get_string("completed","scorm")."\"> $scores->completed ";
134  
-        	if ($scores->incomplete)
135  
-        		$result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/incomplete.gif\" alt=\"".get_string("incomplete","scorm")."\" title=\"".get_string("incomplete","scorm")."\"> $scores->incomplete ";
136  
-        	if ($scores->failed)
137  
-        		$result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/failed.gif\" alt=\"".get_string("failed","scorm")."\" title=\"".get_string("failed","scorm")."\"> $scores->failed ";
138  
-        	if ($scores->browsed)
139  
-        		$result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/browsed.gif\" alt=\"".get_string("browsed","scorm")."\" title=\"".get_string("browsed","scorm")."\"> $scores->browsed ";
140  
-   			if ($scores->notattempted)
141  
-        		$result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\"> $scores->notattempted ";
142  
-        	
143  
-        	$return->grades[$sco_user->userid]=$result;
  173
+            $user_data=get_records_select("scorm_sco_users","scormid='$scormid' AND userid='$sco_user->userid'");
  174
+            $scores->completed=0;
  175
+            $scores->browsed=0;
  176
+            $scores->incomplete=0;
  177
+            $scores->failed=0;
  178
+            $scores->notattempted=0;
  179
+            $result="";
  180
+            $data = current($user_data);
  181
+            foreach ($user_data as $data) {
  182
+                if ($data->cmi_core_lesson_status=="passed")
  183
+                    $scores->completed++;
  184
+                else
  185
+                    $scores->{scorm_remove_spaces($data->cmi_core_lesson_status)}++;
  186
+                
  187
+            }
  188
+            if ($scores->completed)
  189
+                $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string("completed","scorm")."\" title=\"".get_string("completed","scorm")."\"> $scores->completed ";
  190
+            if ($scores->incomplete)
  191
+                $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/incomplete.gif\" alt=\"".get_string("incomplete","scorm")."\" title=\"".get_string("incomplete","scorm")."\"> $scores->incomplete ";
  192
+            if ($scores->failed)
  193
+                $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/failed.gif\" alt=\"".get_string("failed","scorm")."\" title=\"".get_string("failed","scorm")."\"> $scores->failed ";
  194
+            if ($scores->browsed)
  195
+                $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/browsed.gif\" alt=\"".get_string("browsed","scorm")."\" title=\"".get_string("browsed","scorm")."\"> $scores->browsed ";
  196
+            if ($scores->notattempted)
  197
+                $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\"> $scores->notattempted ";
  198
+            
  199
+            $return->grades[$sco_user->userid]=$result;
144 200
         }
145 201
         
146 202
     }
147  
-    
148  
-    $return->maxgrade = count_records_select("scorm_scoes","scorm='$scormid' AND launch<>''");
149 203
 
150 204
     return $return;
151 205
 }
@@ -176,30 +230,30 @@ function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM")
176 230
 {
177 231
     global $CFG;
178 232
 
179  
-	if (($existingdir!="") && (is_dir($strPath.$existingdir)))
180  
-		return $strPath.$existingdir;
181  
-		
182  
-	if (is_dir($strPath)) {
183  
-		do {
184  
- 			$datadir="/".$prefix.scorm_randstring();
185  
- 	 	} while (file_exists($strPath.$datadir));
186  
- 		mkdir($strPath.$datadir, $CFG->directorypermissions);
  233
+    if (($existingdir!="") && (is_dir($strPath.$existingdir)))
  234
+        return $strPath.$existingdir;
  235
+        
  236
+    if (is_dir($strPath)) {
  237
+        do {
  238
+            $datadir="/".$prefix.scorm_randstring();
  239
+        } while (file_exists($strPath.$datadir));
  240
+        mkdir($strPath.$datadir, $CFG->directorypermissions);
187 241
         @chmod($strPath.$datadir, $CFG->directorypermissions);  // Just in case mkdir didn't do it
188  
- 		return $strPath.$datadir;
189  
- 	} else {
190  
- 		return false;
191  
- 	}
  242
+        return $strPath.$datadir;
  243
+    } else {
  244
+        return false;
  245
+    }
192 246
 } 
193 247
 
194 248
 function scorm_validate($manifest)
195 249
 {
196 250
     if (is_file ($manifest)) {
197  
-	if (file_exists($manifest))
198  
-	{
199  
-		return "regular";
200  
-	}
  251
+    if (file_exists($manifest))
  252
+    {
  253
+        return "regular";
  254
+    }
201 255
     } else {
202  
-	    return "nomanifest";
  256
+        return "nomanifest";
203 257
     }
204 258
 }
205 259
 
@@ -211,12 +265,12 @@ function scorm_delete_files($directory)
211 265
         while (($file = readdir($handle)) != '')
212 266
         {
213 267
             if ($file != "." && $file != "..")
214  
-	    {
215  
-	    	if (!is_dir($directory."/".$file))
  268
+        {
  269
+            if (!is_dir($directory."/".$file))
216 270
                     unlink($directory."/".$file);
217  
-	    	else
218  
-		    scorm_delete_files($directory."/".$file);
219  
-	    }
  271
+            else
  272
+            scorm_delete_files($directory."/".$file);
  273
+        }
220 274
         }
221 275
         rmdir($directory);
222 276
     }
@@ -225,17 +279,21 @@ function scorm_delete_files($directory)
225 279
 function scorm_startElement($parser, $name, $attrs) {
226 280
     global $manifest,$i,$resources,$parent,$level;
227 281
     if ($name == "ITEM") {
228  
-		$i++;
229  
-		$manifest[$i]["identifier"] = $attrs["IDENTIFIER"];
230  
-		$manifest[$i]["identifierref"] = $attrs["IDENTIFIERREF"];
231  
-		$manifest[$i]["isvisible"] = $attrs["ISVISIBLE"];
232  
-		$manifest[$i]["parent"] = $parent[$level];
233  
-		$level++;
234  
-		$parent[$level] = $attrs["IDENTIFIER"];
  282
+        $i++;
  283
+        $manifest[$i]["identifier"] = $attrs["IDENTIFIER"];
  284
+        if (empty($attrs["IDENTIFIERREF"]))
  285
+            $attrs["IDENTIFIERREF"] = "";
  286
+        $manifest[$i]["identifierref"] = $attrs["IDENTIFIERREF"];
  287
+        if (empty($attrs["ISVISIBLE"]))
  288
+            $attrs["ISVISIBLE"] = "";
  289
+        $manifest[$i]["isvisible"] = $attrs["ISVISIBLE"];
  290
+        $manifest[$i]["parent"] = $parent[$level];
  291
+        $level++;
  292
+        $parent[$level] = $attrs["IDENTIFIER"];
235 293
     }
236 294
     if ($name == "RESOURCE") {
237  
-		$resources[$attrs["IDENTIFIER"]]["href"]=$attrs["HREF"];
238  
-		$resources[$attrs["IDENTIFIER"]]["type"]=$attrs["ADLCP:SCORMTYPE"];
  295
+        $resources[$attrs["IDENTIFIER"]]["href"]=$attrs["HREF"];
  296
+        $resources[$attrs["IDENTIFIER"]]["type"]=$attrs["ADLCP:SCORMTYPE"];
239 297
     }
240 298
 }
241 299
 
@@ -244,10 +302,15 @@ function scorm_endElement($parser, $name) {
244 302
     if ($name == "ITEM") {
245 303
         $level--;
246 304
     }
247  
-    if ($name == "TITLE" && $level>0)
248  
-		$manifest[$i]["title"] = $datacontent;
249  
-	if ($name == "ADLCP:HIDERTSUI")
250  
-		$manifest[$i][$datacontent] = 1;
  305
+    if ($name == "TITLE" && $level>0) {
  306
+    	$manifest[$i]["title"] = $datacontent;
  307
+    }
  308
+    if ($name == "ADLCP:HIDERTSUI") {
  309
+    	$manifest[$i][$datacontent] = 1;
  310
+    }
  311
+    if ($name == "ORGANIZATION") {
  312
+    	$level = 0;
  313
+    }
251 314
 }
252 315
 
253 316
 function scorm_characterData($parser, $data) {
@@ -274,7 +337,7 @@ function scorm_parse($basedir,$file,$scorm_id) {
274 337
     }
275 338
 
276 339
     while ($data = fread($fp, 4096)) {
277  
-    	if (!xml_parse($xml_parser, $data, feof($fp))) {
  340
+        if (!xml_parse($xml_parser, $data, feof($fp))) {
278 341
             die(sprintf("XML error: %s at line %d",
279 342
                     xml_error_string(xml_get_error_code($xml_parser)),
280 343
                     xml_get_current_line_number($xml_parser)));
@@ -286,18 +349,27 @@ function scorm_parse($basedir,$file,$scorm_id) {
286 349
     $sco->scorm = $scorm_id;
287 350
     delete_records("scorm_scoes","scorm",$scorm_id);
288 351
     delete_records("scorm_sco_users","scormid",$scorm_id);
  352
+    print_r($manifest);
289 353
     for ($j=1; $j<=$i; $j++) {
290 354
         $sco->identifier = $manifest[$j]["identifier"];
291 355
         $sco->parent = $manifest[$j]["parent"];
292 356
         $sco->title = $manifest[$j]["title"];
293  
-        $sco->launch = $resources[$manifest[$j]["identifierref"]]["href"];
294  
-		$sco->type = $resources[$manifest[$j]["identifierref"]]["type"];
295  
-		$sco->previous = $manifest[$j]["previous"];
296  
-		$sco->next = $manifest[$j]["continue"];
297  
-		if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false")
298  
-			$id = insert_record("scorm_scoes",$sco);
299  
-		if ($launch==0 && $sco->launch)
300  
-	   		$launch = $id;	
  357
+        if (empty($resources[($manifest[$j]["identifierref"])]["href"]))
  358
+            $resources[($manifest[$j]["identifierref"])]["href"] = "";
  359
+        $sco->launch = $resources[($manifest[$j]["identifierref"])]["href"];
  360
+        if (empty($resources[($manifest[$j]["identifierref"])]["type"]))
  361
+            $resources[($manifest[$j]["identifierref"])]["type"] = "";
  362
+    $sco->type = $resources[($manifest[$j]["identifierref"])]["type"];
  363
+    if (empty($manifest[$j]["previous"]))
  364
+        $manifest[$j]["previous"] = 0;
  365
+    $sco->previous = $manifest[$j]["previous"];
  366
+    if (empty($manifest[$j]["continue"]))
  367
+        $manifest[$j]["continue"] = 0;
  368
+    $sco->next = $manifest[$j]["continue"];
  369
+    if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false")
  370
+        $id = insert_record("scorm_scoes",$sco);
  371
+    if ($launch==0 && $sco->launch)
  372
+        $launch = $id;  
301 373
     }
302 374
     return $launch;
303 375
 }
@@ -319,20 +391,20 @@ function scorm_get_scoes_records($sco_user) {
319 391
 function scorm_remove_spaces($sourcestr) {
320 392
 // Remove blank space from a string
321 393
     $newstr="";
322  
-	for( $i=0; $i<strlen($sourcestr); $i++) {
323  
-		if ($sourcestr[$i]!=' ')
324  
-			$newstr .=$sourcestr[$i];
325  
-	}
326  
-	return $newstr;
  394
+    for( $i=0; $i<strlen($sourcestr); $i++) {
  395
+        if ($sourcestr[$i]!=' ')
  396
+            $newstr .=$sourcestr[$i];
  397
+    }
  398
+    return $newstr;
327 399
 }
328 400
 
329 401
 function scorm_string_round($stringa) {
330 402
 // Crop a string to $len character and set an anchor title to the full string
331 403
     $len=11;
332 404
     if ( strlen($stringa)>$len ) {
333  
-	return "<A name=\"\" title=\"$stringa\">".substr($stringa,0,$len-4)."...".substr($stringa,strlen($stringa)-1,1)."</A>";
  405
+    return "<A name=\"\" title=\"$stringa\">".substr($stringa,0,$len-4)."...".substr($stringa,strlen($stringa)-1,1)."</A>";
334 406
     } else
335  
-	return $stringa;
  407
+    return $stringa;
336 408
 }
337 409
 
338 410
 function scorm_external_link($link) {
@@ -340,19 +412,19 @@ function scorm_external_link($link) {
340 412
     $result = false;
341 413
     $link = strtolower($link);
342 414
     if (substr($link,0,7) == "http://")
343  
-    	$result = true;
  415
+        $result = true;
344 416
     else if (substr($link,0,8) == "https://")
345  
-    	$result = true;
  417
+        $result = true;
346 418
     else if (substr($link,0,4) == "www.")
347  
-    	$result = true;
348  
-    else if (substr($link,0,7) == "rstp://")
349  
-    	$result = true;
  419
+        $result = true;
  420
+    /*else if (substr($link,0,7) == "rstp://")
  421
+        $result = true;
350 422
     else if (substr($link,0,6) == "rtp://")
351  
-    	$result = true;
  423
+        $result = true;
352 424
     else if (substr($link,0,6) == "ftp://")
353  
-    	$result = true;
  425
+        $result = true;
354 426
     else if (substr($link,0,9) == "gopher://")
355  
-    	$result = true;
  427
+        $result = true; */
356 428
     return $result;
357 429
 }    
358 430
 ?>
6  mod/scorm/mod.html
@@ -8,8 +8,8 @@
8 8
     if (empty($form->summary)) {
9 9
 	$form->summary = "";
10 10
     }
11  
-    if (empty($form->auto)) {
12  
-	$form->auto = "";
  11
+    if (empty($form->launch)) {
  12
+	$form->launch = "";
13 13
     }
14 14
 ?>
15 15
 
@@ -70,6 +70,8 @@
70 70
     <input type="hidden" name=coursemodule	value="<?php p($form->coursemodule) ?>">
71 71
     <input type="hidden" name=datadir	value="<?php p($form->datadir) ?>">
72 72
     <input type="hidden" name=launch	value="<?php p($form->launch) ?>">