*** empty log message ***
authorbobopinna <bobopinna>
Tue, 6 Jul 2004 12:45:56 +0000 (12:45 +0000)
committerbobopinna <bobopinna>
Tue, 6 Jul 2004 12:45:56 +0000 (12:45 +0000)
mod/scorm/api1_2.php
mod/scorm/cmi.php
mod/scorm/lib.php
mod/scorm/playscorm.php
mod/scorm/view.php

index d2066dc..abe739e 100644 (file)
@@ -3,6 +3,7 @@
 //
 function SCORMapi() {
     var cmi= new Object();
+    var nav = new Object();
 
     var errorCode = 0;
     
@@ -53,7 +54,7 @@ function SCORMapi() {
            // end CMI Initialization
            //
            
-           nav = new Object();
+           // Navigation Object
            <?php 
                if ($scorm->auto) {
                    echo 'nav.event = "continue";'."\n";
@@ -111,14 +112,10 @@ function SCORMapi() {
            switch (param) {
                case "cmi.core.session_time":
                    if (typeof(value) == "string") {
-                       var matchedtime = value.match(/([0-9]{2,4}):([0-9]{2}):([0-9]{2})/g);
-                       if (matchedtime != null) {
-                           var parsedtime = value.match(/[0-9]+/g);
-                           if (((parsedtime.length == 3) || (parsedtime.length == 4)) && (parsedtime[0]>=0) && (parsedtime[0]<=9999) && (parsedtime[1]>=0) && (parsedtime[1]<=59) && (parsedtime[2]>=0) && (parsedtime[2]<=59)) {
-                               if ((parsedtime.length == 4) && (parsedtime[3]<=0) && (parsedtime[3]>=99)) {
-                                   errorCode = 405;
-                                   return "false";
-                               }
+                       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[2]>=0) && (parsedtime[2]<=59) && (parsedtime[3]>=0) && (parsedtime[3]<=59)) {
                                eval(param+'="'+value+'";');
                                errorCode = 0;
                                return "true";
@@ -249,11 +246,13 @@ function SCORMapi() {
            Initialized = false;
            errorCode = 0;
            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.theform) {
                cmiform = <?php echo $navObj ?>cmi.document.forms[0];
                cmiform.scoid.value = "<?php echo $sco->id; ?>";
                cmiform.cmi_core_total_time.value = cmi.core.total_time;
                cmiform.submit();
+               
            }
             if (nav.event != "") {
             <?php
index ef780bf..2c6716f 100755 (executable)
 
     require_login($course->id);
     
-    if ($_POST["scoid"]) {
-        if ($_POST["cmi_core_lesson_location"]) {
+    if (!empty($_POST["scoid"])) {
+        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);
        }
-       if ($_POST["cmi_core_lesson_status"]) {
+       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);
         }
-       if ($_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);
         }
-       if ($_POST["cmi_core_total_time"]) {
+       if (!empty($_POST["cmi_core_total_time"])) {
             set_field("scorm_sco_users","cmi_core_total_time",$_POST["cmi_core_total_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
         }
-       if ($_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);
         }
-       if ($_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);
         }
     }
        <input type="hidden" name="cmi_core_lesson_status" />
        <input type="hidden" name="cmi_core_exit" />
        <input type="hidden" name="cmi_core_session_time" />
-       <input type="hidden" name="cmi_core_total_time" />
+       <input type="hidden" name="cmi_core_total_time"  />
        <input type="hidden" name="cmi_core_score_raw" />
        <input type="hidden" name="cmi_suspend_data" />
    </form>
-   <?php echo $result?>
 </body>
 </html>
index 950df2c..ba3080a 100755 (executable)
@@ -302,10 +302,15 @@ function scorm_endElement($parser, $name) {
     if ($name == "ITEM") {
         $level--;
     }
-    if ($name == "TITLE" && $level>0)
-    $manifest[$i]["title"] = $datacontent;
-    if ($name == "ADLCP:HIDERTSUI")
-    $manifest[$i][$datacontent] = 1;
+    if ($name == "TITLE" && $level>0) {
+       $manifest[$i]["title"] = $datacontent;
+    }
+    if ($name == "ADLCP:HIDERTSUI") {
+       $manifest[$i][$datacontent] = 1;
+    }
+    if ($name == "ORGANIZATION") {
+       $level = 0;
+    }
 }
 
 function scorm_characterData($parser, $data) {
@@ -344,6 +349,7 @@ function scorm_parse($basedir,$file,$scorm_id) {
     $sco->scorm = $scorm_id;
     delete_records("scorm_scoes","scorm",$scorm_id);
     delete_records("scorm_sco_users","scormid",$scorm_id);
+    print_r($manifest);
     for ($j=1; $j<=$i; $j++) {
         $sco->identifier = $manifest[$j]["identifier"];
         $sco->parent = $manifest[$j]["parent"];
index 7daa10a..14939c6 100755 (executable)
                            echo "  </ul></li>\n";
                            $level--;
                        } else {
-                           echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
-                           $level++;
+                           $i = $level;
+                           $closelist = "";
+                           while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                               $closelist .= "  </ul></li>\n";
+                               $i--;
+                           }
+                           if (($i == 0) && ($sco->parent != "/")) {
+                               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 != $parents[$level-1])))) {
+                   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 "<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>
+                    <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=\"mode\" type=\"hidden\" value=\"".$mode."\" />
                        if ($level>0 && $parents[$level-1]==$sco->parent) {
                            $level--;
                        } else {
-                           $level++;
+                           $i = $level;
+                           while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                               $i--;
+                           }
+                           if (($i == 0) && ($sco->parent != "/")) {
+                               $level++;
+                           } else {
+                               $level = $i;
+                           }
                            $parents[$level]=$sco->parent;
                        }
                    }
index c456c8b..c9197bd 100755 (executable)
                        echo "  </ul></li>\n";
                        $level--;
                    } else {
-                       echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
-                       $level++;
+                       $i = $level;
+                       $closelist = "";
+                       while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                           $closelist .= "  </ul></li>\n";
+                           $i--;
+                       }
+                       if (($i == 0) && ($sco->parent != "/")) {
+                           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 != $parents[$level-1])))) {
+               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 {
                }
                if ($sco->launch) {
                    if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
-                       if ( $sco_user->cmi_core_lesson_status == "")
+                       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 (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
                            $incomplete = true;
+                       }
                    } else {
                        echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
                        $incomplete = true;
                    }
                    $score = "";
-                   if ($sco_user->cmi_core_score_raw > 0)
-                           $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
+                   if ($sco_user->cmi_core_score_raw > 0) {
+                       $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
+                   }
                    echo "      &nbsp;<a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a> $score\n    </li>\n";
                } else {
                    echo "      &nbsp;$sco->title\n    </li>\n";