Fixed some undefined variable
authorbobopinna <bobopinna>
Thu, 27 May 2004 12:44:11 +0000 (12:44 +0000)
committerbobopinna <bobopinna>
Thu, 27 May 2004 12:44:11 +0000 (12:44 +0000)
mod/scorm/api1_2.php
mod/scorm/details.php
mod/scorm/playscorm.php
mod/scorm/report.php
mod/scorm/scormAPI.php
mod/scorm/view.php

index 34dae80..df9b48a 100644 (file)
@@ -5,11 +5,11 @@
        
        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->firstname." ".$USER->lastname ?>";
-       cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location ?>";
+       cmi.core.student_id = "<?php echo $USER->username; ?>";
+       cmi.core.student_name = "<?php echo $USER->firstname." ".$USER->lastname; ?>";
+       cmi.core.lesson_location = "<?php echo $sco_user->cmi_core_lesson_location; ?>";
        cmi.core.credit = "credit";
-       cmi.core.lesson_status = "<?php echo $sco_user->cmi_core_lesson_status ?>";
+       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'; 
                                        echo 'resume'; 
                                    else 
                                        echo '';?>";
-       cmi.core.session_time = "<?php echo $sco_user->cmi_core_session_time ?>";
-       cmi.core.total_time = "<?php echo $sco_user->cmi_core_total_time ?>";
-       cmi.core.lesson_mode = "<?php echo $_GET["mode"] ?>";
+       cmi.core.session_time = "<?php echo $sco_user->cmi_core_session_time; ?>";
+       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";
-       cmi.core.score.raw = "<?php echo $sco_user->cmi_core_score_raw ?>";
-       cmi.suspend_data = "<?php echo $sco_user->cmi_suspend_data ?>";
-       cmi.launch_data = "<?php echo $sco_user->cmi_launch_data ?>";
+       cmi.core.score.raw = "<?php echo $sco_user->cmi_core_score_raw; ?>";
+       cmi.suspend_data = "<?php echo $sco_user->cmi_suspend_data; ?>";
+       cmi.launch_data = "<?php echo $sco_user->cmi_launch_data; ?>";
 /*     cmi.interactions = new Object();
        cmi.interactions._children = "id,objectives,time,type,correct_responses,weighting,student_response,result,latency";
        cmi.interactions._count = 0;
@@ -180,7 +180,7 @@ function SCORMapi() {
        if (Initialized) {
            if (top.nav.cmi.document.theform) {
                cmiform = top.nav.cmi.document.forms[0];
-               cmiform.scoid.value = "<?php echo  $sco->id ?>";
+               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;
index 4d3c51b..f4e60fa 100755 (executable)
@@ -83,7 +83,7 @@
            echo "    <tr><td align=\"center\" colspan=\"2\" nowrap><p><b>".get_string("trackingloose","scorm")."</b></p></td></tr>\n";
        echo "</table>\n";
        if ($result == "regular") {
-           echo "<form name=\"theform\" method=\"post\" $onsubmit action=\"$form->destination\">\n";
+           echo "<form name=\"theform\" method=\"post\" action=\"$form->destination\">\n";
 ?>
         <input type="hidden" name="reference"  value="<?php p($form->reference) ?>">
         <input type="hidden" name="datadir"    value="<?php p(substr($tempdir,strlen($scormdir))) ?>">
index 83294be..88b70ff 100755 (executable)
@@ -8,6 +8,7 @@
 
     optional_variable($id);    // Course Module ID, or
     optional_variable($a);     // scorm ID
+    optional_variable($frameset, "");
 
     if ($id) {
         if (! $cm = get_record("course_modules", "id", $id)) {
@@ -54,7 +55,7 @@
                      update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
         notice(get_string("activityiscurrentlyhidden"));
     }
-    if ($frameset) {
+    if ($frameset == "top") {
        add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
        //
        // Print the page header
index c03b973..c5dbaf1 100755 (executable)
@@ -87,6 +87,7 @@
                                $row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$data->userid&course=$course->id\">".
                                         "$data->firstname $data->lastname</a>";
                                foreach ($user_data as $data) {
+                                   $scoreview = "";
                                    if ($data->cmi_core_score_raw > 0)
                                        $scoreview = "<br />".get_string("score","scorm").":&nbsp;".$data->cmi_core_score_raw;
                                    $row[]="<img src=\"pix/".scorm_remove_spaces($data->cmi_core_lesson_status).".gif\" 
index bb5d9f8..d4faf10 100755 (executable)
@@ -4,6 +4,8 @@
 
     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)) {
     require_login($course->id);
 
     if ( $scoes_user = get_records_select("scorm_sco_users","userid = ".$USER->id." AND scormid = ".$scorm->id,"scoid ASC") ) {
-       if ($_GET["scoid"]) {
-           $sco = get_record("scorm_scoes","id",$_GET["scoid"]);
+       if ($scoid) {
+           $sco = get_record("scorm_scoes","id",$scoid);
        } else {
            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 ($_GET["mode"] == "review") {
+                   if ($mode == "review") {
                        $sco = get_record("scorm_scoes","id",$sco_user->scoid);
                        break;
                    }
@@ -68,8 +70,8 @@
                }
            }
            $sco = $first;
-           if ($_GET["scoid"]) {
-               if ($sco = get_record("scorm_scoes","id",$_GET["scoid"]))
+           if ($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))
@@ -92,6 +98,8 @@
            }
        }
     }
+    $first = NULL;
+    $last = NULL;
     if ($sco->id == $min)
        $first = $sco;
     if ($sco->id == $max)
@@ -124,7 +132,7 @@ function SCOInitialize() {
        print "\ttop.nav.document.navform.next.style.display = 'none';\n";
     }
 ?>
-       top.main.location="<?php echo $result ?>";
+       top.main.location="<?php echo $result; ?>";
        for (i=0;i<top.nav.document.navform.courseStructure.options.length;i++) {
            if ( top.nav.document.navform.courseStructure.options[i].value == <?php echo $sco->id; ?> )
                top.nav.document.navform.courseStructure.options[i].selected = true;
@@ -133,10 +141,10 @@ function SCOInitialize() {
 
 function changeSco(direction) {
        if (direction == "prev")
-           top.nav.document.navform.scoid.value="<?php echo $prevsco ?>";
+           top.nav.document.navform.scoid.value="<?php echo $prevsco; ?>";
        else
-           top.nav.document.navform.scoid.value="<?php echo $nextsco ?>";
+           top.nav.document.navform.scoid.value="<?php echo $nextsco; ?>";
            
-       //alert ("Prev: <?php echo $prevsco ?>\nNext: <?php echo $nextsco ?>\nNew SCO: "+top.nav.document.navform.scoid.value);
+       //alert ("Prev: <?php echo $prevsco; ?>\nNext: <?php echo $nextsco; ?>\nNew SCO: "+top.nav.document.navform.scoid.value);
        top.nav.document.navform.submit();
 }   
\ No newline at end of file
index c5b14ec..9e24551 100755 (executable)
@@ -94,6 +94,7 @@
        echo "<table>\n";
        echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
        echo "  <tr><td nowrap>\n<ul compact class=\"scormlist\"'>\n";
+       $incomplete = false;
        if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
            $level=0;
            $sublist=0;
                }
                echo "    <li>\n";
                $nextsco = next($scoes);
-               if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && ($nextsco->parent != $parents[$level-1])) {
+               if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent != $parents[$level-1])))) {
                    $sublist++;
                    echo "      <img src=\"pix/minus.gif\" onClick='expandCollide(this,".$sublist.");'/>\n";
-               } else
+               } else {
                    echo "      <img src=\"pix/spacer.gif\" />\n";
+               }
                if ($sco->launch) {
                    if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
                        if ( $sco_user->cmi_core_lesson_status == "")
        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) {
+        if ($incomplete === true) {
             echo "<input type=\"radio\" id=\"n\" name=\"mode\" value=\"normal\" checked /><label for=\"n\">".get_string("normal","scorm")."</label>\n";
         } else {
             echo "<input type=\"radio\" id=\"r\" name=\"mode\" value=\"review\" checked /><label for=\"r\">".get_string("review","scorm")."</label>\n";