First step for SCORM2004, new communication subsystem
authorbobopinna <bobopinna>
Thu, 17 Feb 2005 08:52:54 +0000 (08:52 +0000)
committerbobopinna <bobopinna>
Thu, 17 Feb 2005 08:52:54 +0000 (08:52 +0000)
16 files changed:
mod/scorm/api.php [new file with mode: 0644]
mod/scorm/api1_2.php [deleted file]
mod/scorm/config.html
mod/scorm/datamodel.php [moved from mod/scorm/cmi.php with 74% similarity]
mod/scorm/details.php [deleted file]
mod/scorm/index.php
mod/scorm/lib.php
mod/scorm/loadSCO.php [new file with mode: 0755]
mod/scorm/mod.html
mod/scorm/playscorm.php
mod/scorm/report.php
mod/scorm/request.js [new file with mode: 0644]
mod/scorm/scormAPI.php [deleted file]
mod/scorm/validate.php [new file with mode: 0755]
mod/scorm/version.php
mod/scorm/view.php

diff --git a/mod/scorm/api.php b/mod/scorm/api.php
new file mode 100644 (file)
index 0000000..4d2d54b
--- /dev/null
@@ -0,0 +1,205 @@
+<?php
+
+    require_once("../../config.php");
+
+    optional_variable($id);    // Course Module ID, or
+    optional_variable($a);     // scorm ID
+
+    if ($id) {
+        if (! $cm = get_record("course_modules", "id", $id)) {
+            error("Course Module ID was incorrect");
+        }
+    
+        if (! $course = get_record("course", "id", $cm->course)) {
+            error("Course is misconfigured");
+        }
+    
+        if (! $scorm = get_record("scorm", "id", $cm->instance)) {
+            error("Course module is incorrect");
+        }
+
+    } else {
+        if (! $scorm = get_record("scorm", "id", $a)) {
+            error("Course module is incorrect");
+        }
+        if (! $course = get_record("course", "id", $scorm->course)) {
+            error("Course is misconfigured");
+        }
+        if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
+            error("Course Module ID was incorrect");
+        }
+    }
+
+    require_login($course->id, false, $cm);
+?>
+
+function SCOFinish(){
+    /*if (typeof API != "undefined") {
+       API.SaveTotalTime();
+    } */
+}
+
+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
+//
+var errorCode = "0";
+
+function SCORM_Call (call,param,value) {
+    if (arguments.caller.length < 2) {
+       alert ("Invalid SCORM_Call function call: too few arguments.\nYou need pass at least 2 parameters");
+    } else if (arguments.caller.length == 3) {
+       param = param.concat("&value=",value);
+    }
+    var myRequest = NewHttpReq();
+    result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php?id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>&param="+param);
+    results = result.split('\n');
+    
+    errorCode = results[1];
+    return results[0];
+}
+
+//
+// SCORM 1.2 API Implementation
+//
+function SCORMapi1_2() {
+
+    function LMSInitialize (param) {
+       return SCORM_Call('LMSInitialize',param);
+    }
+    
+    function LMSFinish (param) {
+       return SCORM_Call('LMSGetValue',param);
+    }
+    
+    function LMSGetValue (element) {
+       return SCORM_Call('LMSGetValue',element);
+    }
+    
+    function LMSSetValue (element,value) {
+       return SCORM_Call('LMSGetValue',element,value);
+    }
+    
+    function LMSCommit (param) {
+       return SCORM_Call('LMSGetValue',param);
+    }
+    
+    function LMSGetLastError () {
+       return errorCode;
+    }
+    
+    function LMSGetErrorString (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];
+    }
+    
+    function LMSGetDiagnostic (param) {
+       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();
+
+//
+// SCORM 2004 API Implementation
+//
+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);
+    }
+    
+    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();
\ No newline at end of file
diff --git a/mod/scorm/api1_2.php b/mod/scorm/api1_2.php
deleted file mode 100644 (file)
index 0c8c170..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-// 
-// SCORM API 1.2 Implementation
-//
-
-function SCORMapi() {
-    var cmi= new Object();
-    var nav = new Object();
-
-    var errorCode = "0";
-    
-    var Initialized = false;
-
-    function LMSInitialize (param) {
-       if (param != "") {
-           errorCode = "201";
-           return "false";
-       }
-       if (!Initialized) {
-           Initialized = true;
-           errorCode = "0";
-           
-           //
-           // CMI Initialization SCORM 1.2
-           //
-           cmi.core = new Object();
-           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";
-           cmi.core.student_id = "<?php echo $USER->username; ?>";
-           cmi.core.student_name = "<?php echo $USER->lastname.", ".$USER->firstname; ?>";
-           cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location; ?>";
-           cmi.core.credit = "<?php if ($mode != 'normal') {
-                                        echo "no-credit";
-                                    } else {
-                                        echo "credit";
-                                    }?>";
-           cmi.core.lesson_status = "<?php echo $sco_user->cmi_core_lesson_status; ?>";
-           cmi.core.exit = "<?php echo $sco_user->cmi_core_exit ?>";
-           cmi.core.entry = "<?php if ($sco_user->cmi_core_lesson_status == 'not attempted') {
-                                       echo 'ab-initio'; 
-                                   } else {
-                                       if ($sco_user->cmi_core_lesson_status != 'completed') {
-                                           echo 'resume'; 
-                                       } else {
-                                           echo '';
-                                       }
-                                   }?>";
-           cmi.core.session_time = "00:00:00";
-           cmi.core.total_time = "<?php echo $sco_user->cmi_core_total_time; ?>";
-           cmi.core.lesson_mode = "<?php echo $mode; ?>";
-           cmi.core.score = new Object();
-           cmi.core.score._children = "raw,min,max";
-           cmi.core.score.raw = "<?php echo $sco_user->cmi_core_score_raw; ?>";
-           cmi.core.score.min = "";
-           cmi.core.score.max = "";
-           cmi.suspend_data = "<?php echo $sco_user->cmi_suspend_data; ?>";
-           cmi.launch_data = "<?php echo $sco->datafromlms; ?>";
-           cmi.comments = "";
-           cmi.comments_from_lms = "";
-           //
-           // end CMI Initialization
-           //
-           
-           // Navigation Object
-           <?php 
-               if ($scorm->auto) {
-                   echo 'nav.event = "continue";'."\n";
-               } else {
-                   echo 'nav.event = "";'."\n";
-               }
-           ?>
-
-           return "true";
-       } else {
-           errorCode = "101";
-           return "false";
-       }
-    }
-    
-    function LMSGetValue (param) {
-       if (Initialized) {
-           //top.alert("GET "+param);
-           switch (param) {
-               case "cmi.core._children":
-               case "cmi.core.student_id":
-               case "cmi.core.student_name":
-               case "cmi.core.lesson_location":
-               case "cmi.core.credit":
-               case "cmi.core.lesson_status":
-               case "cmi.core.entry":
-               case "cmi.core.total_time":
-               case "cmi.core.lesson_mode":
-               case "cmi.core.score._children":
-               case "cmi.core.score.raw":
-               case "cmi.core.score.min":
-               case "cmi.core.score.max":
-               case "cmi.launch_data":
-               case "cmi.suspend_data":
-               case "cmi.comments":
-               case "cmi.comments_from_lms":
-                   errorCode = "0";
-                   return eval(param);
-               break;
-               case "cmi.core.exit":
-               case "cmi.core.session_time":
-                   errorCode = "404";
-                   return "";
-               break;
-               default:
-                   errorCode = "401";
-                   param = param.replace(/.(\d+)./g,"[$1].");
-                   
-                   children = param.match(/._children$/);
-                   if (children != null) {
-                       objType = typeof eval(children[1]);
-                       //alert (param+" :"+objType);
-                       if (objType  != "undefined") {
-                           
-                           errorCode = "202";
-                       }
-                   }
-                   
-                   counted = param.match(/._count$/);
-                   if (counted != null) {
-                       objType = typeof eval(counted[1]);
-                       //alert (param+" :"+objType);
-                       if (objType != "undefined") {
-                           errorCode = "203";
-                       }
-                   }
-                   //alert(param+": "+errorCode);
-                   return "";  
-               break;
-           }
-       } else {
-           errorCode = "301";
-           return "";
-       }
-    }
-    
-    function LMSSetValue (param,value) {
-       if (Initialized) {
-           //top.alert("SET "+param+" = "+value);
-           switch (param) {
-               case "cmi.core.session_time":
-                   if (typeof(value) == "string") {
-                       var parsedtime = value.match(/^([0-9]{2,4}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,2})?$/);
-                       if (parsedtime != null) {
-                           //top.alert(parsedtime);
-                           if (((parsedtime.length == 4) || (parsedtime.length == 5)) && (parsedtime[3]>=0) && (parsedtime[3]<=59)) {
-                               eval(param+'="'+value+'";');
-                               errorCode = "0";
-                               return "true";
-                           } else {
-                               errorCode = "405";
-                               return "false";
-                           }
-                       } else {
-                           errorCode = "405";
-                           return "false";
-                       }
-                   } else {
-                       errorCode = "405";
-                       return "false";
-                   }
-               break;
-               case "cmi.core.lesson_status":
-                   if ((value!="passed")&&(value!="completed")&&(value!="failed")&&(value!="incomplete")&&(value!="browsed")) {
-                       errorCode = "405";
-                       return "false";
-                   }
-                   eval(param+'="'+value+'";');
-                   errorCode = "0";
-                   return "true";
-               break;
-               case "cmi.core.score.raw":
-               case "cmi.core.score.min":
-               case "cmi.core.score.max":
-                   if (value != "") {
-                       if ((parseFloat(value,10)).toString() != value) {
-                           errorCode = "405";
-                           return "false";
-                       } else {
-                           rawvalue = parseFloat(value,10);
-                           if ((rawvalue<0) || (rawvalue>100)) {
-                               errorCode = "405";
-                               return "false";
-                           }
-                       }
-                   }
-                   eval(param+'="'+value+'";');
-                   errorCode = "0";
-                   return "true";
-               break;
-               case "cmi.core.exit":
-                   if ((value!="time-out")&&(value!="suspend")&&(value!="logout")&&(value!="")) {
-                       errorCode = "405";
-                       return "false";
-                   }
-                   eval(param+'="'+value+'";');
-                   errorCode = "0";
-                   return "true";
-               break;
-               case "cmi.core.lesson_location":
-                   if (value.length > 255) {
-                       errorCode = "405";
-                       return "false";
-                   }
-                   eval(param+'="'+value+'";');
-                   errorCode = "0";
-                   return "true";
-               break;
-               case "cmi.comments":
-                   if ((value.length + cmi.comments.length) > 4096) {
-                       errorCode = "405";
-                       return "false";
-                   }
-                   eval(param+'=cmi.comments + "'+value+'";');
-                   errorCode = "0";
-                   return "true";
-               break;
-               case "cmi.suspend_data":
-                   if (value.length > 4096) {
-                       errorCode = "405";
-                       return "false";
-                   }
-                   eval(param+'="'+value+'";');
-                   errorCode = "0";
-                   return "true";
-               break;
-               case "cmi.core._children":
-               case "cmi.core.score._children":
-                   errorCode = "402";
-                   return "false";
-               break;
-               case "cmi.core.student_id":
-               case "cmi.core.student_name":
-               case "cmi.core.credit":
-               case "cmi.core.entry":
-               case "cmi.core.total_time":
-               case "cmi.core.lesson_mode":
-               case "cmi.launch_data":
-               case "cmi.comments_from_lms":
-                   errorCode = "403";
-                   return "false";
-               break;
-               case "nav.event":
-                   if ((value == "previous") || (value == "continue")) {
-                       eval(param+'="'+value+'";');
-                       errorCode = "0";
-                       return "true";
-                   } else {
-                       erroCode = "405";
-                       return "false";
-                   }
-               break;  
-               default:
-                   errorCode = "401";  //This is more correct but may have problem with some SCOes
-                   //errorCode = "0"; // With this disable any possible SCO errors alert
-                   return "false";
-               break;
-           }
-       } else {
-           errorCode = "301";
-           return "false";
-       }
-    }
-
-    function LMSCommit (param) {
-       if (param != "") {
-           errorCode = "201";
-           return "false";
-       }
-       if (Initialized) {
-           if (<?php echo $navObj ?>cmi.document.theform) {
-               cmiform = <?php echo $navObj ?>cmi.document.forms[0];
-               cmiform.scoid.value = "<?php echo $sco->id; ?>";
-               cmiform.cmi_core_lesson_location.value = cmi.core.lesson_location;
-               cmiform.cmi_core_lesson_status.value = cmi.core.lesson_status;
-               cmiform.cmi_core_exit.value = cmi.core.exit;
-               cmiform.cmi_core_score_raw.value = cmi.core.score.raw;
-               cmiform.cmi_suspend_data.value = cmi.suspend_data;
-               cmiform.submit();
-           }
-           errorCode = "0";
-           return "true";
-       } else {
-           errorCode = "301";
-           return "false";
-       }
-    }
-    
-    function LMSFinish (param) {
-       if (param != "") {
-           errorCode = "201";
-           return "false";
-       }
-       if (!Initialized) {
-           errorCode = "301";
-           return "false";
-       } else {
-           Initialized = false;
-           errorCode = "0";
-          
-            if (nav.event != "") {
-<?php
-               if ($sco != $last) {
-?>
-               if (nav.event == 'previous') {
-                   setTimeout('top.changeSco("previous");',500);
-               } else {
-                   setTimeout('top.changeSco("continue");',500);
-               }
-<?php
-               } else {
-                   echo "exitloc = '".$CFG->wwwroot."/mod/scorm/view.php?id=".$cm->id."';\n";
-                   echo "setTimeout('top.location = exitloc;',500);\n";
-               } 
-           ?>
-           }
-           return "true";
-       }    
-    }
-    
-    function LMSGetLastError () {
-       return errorCode;
-    }
-    
-    function LMSGetErrorString (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];
-    }
-    
-    function LMSGetDiagnostic (param) {
-       return param;
-    }
-       
-    function AddTime (first, second) {
-       var sFirst = first.split(":");
-       var sSecond = second.split(":");
-       var change = 0;
-       
-       var secs = (Math.round((parseFloat(sFirst[2],10)+parseFloat(sSecond[2],10))*100))/100;  //Seconds
-       change = Math.floor(secs / 60);
-       secs = secs - (change * 60);
-       if (Math.floor(secs) < 10) secs = "0" + secs.toString();
-       
-       mins = parseInt(sFirst[1],10)+parseInt(sSecond[1],10)+change;   //Minutes
-       change = Math.floor(mins / 60);
-       mins = mins - (change * 60);
-       if (mins < 10) mins = "0" + mins.toString();
-           
-       hours = parseInt(sFirst[0],10)+parseInt(sSecond[0],10)+change;  //Hours
-       if (hours < 10) hours = "0" + hours.toString();
-       
-       return hours + ":" + mins + ":" + secs;
-    }
-    
-    function SaveTotalTime() {
-       cmi.core.total_time = AddTime(cmi.core.total_time, cmi.core.session_time);
-       //top.alert(cmi.core.total_time);
-       if (<?php echo $navObj ?>cmi.document.forms[0]) {
-           cmiform = <?php echo $navObj ?>cmi.document.forms[0];
-           cmiform.reset();
-           cmiform.scoid.value = "<?php echo $sco->id; ?>";
-           cmiform.cmi_core_total_time.value = cmi.core.total_time;
-           cmiform.submit();
-           //top.alert(cmi.core.total_time);
-       }
-    }
-    
-    this.SaveTotalTime = SaveTotalTime;
-    
-    this.LMSInitialize = LMSInitialize;
-    this.LMSGetValue = LMSGetValue;
-    this.LMSSetValue = LMSSetValue;
-    this.LMSCommit = LMSCommit;
-    this.LMSFinish = LMSFinish;
-    this.LMSGetLastError = LMSGetLastError;
-    this.LMSGetErrorString = LMSGetErrorString;
-    this.LMSGetDiagnostic = LMSGetDiagnostic;
-}
-
-var API = new SCORMapi();
index 817f296..8ba36bc 100755 (executable)
           echo "</tr>";
       }
 ?>
+<tr valign="top">
+    <td align="right"><p>scorm_windowsettings:</td>
+    <td>
+    <?php
+        unset($choices);
+        $choices[""] = get_string("no");
+        $choices["checked"] = get_string("yes");
+        choose_from_menu ($choices, "scorm_windowsettings", $CFG->scorm_windowsettings, "");
+    ?>
+    </td>
+    <td>
+    <?php print_string("windowsettings", "scorm") ?>
+    </td>
+</tr>
 <tr>
     <td colspan="3" align="center">
        <input type="submit" value="<?php print_string("savechanges") ?>" />
similarity index 74%
rename from mod/scorm/cmi.php
rename to mod/scorm/datamodel.php
index 2840d6f..1cfed79 100755 (executable)
@@ -1,7 +1,7 @@
 <?php
     require_once('../../config.php');
     require_once('lib.php');
-
+    
     optional_variable($id);    // Course Module ID, or
     optional_variable($a);     // scorm ID
 
@@ -9,11 +9,11 @@
         if (! $cm = get_record('course_modules', 'id', $id)) {
             error('Course Module ID was incorrect');
         }
-
+    
         if (! $course = get_record('course', 'id', $cm->course)) {
             error('Course is misconfigured');
         }
-
+    
         if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
             error('Course module is incorrect');
         }
     if (!empty($_POST['scoid'])) {
         //echo 'scoid: '.$_POST['scoid']."\n";
         if (!empty($_POST['cmi_core_lesson_location'])) {
-            set_field('scorm_sco_users','cmi_core_lesson_location',$_POST['cmi_core_lesson_location'],'scoid',$_POST['scoid'],'userid',$USER->id);
-            //echo 'cmi_core_lesson_location: '.$_POST['cmi_core_lesson_location']."\n";
-        }
-        if (!empty($_POST['cmi_core_lesson_status'])) {
+           set_field('scorm_sco_users','cmi_core_lesson_location',$_POST['cmi_core_lesson_location'],'scoid',$_POST['scoid'],'userid',$USER->id);
+           //echo 'cmi_core_lesson_location: '.$_POST['cmi_core_lesson_location']."\n";
+       }
+       if (!empty($_POST['cmi_core_lesson_status'])) {
             set_field('scorm_sco_users','cmi_core_lesson_status',$_POST['cmi_core_lesson_status'],'scoid',$_POST['scoid'],'userid',$USER->id);
             //echo 'cmi_core_lesson_status: '.$_POST['cmi_core_lesson_status']."\n";
         }
-        if (!empty($_POST['cmi_core_exit'])) {
+       if (!empty($_POST['cmi_core_exit'])) {
             set_field('scorm_sco_users','cmi_core_exit',$_POST['cmi_core_exit'],'scoid',$_POST['scoid'],'userid',$USER->id);
             //echo 'cmi_core_exit: '.$_POST['cmi_core_exit']."\n";
         }
-        if (!empty($_POST['cmi_core_score_raw'])) {
+       if (!empty($_POST['cmi_core_score_raw'])) {
             set_field('scorm_sco_users','cmi_core_score_raw',$_POST['cmi_core_score_raw'],'scoid',$_POST['scoid'],'userid',$USER->id);
             //echo 'cmi_core_score_raw: '.$_POST['cmi_core_score_raw']."\n";
         }
-        if (!empty($_POST['cmi_suspend_data'])) {
+       if (!empty($_POST['cmi_suspend_data'])) {
             set_field('scorm_sco_users','cmi_suspend_data',$_POST['cmi_suspend_data'],'scoid',$_POST['scoid'],'userid',$USER->id);
             //echo 'cmi_suspend_data: '.$_POST['cmi_suspend_data']."\n";
         }
    <title>cmi</title>
 </head>
 <body>
-   <form name="theform" method="POST" action="<?php echo $ME ?>?id=<?php echo $cm->id ?>">
-    <input type="hidden" name="scoid" />
-    <input type="hidden" name="cmi_core_lesson_location" />
-    <input type="hidden" name="cmi_core_lesson_status" />
-    <input type="hidden" name="cmi_core_exit" />
-    <input type="hidden" name="cmi_core_total_time"  />
-    <input type="hidden" name="cmi_core_score_raw" />
-    <input type="hidden" name="cmi_suspend_data" />
+   <form name="theform" method="POST" action="<?php echo $ME ?>?id=<?php echo $cm->id ?>"> 
+       <input type="hidden" name="scoid" />
+       <input type="hidden" name="cmi_core_lesson_location" />
+       <input type="hidden" name="cmi_core_lesson_status" />
+       <input type="hidden" name="cmi_core_exit" />
+       <input type="hidden" name="cmi_core_total_time"  />
+       <input type="hidden" name="cmi_core_score_raw" />
+       <input type="hidden" name="cmi_suspend_data" />
    </form>
 </body>
 </html>
diff --git a/mod/scorm/details.php b/mod/scorm/details.php
deleted file mode 100755 (executable)
index db3c664..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-<?php // $Id$
-
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    require_login();
-    if ($form = data_submitted($destination)) { 
-
-        if (! $course = get_record("course", "id", $form->course)) {
-            error("This course doesn't exist");
-        }
-
-        require_login($course->id);
-
-        if (!isteacher($course->id)) {
-            error("You can't modify this course!");
-        }
-
-        $strediting = get_string("validateascorm", "scorm");
-        $strname = get_string("name");
-
-        print_header_simple("$strediting", "$strediting",
-                      "$strediting");
-
-        if (!$form->name or !$form->reference or !$form->summary) {
-            error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
-        }
-    
-    //
-    // Create a temporary directory to unzip package and validate imsmanifest
-    //
-
-    $coursedir = "$CFG->dataroot/$course->id";
-    $form->reference = clean_param($form->reference, PARAM_PATH);
-    
-    if ($scormdir = make_upload_directory("$course->id/$CFG->moddata/scorm")) {
-        if ($tempdir = scorm_datadir($scormdir, $form->datadir)) {
-            copy ("$coursedir/$form->reference", $tempdir."/".basename($form->reference));
-            unzip_file($tempdir."/".basename($form->reference), $tempdir, false);
-            $result = scorm_validate($tempdir."/imsmanifest.xml");
-        } else {
-            $result = "packagedir";
-        }
-    } else {
-        $result = "datadir";
-    }
-    $errorlogs = '';
-    if (($result != "regular") && ($result != "found")) {
-        if ($CFG->scorm_validate == 'domxml') {
-            foreach ($errors as $error) {
-                $errorlogs .= get_string($error->type,"scorm",$error->data) . ".\n";
-            }
-        }
-        //
-        // Delete files and temporary directory
-        //
-        if (is_dir($tempdir))
-            scorm_delete_files($tempdir);
-        } else {
-        //
-        // Delete package file
-        //
-        unlink ($tempdir."/".basename($form->reference));
-        if ($form->mode == "update") {
-            $fp = fopen($coursedir."/".$form->reference,"r");
-            $fstat = fstat($fp);
-            fclose($fp);
-            if (get_field("scorm","timemodified","id",$form->instance) < $fstat["mtime"]) {
-                $form->launch = 0;
-            }
-        }
-    }
-    //
-    // Print validation result
-    //
-    print_simple_box_start('center');
-    echo "<table cellpadding=\"5\" align=\"center\">\n";
-    echo "    <tr><td align=\"right\" nowrap=\"nowrap\"><b>$strname:</b></td><td>$form->name</td></tr>\n";
-    echo "    <tr><td align=\"right\" nowrap=\"nowrap\"><b>".get_string("validation","scorm").":</b></td><td>".get_string($result,"scorm")."</td></tr>\n";
-    if ($errorlogs != '') {
-        $lines = round(count($errors)/4);
-        if ($lines < 5) {
-            $lines = 5;
-        }
-        echo "    <tr><td align=\"right\" nowrap=\"nowrap\"><b>".get_string("errorlogs","scorm").":</b></td><td><textarea rows=\"".$lines."\" cols=\"30\" readonly>".$errorlogs."</textarea></a></td></tr>\n";
-    }
-    if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance))) {
-        echo "    <tr><td align=\"center\" colspan=\"2\" nowrap=\"nowrap\"><b>".get_string("trackingloose","scorm")."</b></td></tr>\n";
-    }
-    echo "</table>\n";
-    if (($result == "regular") || ($result == "found")) {
-        if (empty($form->auto)) {
-            $form->auto = "";
-        }
-        if (empty($form->maxgrade)) {
-            $form->maxgrade = "";
-        }
-        if (empty($form->grademethod)) {
-            $form->grademethod = "0";
-        }
-        echo "<form name=\"theform\" method=\"post\" action=\"$form->destination\">\n";
-        
-        //$form->popup = $CFG->scorm_popup;
-        $strnewwindow     = get_string("newwindow", "scorm");
-        $strnewwindowopen = get_string("newwindowopen", "scorm");
-        foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
-            $stringname = "str$optionname";
-            $$stringname = get_string("new$optionname", "scorm");
-            $window->$optionname = "";
-            $jsoption[] = "\"$optionname\"";
-        }
-        $alljsoptions = implode(",", $jsoption);
-        
-        if ($form->instance) {     // Re-editing
-            if ($form->popup == "") {
-                $newwindow = "";   // Disable the new window
-                foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
-                    $defaultvalue = "scorm_popup$optionname";
-                    $window->$optionname = $CFG->$defaultvalue;
-                }
-            } else {
-                $newwindow = "checked";
-                $rawoptions = explode(',', $form->popup); 
-                foreach ($rawoptions as $rawoption) {
-                    $option = explode('=', trim($rawoption));
-                    if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) {
-                        $optionname = $option[0];
-                        $optionvalue = $option[1];
-                        if ($optionname == "height" or $optionname == "width") {
-                            $window->$optionname = $optionvalue;
-                        } else if ($optionvalue == 1) {
-                            $window->$optionname = "checked";
-                        }
-                    }
-                }
-            }
-        } else {
-            foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
-                $defaultvalue = "scorm_popup$optionname";
-                $window->$optionname = $CFG->$defaultvalue;
-            }
-            $newwindow = $CFG->scorm_popup;
-        }    
-?>
-    <table cellpadding="5" align="center">
-        <tr valign="top">
-            <td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
-            <td>
-            <?php
-                $options = array();
-                $options[0] = get_string("gradescoes", "scorm");
-                $options[1] = get_string("gradehighest", "scorm");
-                $options[2] = get_string("gradeaverage", "scorm");
-                choose_from_menu($SCORM_GRADE_METHOD, "grademethod", "$form->grademethod", "");
-                helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
-            ?>
-            </td>
-        </tr>
-        <tr valign="top">
-            <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
-            <td>
-            <?php
-                for ($i=100; $i>=1; $i--) {
-                    $grades[$i] = $i;
-                }
-
-                choose_from_menu($grades, "maxgrade", "$form->maxgrade", "");
-                helpbutton("maxgrade", get_string("maximumgrade"), "scorm");
-            ?>
-            </td>
-        </tr>
-        <tr valign="top">
-            <td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
-            <td>
-            <?php
-                $options = array();
-                $options[0]=get_string("no");
-                $options[1]=get_string("yes");
-                choose_from_menu ($options, "auto", $form->auto);
-            ?>
-            </td>
-        </tr>
-        <tr valign="top">
-            <td align="right" nowrap="nowrap">
-                <b><?php p($strnewwindow) ?>:</b>
-            </td>
-            <td>
-                <script type="text/javascript">
-                    var subitems = [<?php echo $alljsoptions; ?>];
-                    
-                    function autowindow() {
-                        if (document.theform.newwindow.checked) {
-                            document.theform.auto.disabled=true;
-                        } else {
-                            document.theform.auto.disabled=false;
-                        }
-                    }
-                    
-                    <?php
-                        if ($newwindow == "checked") {
-                            echo "document.theform.auto.disabled=true;\n";
-                            $newwindow = "checked='checked'";
-                        }
-                    ?>
-                </script>
-                <input name="setnewwindow" type="hidden" value="1" />
-                <input name="newwindow" type="checkbox" value="1" onclick="autowindow();return lockoptions('theform','newwindow', subitems);" <?php echo $newwindow ?> /> 
-                <?php echo $strnewwindowopen."\n"; ?>
-                <ul style='list-style-type:none;'><li>
-                <?php
-                     foreach ($window as $name => $value) {
-                         if ($name == "height" or $name == "width") {
-                             continue;
-                         }
-                         echo "\t\t<input name=\"h$name\" type=\"hidden\" value=\"0\" />\n";
-                         if ($window->$name == 'checked') {
-                             $window->$name = 'checked="checked"';
-                         }
-                         echo "\t\t<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." /> ";
-                         $stringname = "str$name";
-                         echo $$stringname."<br />\n";
-                     }
-                ?>
-
-                <input name="hwidth" type="hidden" value="0" />
-                <input name="width" type="text" size="4" value="<?php p($window->width) ?>" alt="width" /> <?php p($strwidth) ?><br />
-                <input name="hheight" type="hidden" value="0" />
-                <input name="height" type="text" size="4" value="<?php p($window->height) ?>" alt="height" /> <?php p($strheight) ?><br />
-                <?php
-                     if (!$newwindow) {
-                         echo "<script type=\"text/javascript\">\n<!--\n";
-                         echo "\tlockoptions('theform','newwindow', subitems);";
-                         echo "\n-->\n</script>";
-                     }
-                 ?>
-                 </li></ul>
-             </td>
-         </tr>
-      </table>
-      <input type="hidden" name="reference"   value="<?php p($form->reference) ?>" />
-      <input type="hidden" name="datadir" value="<?php p(substr($tempdir,strlen($scormdir))) ?>" />
-      <input type="hidden" name="summary" value="<?php p($form->summary) ?>" />
-      <input type="hidden" name="name"    value="<?php p($form->name) ?>" />
-      <input type="hidden" name="launch"  value="<?php p($form->launch) ?>" />
-      <input type="hidden" name="course"  value="<?php p($form->course) ?>" />
-      <input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
-      <input type="hidden" name="coursemodule"    value="<?php p($form->coursemodule) ?>" />
-      <input type="hidden" name="section" value="<?php p($form->section) ?>" />
-      <input type="hidden" name="module"  value="<?php p($form->module) ?>" />
-      <input type="hidden" name="modulename"  value="<?php p($form->modulename) ?>" />
-      <input type="hidden" name="instance"    value="<?php p($form->instance) ?>" />
-      <input type="hidden" name="mode"    value="<?php p($form->mode) ?>" />
-      <div align="center">
-          <input type="submit" value="<?php print_string("savechanges") ?>" />
-          <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
-      </div>
-  </form>
-<?php
-        } else {
-?>
-  <div align="center">
-      <input type="button" value="<?php print_string("continue") ?>" onclick="document.location='<?php echo $CFG->wwwroot ?>/course/view.php?id=<?php echo $course->id ?>';" />
-  </div>
-<?php
-        }
-        print_simple_box_end();
-        print_footer($course);
-    } else {
-        error("This script was called incorrectly");
-    }
-?>
index 194e6f7..13607c1 100755 (executable)
@@ -8,7 +8,7 @@
         error("Course ID is incorrect");
     }
 
-    require_course_login($course);
+    require_course_login($course->id, false, $cm);
 
     add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
 
index 813efcf..a6888ea 100755 (executable)
@@ -56,10 +56,10 @@ function scorm_add_instance($scorm) {
     $scorm->timemodified = time();
 
     # May have to add extra stuff in here #
-    global $SCORM_WINDOW_OPTIONS;
+    global $CFG,$SCORM_WINDOW_OPTIONS;
     
     $scorm->popup = '';
-    
+
     $optionlist = array();
     foreach ($SCORM_WINDOW_OPTIONS as $option) {
         if (isset($scorm->$option)) {
@@ -73,8 +73,19 @@ function scorm_add_instance($scorm) {
        $scorm->popup .= ',location=0,menubar=0,toolbar=0';
        $scorm->auto = '0';
     }
+    $id = insert_record('scorm', $scorm);
     
-    return insert_record('scorm', $scorm);
+    //
+    // Parse scorm manifest
+    //
+    if ($scorm->launch == 0) {
+       $basedir = $CFG->dataroot."/".$scorm->course;
+               $scormdir = "/moddata/scorm";
+       $scorm->launch = scorm_parse($basedir,$scormdir.$scorm->datadir."/imsmanifest.xml",$id);
+       set_field("scorm","launch",$scorm->launch,"id",$id);
+    }
+    
+    return $id;
 }
 
 
@@ -87,7 +98,7 @@ function scorm_update_instance($scorm) {
     $scorm->id = $scorm->instance;
 
     # May have to add extra stuff in here #
-    global $SCORM_WINDOW_OPTIONS;
+    global $CFG,$SCORM_WINDOW_OPTIONS;
     
     $scorm->popup = '';
     
@@ -103,7 +114,20 @@ function scorm_update_instance($scorm) {
        $scorm->popup .= ',location=0,menubar=0,toolbar=0';
        $scorm->auto = '0';
     }
-    return update_record('scorm', $scorm);
+    
+    $id = update_record('scorm', $scorm);
+    
+    //
+    // Check if scorm manifest needs to be reparsed
+    //
+    if ($scorm->launch == 0) {
+       $basedir = $CFG->dataroot."/".$scorm->course;
+               $scormdir = "/moddata/scorm";
+       $scorm->launch = scorm_parse($basedir,$scormdir.$scorm->datadir."/imsmanifest.xml",$id);
+       set_field("scorm","launch",$scorm->launch,"id",$id);
+    }
+    
+    return $id;
 }
 
 
@@ -112,7 +136,7 @@ function scorm_delete_instance($id) {
 /// this function will permanently delete the instance 
 /// and any data that depends on it.  
     
-    global $CFG;
+    require('../config.php');
 
     if (! $scorm = get_record('scorm', 'id', $id)) {
         return false;
@@ -145,8 +169,6 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
 /// $return->time = the time they did it
 /// $return->info = a short text description
 
-    $return = NULL;
-
     return $return;
 }
 
diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php
new file mode 100755 (executable)
index 0000000..29452e2
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+    require_once("../../config.php");
+    require_once("lib.php");
+
+    optional_variable($id);    // Course Module ID, or
+    optional_variable($a);     // scorm ID
+    optional_variable($scoid); // sco ID
+
+    if ($id) {
+       if (! $cm = get_record("course_modules", "id", $id)) {
+           error("Course Module ID was incorrect");
+       }
+
+       if (! $course = get_record("course", "id", $cm->course)) {
+           error("Course is misconfigured");
+       }
+
+       if (! $scorm = get_record("scorm", "id", $cm->instance)) {
+           error("Course module is incorrect");
+       }
+
+    } else {
+       if (! $scorm = get_record("scorm", "id", $a)) {
+           error("Course module is incorrect");
+       }
+       if (! $course = get_record("course", "id", $scorm->course)) {
+           error("Course is misconfigured");
+       }
+       if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
+           error("Course Module ID was incorrect");
+       }
+    }
+
+    require_login($course->id, false, $cm);
+
+    if ( $scoes_user = get_records_select("scorm_sco_users","userid = ".$USER->id." AND scormid = ".$scorm->id,"scoid ASC") ) {
+        //
+        // Already user
+        //
+       if (!empty($scoid)) {   
+           //
+           // Direct sco request
+           //
+           if ($sco = get_record("scorm_scoes","id",$scoid)) {
+               if ($sco->launch == '') {
+                   // Search for th first launchable sco 
+                   if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
+                       $sco = current($scoes);
+                       while ($sco->id < $scoid) {
+                           $sco = next($scoes);
+                       }
+                       while ($sco->launch == '') {
+                           $sco = next($scoes);
+                       }
+                   }
+               }
+           }
+       } else {
+           //
+           // Search for first incomplete sco
+           //
+           foreach ( $scoes_user as $sco_user ) {
+               if (($sco_user->cmi_core_lesson_status != "completed") && ($sco_user->cmi_core_lesson_status != "passed") && ($sco_user->cmi_core_lesson_status != "failed")) {
+                   $sco = get_record("scorm_scoes","id",$sco_user->scoid);
+                   break;
+               } else {
+                   // If review mode get the first
+                   if ($mode == "review") {
+                       $sco = get_record("scorm_scoes","id",$sco_user->scoid);
+                       break;
+                   }
+               }
+           }
+       }
+       //
+       // If no sco was found get the first of SCORM package
+       //
+       if (!isset($sco)) {
+           $scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' order by id ASC");
+           $sco = each($scoes);
+       }
+    } else {
+        //
+        // A new user
+        //
+       if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
+           //
+           // Create user scoes records
+           //
+           foreach ($scoes as $sco) {
+               if (($sco->launch != "") && ($sco->type != "sca") && ($sco->type != "asset")){
+                   if (!isset($first)) {
+                       $first = $sco;
+                   }
+                   $sco_user->userid = $USER->id;
+                   $sco_user->scoid = $sco->id;
+                   $sco_user->scormid = $scorm->id;
+                   $element = "cmi_core_lesson_status";
+                   $sco_user->$element = "not attempted";
+                   $ident = insert_record("scorm_sco_users",$sco_user);
+               }
+           }
+           if (isset($first)) {
+               $sco = $first;
+           }
+           if (!empty($scoid)) {
+               if ($sco = get_record("scorm_scoes","id",$scoid)) {
+                   unset($first);
+               }
+           }
+       }
+    }
+    //
+    // Forge SCO URL
+    //
+    if (scorm_external_link($sco->launch)) {
+       $result = $sco->launch;
+    } else {
+       if ($CFG->slasharguments) {
+           $result = "$CFG->wwwroot/file.php/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch";
+       } else {
+           $result = "$CFG->wwwroot/file.php?file=/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch";
+       }
+    }
+?>
+<html>
+    <head>
+       <title>LoadSCO</title>
+    </head>
+    <body>
+       <script language="javascript">
+<?php  
+    if ($scorm->popup == "") { 
+       echo "\t    document.location=\"$result\";\n";
+    } else {
+        $popuplocation = '';
+        if (isset($_COOKIE["SCORMpopup"])) {
+            $popuplocation = $_COOKIE["SCORMpopup"];
+        }
+       echo "\t    top.main = window.open('$result','main','$scorm->popup$popuplocation');\n";
+    }
+?>
+       </script>
+    </body>
+</html>
\ No newline at end of file
index a09c62a..23f9b1e 100755 (executable)
 <?php
+    require_once("$CFG->dirroot/mod/scorm/lib.php");
     if (empty($form->name)) {
-  $form->name = "";
+       $form->name = "";
     }
     if (empty($form->reference)) {
-  $form->reference = "";
+       $form->reference = "";
     }
     if (empty($form->summary)) {
-  $form->summary = "";
+       $form->summary = "";
     }
     if (empty($form->launch)) {
-  $form->launch = "";
+       $form->launch = "";
+    }
+    if (empty($form->auto)) {
+        $form->auto = "";
+    }
+    if (empty($form->datadir)) {
+        $form->datadir = "";
+    }
+    if (empty($form->popup)) {
+        $form->popup = "";
+    }
+    if (empty($form->maxgrade)) {
+        $form->maxgrade = "";
+    }
+    if (empty($form->grademethod)) {
+        $form->grademethod = "0";
+    }
+    $scormid ='';
+    if (!empty($form->instance)) {
+        $scormid = '&instance='.$form->instance;
+    }
+    $datadir ='';
+    if (!empty($form->datadir)) {
+        $datadir = '&datadir='.$form->datadir;
     }
 ?>
 
+<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" >
+</script>
+<script type="text/javascript">
+    function validate_scorm(theform,filename) {
+       //alert(filename);
+        var myRequest = NewHttpReq();
+       result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php?id=<?php p($form->course) ?>&reference="+filename+"<?php p($scormid.$datadir) ?>");
+       //alert(result);
+       results = result.split('\n');
+       if ((results[0] == "found") || (results[0] == "regular")) {
+           theform.launch.value = results[1];
+           theform.datadir.value = results[2];
+       } else {
+           result = 'Result: '+ results[0] + '\n';
+           result.concat('Errorlog:\n',results[3]);
+           alert(result);
+           exit;
+       }
+       return false;
+    }
+</script>
 
-<form name="form" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/details.php">
+<form name="form" method="post" action="mod.php" onsubmit="validate_scorm(document.form,document.form.reference.value);">
     <table cellpadding="5">
-  <tr valign="top">
-      <td align="right"><b><?php print_string("name") ?>:</b></td>
-      <td>
-          <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
-      </td>
-  </tr>
+       <tr valign="top">
+           <td align="right"><b><?php print_string("name") ?>:</b></td>
+           <td>
+               <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
+           </td>
+       </tr>
 <?php 
     $strfilename = get_string("coursepacket", "scorm");
     $strchooseafile = get_string("chooseapacket", "scorm");
 ?>
-  <tr valign="top">
-      <td align="right" nowrap="nowrap">
-     <b><?php echo $strfilename?>:</b>
-      </td>
-      <td>
-     <?php
-         echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
-         button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference", 
-               "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
-     ?>
-      </td>
-  </tr>
-  <tr valign="top">
-      <td align="right"><b><?php print_string("summary") ?>:</b><br />
-    <font size="1">
-    <?php
-        helpbutton("summary", get_string("summary"), "scorm", true, true);
-        echo "<br />";
-        helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
-        echo "<br />";
-        helpbutton("text", get_string("helptext"), "moodle", true, true);
-         ?>
-           </font>
-      </td>
-      <td>
-        <?php print_textarea($usehtmleditor, 20, 50, 680, 400, "summary", $form->summary); ?>
-      </td>
-  </tr>
-  <?php print_visible_setting($form); ?>
+       <tr valign="top">
+           <td align="right"><b><?php print_string("summary") ?>:</b><br />
+               <font size="1">
+               <?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
+               </font>
+           </td>
+           <td>
+        <?php print_textarea($usehtmleditor, 10, 50, 680, 400, "summary", $form->summary); ?>
+           </td>
+       </tr>
+       <tr valign="top">
+           <td align="right" nowrap="nowrap">
+               <b><?php echo $strfilename?>:</b>
+           </td>
+           <td>
+               <?php
+                   echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
+                   button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference", 
+                                           "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
+                   helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
+               ?>
+           </td>
+       </tr>
+<?php   
+        $strnewwindow     = get_string("newwindow", "scorm");
+        $strnewwindowopen = get_string("newwindowopen", "scorm");
+        foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
+            $stringname = "str$optionname";
+            $$stringname = get_string("new$optionname", "scorm");
+            $window->$optionname = "";
+            $jsoption[] = "\"$optionname\"";
+        }
+        $alljsoptions = implode(",", $jsoption);
+        
+        if ($form->instance) {     // Re-editing
+            if ($form->popup == "") {
+                $newwindow = "";   // Disable the new window
+                foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
+                    $defaultvalue = "scorm_popup$optionname";
+                    $window->$optionname = $CFG->$defaultvalue;
+                }
+            } else {
+                $newwindow = "checked";
+                $rawoptions = explode(',', $form->popup); 
+                foreach ($rawoptions as $rawoption) {
+                    $option = explode('=', trim($rawoption));
+                    if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) {
+                        $optionname = $option[0];
+                        $optionvalue = $option[1];
+                        if ($optionname == "height" or $optionname == "width") {
+                            $window->$optionname = $optionvalue;
+                        } else if ($optionvalue == 1) {
+                            $window->$optionname = "checked";
+                        }
+                    }
+                }
+            }
+        } else {
+            foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
+                $defaultvalue = "scorm_popup$optionname";
+                $window->$optionname = $CFG->$defaultvalue;
+            }
+            $newwindow = $CFG->scorm_popup;
+        }    
+?>
+        <tr valign="top">
+            <td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
+            <td>
+            <?php
+                $options = array();
+                $options[0] = get_string("gradescoes", "scorm");
+                $options[1] = get_string("gradehighest", "scorm");
+                $options[2] = get_string("gradeaverage", "scorm");
+                choose_from_menu($SCORM_GRADE_METHOD, "grademethod", "$form->grademethod", "");
+                helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
+            ?>
+            </td>
+        </tr>
+        <tr valign="top">
+            <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
+            <td>
+            <?php
+                for ($i=100; $i>=1; $i--) {
+                    $grades[$i] = $i;
+                }
+
+                choose_from_menu($grades, "maxgrade", "$form->maxgrade", "");
+                helpbutton("maxgrade", get_string("maximumgrade"), "scorm");
+            ?>
+            </td>
+        </tr>    
+        <tr>
+           <td align="right"><b><?php print_string("display", "scorm") ?>:</b></td>
+           <td>
+               <input type="button" value="hide settings" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
+               <input type="hidden" name="windowsettingspref" id="windowsettingspref" 
+                 value="<?php echo get_user_preferences('windowsettingspref', $CFG->scorm_windowsettings); ?>" />
+               <?php helpbutton("window", get_string("display", "scorm"), "scorm", true) ?>
+           </td>
+       </tr>
     </table>
-    <input type="hidden" name="course"  value="<?php p($form->course) ?>" />
-    <input type="hidden" name="sesskey"  value="<?php p($form->sesskey) ?>" />
-    <input type="hidden" name="coursemodule"  value="<?php p($form->coursemodule) ?>" />
-    <input type="hidden" name="datadir"  value="<?php p($form->datadir) ?>" />
-    <input type="hidden" name="launch"  value="<?php p($form->launch) ?>" />
-    <input type="hidden" name="popup"  value="<?php p($form->popup) ?>" />
-    <input type="hidden" name="auto"  value="<?php p($form->auto) ?>" />
-    <input type="hidden" name="maxgrade"  value="<?php p($form->maxgrade) ?>" />
-    <input type="hidden" name="grademethod"  value="<?php p($form->grademethod) ?>" />
-    <input type="hidden" name="section"  value="<?php p($form->section) ?>" />
-    <input type="hidden" name="module"  value="<?php p($form->module) ?>" />
-    <input type="hidden" name="modulename"  value="<?php p($form->modulename) ?>" />
-    <input type="hidden" name="instance"  value="<?php p($form->instance) ?>" />
-    <input type="hidden" name="mode"    value="<?php p($form->mode) ?>" />
-    <input type="hidden" name="destination"  value="<?php echo $ME ?>" />
+    <script type="text/javascript">
+        var subitems = [<?php echo $alljsoptions; ?>];
+                    
+        function autowindow(set) {
+            divobj = document.getElementById('autocontinue');
+            if (document.form.newwindow.checked) {
+                divobj.style.display = 'none';
+            } else {
+                divobj.style.display = 'block';
+            }
+        }
+                  
+       function showhide (id, set) {
+            divobj = document.getElementById(id);
+            butobj = document.getElementById(id+'button');
+            prefobj = document.getElementById(id+'pref');
+            if (set == true) {
+               if (prefobj.value == '1') {
+                   divobj.style.display = 'block';
+                   butobj.value = '<?php print_string("hidesettings") ?>';
+               } else {
+                   divobj.style.display = 'none';
+                    butobj.value = '<?php print_string("showsettings") ?>...';
+               }
+            } else {
+               if (prefobj.value == '1') {
+                    divobj.style.display = 'none';
+                    butobj.value = '<?php print_string("showsettings") ?>...';
+                    prefobj.value = '0';
+               } else {
+                    divobj.style.display = 'block';
+                    butobj.value = '<?php print_string("hidesettings") ?>';
+                    prefobj.value = '1';
+               }
+            }
+       }
+    </script>
+ <div id="windowsettings" align="center">
+    <table>
+        <tr valign="top">
+            <td align="right" nowrap="nowrap">
+                <b><?php p($strnewwindow) ?>:</b>
+            </td>
+            <td>
+                <input name="setnewwindow" type="hidden" value="1" />
+                <input name="newwindow" type="checkbox" value="1" onclick="autowindow();return lockoptions('form','newwindow', subitems);" <?php echo $newwindow ?> /> 
+                <?php echo $strnewwindowopen."\n"; ?>
+                <ul style='list-style-type:none;'><li>
+                <?php
+                     foreach ($window as $name => $value) {
+                         if ($name == "height" or $name == "width") {
+                             continue;
+                         }
+                         echo "\t\t<input name=\"h$name\" type=\"hidden\" value=\"0\" />\n";
+                         if ($window->$name == 'checked') {
+                             $window->$name = 'checked="checked"';
+                         }
+                         echo "\t\t<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." /> ";
+                         $stringname = "str$name";
+                         echo $$stringname."<br />\n";
+                     }
+                ?>
+
+                <input name="hwidth" type="hidden" value="0" />
+                <input name="width" type="text" size="4" value="<?php p($window->width) ?>" alt="width" /> <?php p($strwidth) ?><br />
+                <input name="hheight" type="hidden" value="0" />
+                <input name="height" type="text" size="4" value="<?php p($window->height) ?>" alt="height" /> <?php p($strheight) ?><br />
+                <?php
+                     if (!$newwindow) {
+                         echo "<script type=\"text/javascript\">\n<!--\n";
+                         echo "\tlockoptions('form','newwindow', subitems);";
+                         echo "\n-->\n</script>";
+                     }
+                 ?>
+                 </li></ul>
+             </td>
+         </tr>
+      </table>
+      <div id="autocontinue">
+       <table>
+            <tr>
+            <td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
+               <td>
+               <?php
+                $options = array();
+                $options[0]=get_string("no");
+                $options[1]=get_string("yes");
+                choose_from_menu ($options, "auto", $form->auto);
+                helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
+               ?>
+               </td>
+            </tr>
+       </table>
+     </div>
+  </div>
+    <script type="text/javascript">
+    <?php
+        if ($newwindow == "checked") {
+            echo "autowindow();\n";
+            echo "showhide('windowsettings',false);\n";
+            $newwindow = "checked='checked'";
+        } else {
+            echo "showhide('windowsettings',true);\n";
+        }
+    ?>
+    </script>
+    <input type="hidden" name="datadir"        value="<?php p($form->datadir) ?>" />
+    <input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
+    <input type="hidden" name="popup"  value="<?php p($form->popup) ?>" />
+    <input type="hidden" name="auto"   value="<?php p($form->auto) ?>" />
+    <input type="hidden" name="maxgrade"       value="<?php p($form->maxgrade) ?>" />
+    <input type="hidden" name="grademethod"    value="<?php p($form->grademethod) ?>" />
+    
+    <input type="hidden" name="course" value="<?php p($form->course) ?>" />
+    <input type="hidden" name="sesskey"        value="<?php p($form->sesskey) ?>" />
+    <input type="hidden" name="coursemodule"   value="<?php p($form->coursemodule) ?>" />
+    <input type="hidden" name="section"        value="<?php p($form->section) ?>" />
+    <input type="hidden" name="module" value="<?php p($form->module) ?>" />
+    <input type="hidden" name="modulename"     value="<?php p($form->modulename) ?>" />
+    <input type="hidden" name="instance"       value="<?php p($form->instance) ?>" />
+    <input type="hidden" name="mode"           value="<?php p($form->mode) ?>" />
     <center>
-  <input type="submit" value="<?php print_string("continue") ?>" />
+       <input type="submit" value="<?php print_string("savechanges") ?>" />
+       <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
     </center>
 </form>
index c46d7c9..d96f98a 100755 (executable)
@@ -1,4 +1,4 @@
-<?php  // $Id$
+<?PHP  // $Id$
 
 /// This page prints a particular instance of scorm
 /// (Replace scorm with the name of your module)
         if (! $cm = get_record("course_modules", "id", $id)) {
             error("Course Module ID was incorrect");
         }
-
+    
         if (! $course = get_record("course", "id", $cm->course)) {
             error("Course is misconfigured");
         }
-
+    
         if (! $scorm = get_record("scorm", "id", $cm->instance)) {
             error("Course module is incorrect");
         }
 
     require_login($course->id, false, $cm);
 
-
+    
     $strscorms = get_string("modulenameplural", "scorm");
     $strscorm  = get_string("modulename", "scorm");
-
+       
     if ($course->category) {
         $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
                        <a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
     $pagetitle = strip_tags("$course->shortname: $scorm->name");
 
     if (!$cm->visible and !isteacher($course->id)) {
-        print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true,
+        print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true, 
                      update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
         notice(get_string("activityiscurrentlyhidden"));
     }
-
-    if (!empty($_POST["scoid"]))
-            $scoid = "&amp;scoid=".$_POST["scoid"];
-    if (!empty($_POST['currentorg'])) {
-    $currentorg = $_POST['currentorg'];
-    }
-    if (($scorm->popup != "") && (!empty($_POST["mode"])))
-        $mode = $_POST["mode"];
-    if (($scorm->popup == "") && (!empty($_GET["mode"])))
-        $mode = $_GET["mode"];
-
-    if (($frameset == "top") || ($scorm->popup != "")) {
-        add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
+    
     //
-    // Print the page header
+    // Checkin script parameters
     //
-    $bodyscripts = "";
-    if ($scorm->popup != "") {
-        $bodyscripts = "onload='SCOInitialize();' onunload='SCOFinish(); closeMain();'";
+    $mode = '';
+    $scoid='';
+    $currentorg='';
+    $modestring = '';
+    $scoidstring = '';
+    $currentorgstring = '';
+    if (($scorm->popup == "") && ($frameset == "top")) {
+       if (!empty($_GET["mode"])) {
+           $mode = $_GET["mode"];
+           $modestring = '&mode='.$mode;
+       }
+       if (!empty($_GET["scoid"])) {
+           $scoid = $_GET["scoid"];
+           $scoidstring = '&scoid='.$scoid;
+       }
+       if (!empty($_GET['currentorg'])) {
+           $currentorg = $_GET['currentorg'];
+           $currentorgstring = '&currentorg='.$currentorg;
+       }
+    } else {
+       if (!empty($_POST["mode"])) {
+           $mode = $_POST["mode"];
+           $modestring = '&mode='.$mode;
+       }
+       if (!empty($_POST["scoid"])) {
+           $scoid = $_POST["scoid"];
+           $scoidstring = '&scoid='.$scoid;
+       }
+       if (!empty($_POST['currentorg'])) {
+           $currentorg = $_POST['currentorg'];
+           $currentorgstring = '&currentorg='.$currentorg;
+       }
     }
-        print_header($pagetitle, "$course->fullname",
-        "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
-        "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top'),"",$bodyscripts);
-
-        echo "<table width=\"100%\">\n    <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td>\n";
-        if ($mode == "browse")
-        echo "<td align=\"right\" width=\"10%\" nowrap=\"nowrap\">".get_string("browsemode","scorm")."</td>\n";
-        echo "     </tr>\n</table>\n";
-
-        if ($scorm->popup != "") {
-            echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&amp;mode=".$mode.$scoid."\"></script>\n";
-        $currentSCO = "";
-            if (!empty($_POST['scoid']))
-                $currentSCO = $_POST['scoid'];
+    
+    if (($frameset == "top") || ($scorm->popup != "")) {
+       add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
+       //
+       // Print the page header
+       //
+       $bodyscripts = "";
+       if ($scorm->popup != "") {
+           $bodyscripts = "onUnload='SCOFinish(); closeMain();' ";
+       }
+       //print_header($pagetitle, "$course->fullname",
+       //      "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">$scorm->name</a>",
+       //      "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top'),"",$bodyscripts);
+       print_header($pagetitle, "$course->fullname",
+               "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">$scorm->name</a>",
+               "", "", true, update_module_button($cm->id, $course->id, $strscorm), "", "", $bodyscripts);
+       echo "<table width=\"100%\">\n    <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td>\n";
+       if ($mode == "browse")
+           echo "<td align=\"right\" width=\"10%\" nowrap>".get_string("browsemode","scorm")."</td>\n";
+       echo "     </tr>\n</table>\n";
+       
+       if ($scorm->popup != "") {
+           echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"request.js\"></script>\n";
+           echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"api.php?id=$cm->id\"></script>\n";
         ?>
             <br />
-            <script language="Javascript" type="text/javascript">
+            <script language="Javascript">
             <!--
                 function playSCO(scoid) {
-                    document.navform.scoid.value=scoid;
-                    document.navform.submit();
-                }
-
-                function expandCollide(which,list) {
-                var nn=document.ids?true:false
-            var w3c=document.getElementById?true:false
-            var beg=nn?"document.ids.":w3c?"document.getElementById('":"document.all.";
-            var mid=w3c?"').style":".style";
-
-                if (eval(beg+list+mid+".display") != "none") {
-                which.src = "pix/plus.gif";
-                eval(beg+list+mid+".display='none';");
-                } else {
-                which.src = "pix/minus.gif";
-                eval(beg+list+mid+".display='block';");
-                }
-
-            }
+                   document.navform.scoid.value=scoid;
+                   document.navform.submit();
+               }
+               
+               function expandCollide(which,list) {
+                   var nn=document.ids?true:false
+                   var w3c=document.getElementById?true:false
+                   var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
+                   var mid=w3c?").style":".style";
+       
+                   if (eval(beg+list+mid+".display") != "none") {
+                       which.src = "pix/plus.gif";
+                       eval(beg+list+mid+".display='none';");
+                   } else {
+                       which.src = "pix/minus.gif";
+                       eval(beg+list+mid+".display='block';");
+                   }
+       
+               }
             -->
             </script>
+            <style type="text/css">
+                .scormlist { list-style-type:none; }
+            </style>
         <?php
-            $liststyle = "style=\"list-style-type:none;\"";
-            print_simple_box_start("center");
-            echo "<table>\n";
-            echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
-            echo "  <tr><td nowrap=\"nowrap\">\n<ul $liststyle>\n";
-            $incomplete = false;
-            if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
-            $level=0;
-            $sublist=0;
-            $parents[$level]="/";
-            foreach ($scoes as $sco) {
-                if ($parents[$level]!=$sco->parent) {
-                if ($level>0 && $parents[$level-1]==$sco->parent) {
-                    echo "  </ul></li>\n";
-                    $level--;
-                } else {
-                    $i = $level;
-                    $closelist = "";
-                    while (($i > 0) && ($parents[$level] != $sco->parent)) {
-                        $closelist .= "  </ul></li>\n";
-                        $i--;
-                    }
-                    if (($i == 0) && ($sco->parent != $currentorg)) {
-                        echo "  <li><ul id='s".$sublist."' $liststyle>\n";
-                        $level++;
-                    } else {
-                        echo $closelist;
-                        $level = $i;
-                    }
-                    $parents[$level]=$sco->parent;
-                }
-                }
-                echo "    <li>\n";
-                $nextsco = next($scoes);
-                if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
-                $sublist++;
-                echo "      <img src=\"pix/minus.gif\" onclick='expandCollide(this,\"s".$sublist."\");' alt=\"-\" title=\"".get_string('collide','scorm')."\" />\n";
-                } else {
-                echo "      <img src=\"pix/spacer.gif\" alt=\" \" />\n";
-                }
-
-                if ($sco->launch) {
-                    $startbold = '';
-                    $endbold = '';
-                    if ($sco->id == $currentSCO) {
-                    $startbold = '-&gt; <b>';
-                    $endbold = '</b> &lt;-';
-                    }
-                    if (($currentSCO == "") && ($mode != "normal")) {
-                        $currentSCO = $sco->id;
-                $startbold = '-&gt; <b>';
-                    $endbold = '</b> &gt;-';
-                    }
-                    $score = "";
-                if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
-                    if ( $sco_user->cmi_core_lesson_status == "") {
-                        $sco_user->cmi_core_lesson_status = "not attempted";
-                        }
-                    echo "      <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
-                if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
-                    if ($currentSCO == "") {
-                    $incomplete = true;
-                    $currentSCO = $sco->id;
-                    $startbold = '-> <b>';
-                            $endbold = '</b> <-';
-                }
-                }
-                if ($sco_user->cmi_core_score_raw > 0) {
-                        $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
-                }
-                } else {
-                    if ($sco->type == 'sco') {
-                    echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\" />";
-                    $incomplete = true;
-                    } else {
-                    echo "      <img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" title=\"".get_string("asset","scorm")."\" />";
-                    }
-                }
-                echo "      &nbsp;$startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a> $score$endbold\n    </li>\n";
-                } else {
-            echo "      &nbsp;$sco->title\n    </li>\n";
-            }
-        }
-        for ($i=0;$i<$level;$i++){
-            echo "  </ul></li>\n";
-        }
-        }
-        echo "</ul></td></tr>\n";
-            echo "</table>\n";
-            print_simple_box_end();
-
-        }
-
-        echo "<table width=\"100%\">\n    <tr>\n";
-        echo "          <td align=\"center\" nowrap=\"nowrap\">
-             <iframe name=\"cmi\" width=\"1\" height=\"1\" src=\"cmi.php?id=$cm->id\" style=\"visibility: hidden\"></iframe>
-             <form name=\"navform\" method=\"post\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
-                <input name=\"scoid\" type=\"hidden\" />
-            <input name=\"currentorg\" type=\"hidden\" value=\"$currentorg\" />
-                <input name=\"mode\" type=\"hidden\" value=\"".$mode."\" />
-                <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onclick=\"top.changeSco('previous');\" />&nbsp;\n";
-
-    if ($scorm->popup == "") {
-        $currentorg = '';
-        if (isset($_GET['currentorg'])) {
-        $currentorg = $_GET['currentorg'];
+            print_simple_box_start("CENTER");
+           echo "<table>\n";
+           echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
+           echo "  <tr><td nowrap>\n<ul class=\"scormlist\">\n";
+           $incomplete = false;
+           if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
+               $level=0;
+               $sublist=0;
+               $parents[$level]="/";
+               foreach ($scoes as $sco) {
+                   if ($parents[$level]!=$sco->parent) {
+                       if ($level>0 && $parents[$level-1]==$sco->parent) {
+                           echo "  </ul></li>\n";
+                           $level--;
+                       } else {
+                           $i = $level;
+                           $closelist = "";
+                           while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                               $closelist .= "  </ul></li>\n";
+                               $i--;
+                           }
+                           if (($i == 0) && ($sco->parent != $currentorg)) {
+                               echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
+                               $level++;
+                           } else {
+                               echo $closelist;
+                               $level = $i;
+                           }
+                           $parents[$level]=$sco->parent;
+                       }
+                   }
+                   echo "    <li>\n";
+                   $nextsco = next($scoes);
+                   if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
+                       $sublist++;
+                       echo "      <img src=\"pix/minus.gif\" onClick='expandCollide(this,".$sublist.");'/>\n";
+                   } else {
+                       echo "      <img src=\"pix/spacer.gif\" />\n";
+                   }
+                   
+                   if ($sco->launch) {
+                       $startbold = '';
+                       $endbold = '';
+                       if ($sco->id == $scoid) {
+                           $startbold = '-> <b>';
+                           $endbold = '</b> <-';
+                       }
+                       if (($scoid == "") && ($mode != "normal")) {
+                           $scoid = $sco->id;
+                           $startbold = '-> <b>';
+                           $endbold = '</b> <-';
+                       }
+                       $score = "";
+                       if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
+                           if ( $sco_user->cmi_core_lesson_status == "") {
+                               $sco_user->cmi_core_lesson_status = "not attempted";
+                           }
+                           echo "      <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
+                           if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
+                               if ($scoid == "") {
+                                   $incomplete = true;
+                                   $scoid = $sco->id;
+                                   $startbold = '-> <b>';
+                                   $endbold = '</b> <-';
+                               }
+                           }
+                           if ($sco_user->cmi_core_score_raw > 0) {
+                               $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
+                           }
+                       } else {
+                           if ($sco->type == 'sco') {
+                               echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
+                               $incomplete = true;
+                           } else {
+                               echo "      <img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" />";
+                           }
+                       }
+                       echo "      &nbsp;$startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a> $score$endbold\n    </li>\n";
+                   } else {
+                       echo "      &nbsp;$sco->title\n    </li>\n";
+                   }
+               }
+               for ($i=0;$i<$level;$i++){
+                   echo "  </ul></li>\n";
+               }
+           }
+           echo "</ul></td></tr>\n";
+           echo "</table>\n";
+           print_simple_box_end();
+           
         }
-        if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
-                $level=0;
-                $parents[$level]="/";
-                foreach ($scoes as $sco) {
-                if ($parents[$level]!=$sco->parent) {
-                if ($level>0 && $parents[$level-1]==$sco->parent) {
-                    $level--;
-                } else {
-                    $i = $level;
-                    while (($i > 0) && ($parents[$level] != $sco->parent)) {
-                        $i--;
-                    }
-                    if (($i == 0) && ($sco->parent != $currentorg)) {
-                        $level++;
-                    } else {
-                        $level = $i;
-                    }
-                    $parents[$level]=$sco->parent;
-                }
-                }
-                $indenting = "";
-                for ($i=0;$i<$level;$i++) {
-                    $indenting .= "-";
-                }
-                $options[$sco->id] = $indenting."&gt; ".$sco->title;
-            }
-        }
-        choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
-    }
-    echo "      &nbsp;<input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onclick=\"top.changeSco('continue')\" />\n";
-    echo "       </form>
-        </td>\n";
-
-        echo "</tr>\n</table>\n";
-    if ($scorm->popup == "") {
-        echo "</body>\n</html>\n";
-    } else {
-        print_footer($course);
-    }
+           
+       echo "<table width=\"100%\">\n    <tr>\n";
+       echo "          <td align=\"center\" nowrap>
+                    <!--<iframe name=\"cmi\" width=\"1\" height=\"1\" src=\"cmi.php?id=$cm->id\" style=\"visibility: hidden\"></iframe> -->
+                    <form name=\"navform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
+                       <input name=\"scoid\" type=\"hidden\" />
+                       <input name=\"currentorg\" type=\"hidden\" value=\"$currentorg\" />
+                       <input name=\"mode\" type=\"hidden\" value=\"".$mode."\" />
+                       <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('previous');\" />&nbsp;\n";
+                       
+       if ($scorm->popup == "") {
+           if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
+               $level=0;                       
+               $parents[$level]="/";
+               foreach ($scoes as $sco) {
+                   if ($parents[$level]!=$sco->parent) {
+                       if ($level>0 && $parents[$level-1]==$sco->parent) {
+                           $level--;
+                       } else {
+                           $i = $level;
+                           while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                               $i--;
+                           }
+                           if (($i == 0) && ($sco->parent != $currentorg)) {
+                               $level++;
+                           } else {
+                               $level = $i;
+                           }
+                           $parents[$level]=$sco->parent;
+                       }
+                   }
+                   $indenting = "";
+                   for ($i=0;$i<$level;$i++) {
+                       $indenting .= "-";
+                   }
+                   $options[$sco->id] = $indenting."&gt; ".$sco->title;
+               }
+           }
+           choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
+       }
+       echo "          &nbsp;<input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('continue')\" />\n";
+       echo "       </form>
+               </td>\n";
+       
+       echo "</tr>\n</table>\n";
+       if ($scorm->popup == "") {
+           echo "</body>\n</html>\n";
+       } else {
+           print_footer($course);
+       }
     } else {
         if ($scorm->popup == "") {
-            //
-            // Frameset
-            //
-            echo "<html>\n";
+           // 
+           // Frameset
+           //
+           echo "<html>\n";
             echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
-            echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&amp;mode=".$mode.$scoid."\"></script>\n";
-        echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"SCOFinish();\">\n";
-            echo "\t    <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id&amp;mode=".$mode.'&amp;currentorg='.$currentorg."&amp;frameset=top\">\n";
-            echo "\t    <frame name=\"main\" src=\"\">\n";
+            echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"request.js\"></script>\n";
+            echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"api.php?id=$cm->id\"></script>\n";
+           echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"SCOFinish();\">\n";
+            echo "\t    <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id".$modestring.$currentorgstring."&frameset=top\">\n";
+            echo "\t    <frame name=\"main\" src=\"loadSCO.php?id=$cm->id$scoidstring\">\n";
             echo "</frameset>\n";
             echo "</html>\n";
         }
index 7b32c74..973b16d 100755 (executable)
@@ -32,7 +32,7 @@
         }
     }
 
-    require_login($course->id, false);
+    require_login($course->id, false, $cm);
 
     if (!isteacher($course->id)) {
         error("You are not allowed to use this script");
diff --git a/mod/scorm/request.js b/mod/scorm/request.js
new file mode 100644 (file)
index 0000000..eac3951
--- /dev/null
@@ -0,0 +1,30 @@
+function NewHttpReq() {
+    var httpReq = false;
+    if (typeof XMLHttpRequest!='undefined') {
+        httpReq = new XMLHttpRequest();
+    } else {
+        try {
+           httpReq = new ActiveXObject("Msxml2.XMLHTTP.4.0");
+        } catch (e) {
+           try {
+               httpReq = new ActiveXObject("Msxml2.XMLHTTP");
+           } catch (ee) {
+               try {
+                   httpReq = new ActiveXObject("Microsoft.XMLHTTP");
+               } catch (eee) {
+                   httpReq = false;
+               }
+           }
+       }
+    }
+    return httpReq;
+}
+
+function DoRequest(httpReq,url) {
+    //
+    // httpReq.open (Method("get","post"), URL(string), Asyncronous(true,false))
+    //
+    httpReq.open("get", url,false);
+    httpReq.send(null);
+    return httpReq.responseText;
+}
\ No newline at end of file
diff --git a/mod/scorm/scormAPI.php b/mod/scorm/scormAPI.php
deleted file mode 100755 (executable)
index f9306f8..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-<?php
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    optional_variable($id);    // Course Module ID, or
-    optional_variable($a);     // scorm ID
-    optional_variable($scoid); // sco ID
-    optional_variable($mode);
-
-    if ($id) {
-    if (! $cm = get_record("course_modules", "id", $id)) {
-        error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
-    }
-
-    if (! $scorm = get_record("scorm", "id", $cm->instance)) {
-        error("Course module is incorrect");
-    }
-
-    } else {
-    if (! $scorm = get_record("scorm", "id", $a)) {
-        error("Course module is incorrect");
-    }
-    if (! $course = get_record("course", "id", $scorm->course)) {
-        error("Course is misconfigured");
-    }
-    if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
-        error("Course Module ID was incorrect");
-    }
-    }
-
-    require_login($course->id, false, $cm);
-
-    if ( $scoes_user = get_records_select("scorm_sco_users","userid = ".$USER->id." AND scormid = ".$scorm->id,"scoid ASC") ) {
-        //
-        // Already user
-        //
-    if (!empty($scoid)) {
-        // Direct sco request
-        //$sco = get_record("scorm_scoes","id",$scoid);
-        if ($sco = get_record("scorm_scoes","id",$scoid)) {
-            if ($sco->launch == '') {
-                // Search for th first launchable sco
-                if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
-                    $sco = current($scoes);
-                    while ($sco->id < $scoid) {
-                        $sco = next($scoes);
-                    }
-                    while ($sco->launch == '') {
-                        $sco = next($scoes);
-                    }
-                }
-            }
-        }
-    } else {
-        // Search for first incomplete sco
-        foreach ( $scoes_user as $sco_user ) {
-        if (($sco_user->cmi_core_lesson_status != "completed") && ($sco_user->cmi_core_lesson_status != "passed") && ($sco_user->cmi_core_lesson_status != "failed")) {
-            $sco = get_record("scorm_scoes","id",$sco_user->scoid);
-            break;
-        } else {
-            // If review mode get the first
-            if ($mode == "review") {
-            $sco = get_record("scorm_scoes","id",$sco_user->scoid);
-            break;
-            }
-        }
-        }
-    }
-    if (!isset($sco)) {  // If no sco was found get the first of SCORM package
-        $scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' order by id ASC");
-        $sco = each($scoes);
-    }
-    } else {
-        //
-        // A new user
-        //
-    if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) {
-        //
-        // Create user scoes records
-        //
-        foreach ($scoes as $sco) {
-        if (($sco->launch != "") && ($sco->type != "sca") && ($sco->type != "asset")){
-            if (!isset($first)) {
-            $first = $sco;
-            }
-            $sco_user->userid = $USER->id;
-            $sco_user->scoid = $sco->id;
-            $sco_user->scormid = $scorm->id;
-            $element = "cmi_core_lesson_status";
-            $sco_user->$element = "not attempted";
-            $ident = insert_record("scorm_sco_users",$sco_user);
-        }
-        }
-        if (isset($first)) {
-            $sco = $first;
-        }
-        if (!empty($scoid)) {
-        if ($sco = get_record("scorm_scoes","id",$scoid)) {
-            unset($first);
-        }
-        }
-    }
-    }
-    //
-    // Get first, last, prev and next scoes
-    //
-    $scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC");
-    $min = 0;
-    $max = 0;
-    $prevsco = 0;
-    $nextsco = 0;
-    foreach ($scoes as $fsco) {
-    if ($fsco->launch != "") {
-        if (!$min || ($min > $fsco->id))
-        $min = $fsco->id;
-        if (!$max || ($max < $fsco->id))
-        $max = $fsco->id;
-        if ((!$prevsco) || ($sco->id > $fsco->id)) {
-        $prevsco = $fsco->id;
-        }
-        if ((!$nextsco) && ($sco->id < $fsco->id)) {
-        $nextsco = $fsco->id;
-        }
-    }
-    }
-    $first = NULL;
-    $last = NULL;
-    if ($sco->id == $min)
-    $first = $sco;
-    if ($sco->id == $max)
-    $last = $sco;
-
-    // Get current sco User data
-    $sco_user = get_record("scorm_sco_users","userid",$USER->id,"scoid",$sco->id);
-
-    if (scorm_external_link($sco->launch)) {
-    $result = $sco->launch;
-    } else {
-    if ($CFG->slasharguments) {
-        $result = "$CFG->wwwroot/file.php/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch";
-    } else {
-        $result = "$CFG->wwwroot/file.php?file=/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch";
-    }
-    }
-    $navObj = "top.";
-    if ($scorm->popup == "") {
-    $navObj = "top.navigation.";
-    }
-
-    if ($sco->type == 'sco') {
-    include("api1_2.php");
-    }
-
-?>
-
-function hilightcurrent(popupmenu) {
-    for (i=0;i < popupmenu.options.length;i++) {
-     if ( popupmenu.options[i].value == <?php echo $sco->id; ?> )
-            popupmenu.options[i].selected = true;
-    }
-}
-
-function SCOInitialize() {
-<?php
-    if ( $sco->previous || $first) {
-        print "\t".$navObj."document.navform.prev.disabled = true;\n";
-    print "\t".$navObj."document.navform.prev.style.display = 'none';\n";
-    }
-    if ( $sco->next || $last) {
-        print "\t".$navObj."document.navform.next.disabled = true;\n";
-    print "\t".$navObj."document.navform.next.style.display = 'none';\n";
-    }
-?>
-<?php
-    if ($scorm->popup == "") {
-    echo "\t    top.main.location=\"$result\";\n";
-    echo "\t    hilightcurrent(".$navObj."document.navform.courseStructure);\n";
-    } else {
-        $popuplocation = '';
-        if (isset($_COOKIE["SCORMpopup"])) {
-            $popuplocation = $_COOKIE["SCORMpopup"];
-        }
-    echo "\t    top.main = window.open('$result','main','$scorm->popup$popuplocation');\n";
-    }
-?>
-}
-
-function SCOFinish(){
-    if (typeof API != "undefined") {
-    API.SaveTotalTime();
-    }
-}
-
-function changeSco(direction) {
-    if (direction == "previous")
-    <?php echo $navObj ?>document.navform.scoid.value="<?php echo $prevsco; ?>";
-    else
-    <?php echo $navObj ?>document.navform.scoid.value="<?php echo $nextsco; ?>";
-
-    //alert ("Prev: <?php echo $prevsco; ?>\nNext: <?php echo $nextsco; ?>\nNew SCO: "+<?php echo $navObj ?>document.navform.scoid.value);
-    <?php echo $navObj ?>document.navform.submit();
-}
-
-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();
-}
\ No newline at end of file
diff --git a/mod/scorm/validate.php b/mod/scorm/validate.php
new file mode 100755 (executable)
index 0000000..adf346f
--- /dev/null
@@ -0,0 +1,71 @@
+<?php // $Id$
+
+    require_once("../../config.php");
+    require_once("lib.php");
+
+    require_login();
+    
+    //
+    // Create a temporary directory to unzip package and validate imsmanifest
+    //
+
+    $reference = clean_param($_GET["reference"], PARAM_PATH);
+    $courseid = $_GET["id"];
+    $datadir = '';
+    $launch = 0;
+    if (isset($_GET["datadir"])) {
+        $datadir = $_GET["datadir"];
+    }
+    $result = '';
+    if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
+        if ($tempdir = scorm_datadir($scormdir, $datadir)) {
+            copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
+            unzip_file($tempdir."/".basename($reference), $tempdir, false);
+            $result = scorm_validate($tempdir."/imsmanifest.xml");
+        } else {
+            $result = "packagedir";
+        }
+    } else {
+        $result = "datadir";
+    }
+    $errorlogs = '';
+    if (($result != "regular") && ($result != "found")) {
+        if ($CFG->scorm_validate == 'domxml') {
+            foreach ($errors as $error) {
+                $errorlogs .= get_string($error->type,"scorm",$error->data) . ".\n";
+            }
+        }
+        //
+        // Delete files and temporary directory
+        //
+        if (is_dir($tempdir))
+            scorm_delete_files($tempdir);
+        } else {
+        //
+        // Delete package file
+        //
+        unlink ($tempdir."/".basename($reference));
+        if (isset($_GET["instance"])) {
+            $fp = fopen($CFG->dataroot.'/'.$reference,"r");
+            $fstat = fstat($fp);
+            fclose($fp);
+            if ($scorm = get_record("scorm","id",$_GET["instance"])) {
+               $launch = $scorm->launch;
+               if ($scorm->timemodified < $fstat["mtime"]) {
+                    $launch = 0;
+                }
+            }
+        }
+    }
+    //
+    // Print validation result
+    //
+    echo $result . "\n";
+    echo $launch . "\n";
+    $datadir = substr($tempdir,strlen($scormdir));
+    echo $datadir . "\n";
+    if ($errorlogs != '') {
+       echo $errorlogs;
+    }
+?>
+    
\ No newline at end of file
index b163002..8eb78aa 100755 (executable)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2005021600;   // The (date) version of this module
+$module->version  = 2005021700;   // The (date) version of this module
 $module->requires = 2005021600;   // The version of Moodle that is required
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
index 7da65b5..7d9254c 100755 (executable)
         if (! $cm = get_record("course_modules", "id", $id)) {
             error("Course Module ID was incorrect");
         }
-
+    
         if (! $course = get_record("course", "id", $cm->course)) {
             error("Course is misconfigured");
         }
-
+    
         if (! $scorm = get_record("scorm", "id", $cm->instance)) {
             error("Course module is incorrect");
         }
 
     require_login($course->id, false, $cm);
 
-
+    
     $strscorms = get_string("modulenameplural", "scorm");
     $strscorm  = get_string("modulename", "scorm");
-
+       
     if ($course->category) {
         $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
                        <a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
     }
 
     $pagetitle = strip_tags("$course->shortname: $scorm->name");
-
+    
     add_to_log($course->id, "scorm", "pre-view", "view.php?id=$cm->id", "$scorm->id");
-    //
-    // Checking if parsed scorm manifest
-    //
-    if ($scorm->launch == 0) {
-    $basedir = $CFG->dataroot."/".$course->id;
-        $scormdir = "/moddata/scorm";
-    $scorm->launch = scorm_parse($basedir,$scormdir.$scorm->datadir."/imsmanifest.xml",$scorm->id);
-    set_field("scorm","launch",$scorm->launch,"id",$scorm->id);
-    }
+    
     //
     // Print the page header
     //
     if (!$cm->visible and !isteacher($course->id)) {
-        print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true,
-                 update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
+        print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true, 
+                    update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
         notice(get_string("activityiscurrentlyhidden"));
     } else {
-        print_header($pagetitle, "$course->fullname","$navigation <a target=\"{$CFG->framename}\" href=\"$ME?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
-                 "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
-
-        if (isteacher($course->id)) {
-            if ($sco_users = get_records_select("scorm_sco_users", "scormid='$scorm->id' GROUP BY userid")) {
-            echo "<p align=\"right\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string("viewallreports","scorm",count($sco_users))."</a></p>";
+       print_header($pagetitle, "$course->fullname","$navigation <a target=\"{$CFG->framename}\" href=\"$ME?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
+                        "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
+        
+       if (isteacher($course->id)) {
+           if ($sco_users = get_records_select("scorm_sco_users", "scormid='$scorm->id' GROUP BY userid")) {
+               echo "<p align=\"right\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string("viewallreports","scorm",count($sco_users))."</a></p>";
             } else {
-            echo "<p align=\"right\">".get_string("noreports","scorm")."</p>";
+               echo "<p align=\"right\">".get_string("noreports","scorm")."</p>";
             }
-        }
-        // Print the main part of the page
+       }
+       // Print the main part of the page
 
-        print_heading($scorm->name);
+       print_heading($scorm->name);
 
-        print_simple_box(text_to_html($scorm->summary), "center");
+       print_simple_box(text_to_html($scorm->summary), "center");
 
-        if (isguest()) {
+       if (isguest()) {
             print_heading(get_string("guestsno", "scorm"));
             print_footer($course);
             exit;
-        }
+       }
         echo "<br />";
         $liststyle = "style=\"list-style-type:none;\"";
         print_simple_box_start("center");
-        echo "<table>\n";
-        echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
-    $organization = $scorm->launch;
-    if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) {
-        if (count($orgs) > 1) {
-        if (isset($_POST['organization'])) {
-            $organization = $_POST['organization'];
-        }
-        echo "<tr><td align='center'><form name='changeorg' method='post' action='view.php?id=$cm->id'>".get_string('organizations','scorm').": \n";
-        choose_from_menu($orgs, 'organization', "$organization", '','submit()');
-        echo "</form></td></tr>\n";
-        }
-    }
-    $orgidentifier = '';
-    if ($org = get_record('scorm_scoes','id',$organization)) {
-        if (($org->organization == '') && ($org->launch == '')) {
-            $orgidentifier = $org->identifier;
-        } else {
-            $orgidentifier = $org->organization;
-        }
-    }
-        echo "  <tr><td nowrap=\"nowrap\">\n<ul $liststyle>\n";
-        $incomplete = false;
-        if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$orgidentifier' order by id ASC")){
-        $level=0;
-            $sublist=0;
-            $parents[$level]="/";
-            foreach ($scoes as $sco) {
-            if ($parents[$level]!=$sco->parent) {
-                if ($level>0 && $parents[$level-1]==$sco->parent) {
-                echo "  </ul></li>\n";
-                $level--;
-                } else {
-                $i = $level;
-                $closelist = "";
-                while (($i > 0) && ($parents[$level] != $sco->parent)) {
-                    $closelist .= "  </ul></li>\n";
-                    $i--;
-                }
-                if (($i == 0) && ($sco->parent != $orgidentifier)) {
-                    echo "  <li><ul id='s".$sublist."' $liststyle>\n";
-                    $level++;
-                } else {
-                    echo $closelist;
-                    $level = $i;
-                }
-                $parents[$level]=$sco->parent;
-                }
-            }
-
-            echo "    <li>\n";
-            $nextsco = next($scoes);
-            if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
-                $sublist++;
-                echo "      <img src=\"pix/minus.gif\" onclick='expandCollide(this,\"s".$sublist."\");' alt=\"-\" title=\"".get_string('collide','scorm')."\" />\n";
-            } else {
-                echo "      <img src=\"pix/spacer.gif\" alt=\" \" />\n";
-            }
-            if ($sco->launch) {
-                $score = "";
-                if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
-                    if ( $sco_user->cmi_core_lesson_status == "") {
-                        $sco_user->cmi_core_lesson_status = "not attempted";
-                    }
-                echo "      <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
-            if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
-                $incomplete = true;
-            }
-            if ($sco_user->cmi_core_score_raw > 0) {
-                    $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
-                    }
-                } else {
-                if ($sco->type == 'sco') {
-                    echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\" />";
-                    $incomplete = true;
-                } else {
-                    echo "      <img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" title=\"".get_string("asset","scorm")."\" />";
-                }
-                }
-                echo "      &nbsp;<a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a> $score\n    </li>\n";
-            } else {
-            echo "      &nbsp;$sco->title\n    </li>\n";
-        }
-        }
-        for ($i=0;$i<$level;$i++){
-             echo "  </ul></li>\n";
-        }
-    }
-    echo "</ul></td></tr>\n";
-        echo "</table>\n";
-        print_simple_box_end();
-        echo "<form name=\"theform\" method=\"post\" action=\"playscorm.php?id=$cm->id\">\n";
-        echo "<table align=\"center\">\n<tr>\n<td align=\"center\">";
-        print_string("mode","scorm");
+       echo "<table>\n";
+       echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
+       $organization = $scorm->launch;
+       if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) {
+           if (count($orgs) > 1) {
+               if (isset($_POST['organization'])) {
+                   $organization = $_POST['organization'];
+               }
+               echo "<tr><td align='center'><form name='changeorg' method='post' action='view.php?id=$cm->id'>".get_string('organizations','scorm').": \n";
+               choose_from_menu($orgs, 'organization', "$organization", '','submit()');
+               echo "</form></td></tr>\n"; 
+           }
+       }
+       $orgidentifier = '';
+       if ($org = get_record('scorm_scoes','id',$organization)) {
+           if (($org->organization == '') && ($org->launch == '')) {
+               $orgidentifier = $org->identifier;
+           } else {
+               $orgidentifier = $org->organization;
+           }
+       }
+       echo "  <tr><td nowrap=\"nowrap\">\n<ul $liststyle>\n";
+       $incomplete = false;
+       if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$orgidentifier' order by id ASC")){
+           $level=0;
+           $sublist=0;
+           $parents[$level]="/";
+           foreach ($scoes as $sco) {
+               if ($parents[$level]!=$sco->parent) {
+                   if ($level>0 && $parents[$level-1]==$sco->parent) {
+                       echo "  </ul></li>\n";
+                       $level--;
+                   } else {
+                       $i = $level;
+                       $closelist = "";
+                       while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                           $closelist .= "  </ul></li>\n";
+                           $i--;
+                       }
+                       if (($i == 0) && ($sco->parent != $orgidentifier)) {
+                           echo "  <li><ul id='s".$sublist."' $liststyle>\n";
+                           $level++;
+                       } else {
+                           echo $closelist;
+                           $level = $i;
+                       }
+                       $parents[$level]=$sco->parent;
+                   }
+               } 
+               
+               echo "    <li>\n";
+               $nextsco = next($scoes);
+               if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
+                   $sublist++;
+                   echo "      <img src=\"pix/minus.gif\" onclick='expandCollide(this,\"s".$sublist."\");' alt=\"-\" title=\"".get_string('collide','scorm')."\" />\n";
+               } else {
+                   echo "      <img src=\"pix/spacer.gif\" alt=\" \" />\n";
+               }
+               if ($sco->launch) {
+                   $score = "";
+                   if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
+                       if ( $sco_user->cmi_core_lesson_status == "") {
+                           $sco_user->cmi_core_lesson_status = "not attempted";
+                       }
+                       echo "      <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
+                       if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
+                           $incomplete = true;
+                       }
+                       if ($sco_user->cmi_core_score_raw > 0) {
+                           $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
+                       }
+                   } else {
+                       if ($sco->type == 'sco') {
+                           echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\" />";
+                           $incomplete = true;
+                       } else {
+                           echo "      <img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" title=\"".get_string("asset","scorm")."\" />";
+                       }
+                   }
+                   echo "      &nbsp;<a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a> $score\n    </li>\n";
+               } else {
+                   echo "      &nbsp;$sco->title\n    </li>\n";
+               }
+           }
+           for ($i=0;$i<$level;$i++){
+                echo "  </ul></li>\n";
+           }
+       }
+       echo "</ul></td></tr>\n";
+       echo "</table>\n";
+       print_simple_box_end();
+       echo "<form name=\"theform\" method=\"post\" action=\"playscorm.php?id=$cm->id\">\n";
+       echo "<table align=\"center\">\n<tr>\n<td align=\"center\">";
+       print_string("mode","scorm");
         echo ": <input type=\"radio\" id=\"b\" name=\"mode\" value=\"browse\" /><label for=\"b\">".get_string("browse","scorm")."</label>\n";
         if ($incomplete === true) {
             echo "<input type=\"radio\" id=\"n\" name=\"mode\" value=\"normal\" checked=\"checked\" /><label for=\"n\">".get_string("normal","scorm")."</label>\n";
         } else {
             echo "<input type=\"radio\" id=\"r\" name=\"mode\" value=\"review\" checked=\"checked\" /><label for=\"r\">".get_string("review","scorm")."</label>\n";
-    }
-    echo "</td>\n</tr>\n<tr><td align=\"center\">";
-    echo '<input type="hidden" name="scoid" />
-    <input type="hidden" name="currentorg" value="'.$orgidentifier.'" />
-    <input type="submit" value="'.get_string("entercourse","scorm").'" />';
+       }
+       echo "</td>\n</tr>\n<tr><td align=\"center\">";
+       echo '<input type="hidden" name="scoid" />
+       <input type="hidden" name="currentorg" value="'.$orgidentifier.'" />
+       <input type="submit" value="'.get_string("entercourse","scorm").'" />';
         echo "\n</td>\n</tr>\n</table>\n</form><br />";
 ?>
 <script language="javascript" type="text/javascript">
 <!--
     function playSCO(scoid,status) {
-        document.theform.scoid.value = scoid;
-        document.theform.submit();
+       document.theform.scoid.value = scoid;
+       document.theform.submit();
     }
-
+    
     function expandCollide(which,list) {
-        var nn=document.ids?true:false
-    var w3c=document.getElementById?true:false
-    var beg=nn?"document.ids.":w3c?"document.getElementById('":"document.all.";
-    var mid=w3c?"').style":".style";
-
-        if (eval(beg+list+mid+".display") != "none") {
-            which.src = "pix/plus.gif";
-            which.alt = "+";
-            which.title = "<?php echo get_string('expand','scorm') ?>";
-            eval(beg+list+mid+".display='none';");
-        } else {
-            which.src = "pix/minus.gif";
-            which.alt = "-";
-            which.title = "<?php echo get_string('collide','scorm') ?>";
-            eval(beg+list+mid+".display='block';");
-        }
-
+       var nn=document.ids?true:false
+       var w3c=document.getElementById?true:false
+       var beg=nn?"document.ids.":w3c?"document.getElementById('":"document.all.";
+       var mid=w3c?"').style":".style";
+       
+       if (eval(beg+list+mid+".display") != "none") {
+           which.src = "pix/plus.gif";
+           which.alt = "+";
+           which.title = "<?php echo get_string('expand','scorm') ?>";
+           eval(beg+list+mid+".display='none';");
+       } else {
+           which.src = "pix/minus.gif";
+           which.alt = "-";
+           which.title = "<?php echo get_string('collide','scorm') ?>";
+           eval(beg+list+mid+".display='block';");
+       }
+       
     }
 -->
 </script>
 <?php
-        print_footer($course);
+       print_footer($course);
     }
 ?>