Added multiorg display and patched some typo
authorbobopinna <bobopinna>
Mon, 9 Aug 2004 07:26:06 +0000 (07:26 +0000)
committerbobopinna <bobopinna>
Mon, 9 Aug 2004 07:26:06 +0000 (07:26 +0000)
mod/scorm/api1_2.php
mod/scorm/lib.php
mod/scorm/playscorm.php
mod/scorm/view.php

index 2888a13..436a372 100644 (file)
@@ -208,8 +208,16 @@ function SCORMapi() {
                    errorCode = "0";
                    return "true";
                break;
-               case "cmi.suspend_data":
                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";
index f4ab32d..9a096ca 100755 (executable)
@@ -388,7 +388,9 @@ function scorm_delete_files($directory)
 }
 
 function scorm_startElement($parser, $name, $attrs) {
+
     global $scoes,$i,$resources,$parent,$level,$organization,$manifest,$defaultorg;
+
     if ($name == 'ITEM') {
         $i++;
         $scoes[$i]['manifest'] = $manifest;
@@ -409,15 +411,30 @@ function scorm_startElement($parser, $name, $attrs) {
             $attrs['HREF'] = '';
         }
         $resources[$attrs['IDENTIFIER']]['href']=$attrs['HREF'];
+        if (!isset($attrs['ADLCP:SCORMTYPE'])) {
+            $attrs['ADLCP:SCORMTYPE'] = '';
+        }
         $resources[$attrs['IDENTIFIER']]['type']=$attrs['ADLCP:SCORMTYPE'];
     }
     if ($name == 'ORGANIZATION') {
+        $i++;
+        $scoes[$i]['manifest'] = $manifest;
+        $scoes[$i]['organization'] = '';
+        $scoes[$i]['identifier'] = $attrs['IDENTIFIER'];
+        $scoes[$i]['identifierref'] = '';
+        $scoes[$i]['isvisible'] = '';
+        $scoes[$i]['parent'] = $parent[$level];
+        $level++;
+        $parent[$level] = $attrs['IDENTIFIER'];
        $organization = $attrs['IDENTIFIER'];
     }
     if ($name == 'MANIFEST') {
        $manifest = $attrs['IDENTIFIER'];
     }
     if ($name == 'ORGANIZATIONS') {
+       if (!isset($attrs['DEFAULT'])) {
+           $attrs['DEFAULT'] = '';
+       }
        $defaultorg = $attrs['DEFAULT'];
     }
 }
@@ -427,12 +444,23 @@ function scorm_endElement($parser, $name) {
     if ($name == 'ITEM') {
         $level--;
     }
-    if ($name == 'TITLE' && $level>0)
+    //if ($name == 'TITLE' && $level>0) {
+    if ($name == 'TITLE') {
         $scoes[$i]['title'] = $datacontent;
-    if ($name == 'ADLCP:HIDERTSUI')
+    }
+    if ($name == 'ADLCP:HIDERTSUI') {
         $scoes[$i][$datacontent] = 1;
-    if ($name == 'ADLCP:DATAFROMLMS')
+    }
+    if ($name == 'ADLCP:DATAFROMLMS') {
        $scoes[$i]['datafromlms'] = $datacontent;
+    }
+    if ($name == 'ORGANIZATION') {
+       $organization = '';
+       $level--;
+    }
+    if ($name == 'MANIFEST') {
+       $manifest = '';
+    }
 }
 
 function scorm_characterData($parser, $data) {
@@ -508,7 +536,8 @@ function scorm_parse($basedir,$file,$scorm_id) {
            if (scorm_remove_spaces($scoes[$j]['isvisible']) != 'false') {
                $id = insert_record('scorm_scoes',$sco);
             }
-           if (($launch==0) && (isset($sco->launch)) && ($defaultorg==$sco->organization)) {
+           //if (($launch==0) && (isset($sco->launch)) && ($defaultorg==$sco->organization)) {
+           if (($launch==0) && ($defaultorg==$sco->identifier)) {
                $launch = $id;
             }
        }
index a2ad50b..43fc87d 100755 (executable)
@@ -58,6 +58,9 @@
     
     if (!empty($_POST["scoid"]))
            $scoid = "&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"])))
            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' order by id ASC")){
+           if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
                $level=0;
                $sublist=0;
                $parents[$level]="/";
                                $closelist .= "  </ul></li>\n";
                                $i--;
                            }
-                           if (($i == 0) && ($sco->parent != "/")) {
+                           if (($i == 0) && ($sco->parent != $currentorg)) {
                                echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
                                $level++;
                            } else {
                            $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";
                                    $endbold = '</b> <-';
                                }
                            }
+                           if ($sco_user->cmi_core_score_raw > 0) {
+                               $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
+                           }
                        } 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.")";
-                       echo "      &nbsp;$startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a> $score$endbold\n    </li>\n";
+                       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";
                    }
                     <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' order by id ASC")){
+           $currentorg = '';
+           if (isset($_GET['currentorg'])) {
+               $currentorg = $_GET['currentorg'];
+           }
+           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) {
                            while (($i > 0) && ($parents[$level] != $sco->parent)) {
                                $i--;
                            }
-                           if (($i == 0) && ($sco->parent != "/")) {
+                           if (($i == 0) && ($sco->parent != $currentorg)) {
                                $level++;
                            } else {
                                $level = $i;
                </td>\n";
        
        echo "</tr>\n</table>\n";
-       echo "</body>\n</html>\n";
+       if ($scorm->popup == "") {
+           echo "</body>\n</html>\n";
+       } else {
+           print_footer($course);
+       }
     } else {
         if ($scorm->popup == "") {
            // 
             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&mode=".$mode.$scoid."\"></script>\n";
            echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"API.SaveTotalTime();\" onbeforeUnload=\"API.SaveTotalTime();\">\n";
-            echo "\t    <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id&mode=".$mode."&frameset=top\">\n";
+            echo "\t    <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id&mode=".$mode.'&currentorg='.$currentorg."&frameset=top\">\n";
             echo "\t    <frame name=\"main\" src=\"\">\n";
             echo "</frameset>\n";
             echo "</html>\n";
index c9197bd..b89c9aa 100755 (executable)
         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>\n<ul class=\"scormlist\"'>\n";
        $incomplete = false;
-       if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
-           $level=0;
+       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) {
                            $closelist .= "  </ul></li>\n";
                            $i--;
                        }
-                       if (($i == 0) && ($sco->parent != "/")) {
+                       if (($i == 0) && ($sco->parent != $orgidentifier)) {
                            echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
                            $level++;
                        } else {
                    echo "      <img src=\"pix/spacer.gif\" />\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";
                        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 {
                        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.")";
-                   }
                    echo "      &nbsp;<a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a> $score\n    </li>\n";
                } else {
                    echo "      &nbsp;$sco->title\n    </li>\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 "\n</td>\n</tr>\n</table>\n</form><br />";
 ?>