From: bobopinna <bobopinna>
Date: Mon, 21 Jun 2004 11:27:52 +0000 (+0000)
Subject: Added popup window scorm player and its settings
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=76d3542313253ccb5dca3fe412aee2165e20897b;p=moodle.git

Added popup window scorm player and its settings
---

diff --git a/mod/scorm/api1_2.php b/mod/scorm/api1_2.php
index 6b5e8b1137..360e981a6c 100644
--- a/mod/scorm/api1_2.php
+++ b/mod/scorm/api1_2.php
@@ -1,47 +1,11 @@
-//
-// CMI Initialization SCORM 1.2
-//
-	var cmi= new Object();
-	
-	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.credit = "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 = "<?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,min,max";
-	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;
-*/
-	var errorCode = 0;
-
-//
-// end CMI Initialization
-//
-
-
 // 
 // SCORM API 1.2 Implementation
 //
 function SCORMapi() {
+    var cmi= new Object();
+
+    var errorCode = 0;
+    
     var Initialized = false;
 
     function LMSInitialize (param) {
@@ -52,6 +16,37 @@ function SCORMapi() {
 	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->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.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 = "";
+	    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.suspend_data = "<?php echo $sco_user->cmi_suspend_data; ?>";
+	    cmi.launch_data = "<?php echo $sco_user->cmi_launch_data; ?>";
+	    //
+	    // end CMI Initialization
+	    //
+
 	    return "true";
 	} else {
 	    errorCode = 101;
@@ -277,6 +272,7 @@ function SCORMapi() {
 	
 	return hours + ":" + mins + ":" + secs;
     }
+    
     this.LMSInitialize = LMSInitialize;
     this.LMSGetValue = LMSGetValue;
     this.LMSSetValue = LMSSetValue;
diff --git a/mod/scorm/config.html b/mod/scorm/config.html
new file mode 100755
index 0000000000..b4c8e24829
--- /dev/null
+++ b/mod/scorm/config.html
@@ -0,0 +1,50 @@
+<form method="post" action="module.php" name="form">
+
+<table cellpadding=9 cellspacing=0 >
+<tr valign=top>
+	<td align=right><p>scorm_framesize:</td>
+	<td>
+    <input name=scorm_framesize type=text size=5 value="<?php p($CFG->scorm_framesize) ?>">
+    </td>
+    <td>
+    <?php print_string("configframesize", "scorm") ?>
+    </td>
+</tr>
+<tr valign=top>
+	<td align=right><p>scorm_popup:</td>
+	<td>
+    <?php
+        unset($choices);
+        $choices[""] = get_string("no");
+        $choices["checked"] = get_string("yes");
+        choose_from_menu ($choices, "scorm_popup", $CFG->scorm_popup, "");
+    ?>
+    </td>
+    <td>
+    <?php print_string("configpopup", "scorm") ?>
+    </td>
+</tr>
+<?php foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
+          $defaultvalue = "scorm_popup$optionname";
+          echo "<tr valign=top>";
+	      echo "<td align=right><p>$defaultvalue:</td>";
+	      echo "<td>";
+          if ($optionname == "height" or $optionname == "width") {
+              echo "<input name=$defaultvalue type=text size=5 value=\"".$CFG->$defaultvalue."\">";
+          } else {
+              choose_from_menu ($choices, $defaultvalue, $CFG->$defaultvalue, "");
+          }
+          echo "</td>";
+          echo "<td>";
+          print_string("configpopup$optionname", "scorm");
+          echo "</td>";
+          echo "</tr>";
+      }
+?>
+<tr>
+    <td colspan=3 align=center>
+	<input type="submit" value="<?php print_string("savechanges") ?>"></td>
+</tr>
+</table>
+
+</form>
diff --git a/mod/scorm/db/mysql.php b/mod/scorm/db/mysql.php
index d9ae381bb2..d1aaf486fd 100755
--- a/mod/scorm/db/mysql.php
+++ b/mod/scorm/db/mysql.php
@@ -5,14 +5,17 @@ function scorm_upgrade($oldversion) {
 /// older versions to match current functionality
     global $CFG;
     if ($oldversion < 2004033000) {
-    	execute_sql(" ALTER TABLE `{$CFG->prefix}scorm` ADD `auto` TINYINT( 1 ) UNSIGNED DEFAULT '0' NOT NULL AFTER `summary`"); 
+    	table_column("scorm", "", "auto", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "summary"); 
     }
     if ($oldversion < 2004040900) {
-    	execute_sql(" ALTER TABLE `{$CFG->prefix}scorm_sco_users` ADD `cmi_core_score_raw` FLOAT( 3 ) DEFAULT '0' NOT NULL AFTER `cmi_core_session_time`"); 
+        table_column("scorm_sco_users", "", "cmi_core_score_raw", "FLOAT", "3", "", "0", "NOT NULL", "cmi_core_session_time");
+    }
+    if ($oldversion < 2004061800) {
+    	table_column("scorm", "", "popup", "VARCHAR", "255", "", "", "NOT NULL", "auto");
+    	table_column("scorm", "reference", "reference", "VARCHAR", "255", "", "", "NOT NULL");
     }
     return true;
 }
 
 
 ?>
-
diff --git a/mod/scorm/db/mysql.sql b/mod/scorm/db/mysql.sql
index 58b2046730..4a19a1cf1f 100755
--- a/mod/scorm/db/mysql.sql
+++ b/mod/scorm/db/mysql.sql
@@ -6,11 +6,12 @@ CREATE TABLE prefix_scorm (
   id int(10) unsigned NOT NULL auto_increment,
   course int(10) unsigned NOT NULL default '0',
   name varchar(255) NOT NULL default '',
-  reference varchar(255) default NULL,
+  reference varchar(255) NOT NULL default '',
   datadir varchar(255) NOT NULL default '',
   launch int(10) unsigned NOT NULL default 0,
   summary text NOT NULL,
   auto tinyint(1) unsigned NOT NULL default '0',
+  popup varchar(255) NOT NULL default '',
   timemodified int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (id),
   UNIQUE KEY id (id)
diff --git a/mod/scorm/db/postgres7.php b/mod/scorm/db/postgres7.php
index 90c53dd8d8..b56d414d1e 100755
--- a/mod/scorm/db/postgres7.php
+++ b/mod/scorm/db/postgres7.php
@@ -3,7 +3,17 @@
 function scorm_upgrade($oldversion) {
 // This function does anything necessary to upgrade
 // older versions to match current functionality
-
+    global $CFG;
+    if ($oldversion < 2004033000) {
+    	table_column("scorm", "", "auto", "integer", "1", "", "0", "NOT NULL", "summary"); 
+    }
+    if ($oldversion < 2004040900) {
+        table_column("scorm_sco_users", "", "cmi_core_score_raw", "real", "3", "", "0", "NOT NULL", "cmi_core_session_time");
+    }
+    if ($oldversion < 2004061800) {
+    	table_column("scorm", "", "popup", "varchar", "255", "", "", "NOT NULL", "auto");
+    	table_column("scorm", "reference", "reference", "varchar", "255", "", "", "NOT NULL");
+    }
     return true;
 }
 
diff --git a/mod/scorm/db/postgres7.sql b/mod/scorm/db/postgres7.sql
index aa2df46c22..8d0d21c48c 100755
--- a/mod/scorm/db/postgres7.sql
+++ b/mod/scorm/db/postgres7.sql
@@ -6,11 +6,12 @@ CREATE TABLE prefix_scorm (
   id SERIAL PRIMARY KEY,
   course integer NOT NULL default '0',
   name varchar(255) NOT NULL default '',
-  reference varchar(255) default NULL,
+  reference varchar(255) NOT NULL default '',
   datadir varchar(255) NOT NULL default '',
   launch integer NOT NULL default '0',
   summary text NOT NULL default '',
   auto integer NOT NULL default '0',
+  popup varchar(255) NOT NULL default '',
   timemodified integer NOT NULL default '0'
 );
 
diff --git a/mod/scorm/details.php b/mod/scorm/details.php
index f4e60fac1e..f2bc1f59c5 100755
--- a/mod/scorm/details.php
+++ b/mod/scorm/details.php
@@ -79,16 +79,119 @@
     	echo "<table cellpadding=\"5\" align=\"center\">\n";
     	echo "    <tr><td align=\"right\" nowrap><p><b>$strname:</b></p></td><td><p>$form->name</p></a></td></tr>\n";
     	echo "    <tr><td align=\"right\" nowrap><p><b>".get_string("validation","scorm").":</b></p></td><td><p>".get_string($result,"scorm")."</p></a></td></tr>\n";
-    	if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_user","scormid",$form->instance)))
+    	if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance)))
 	    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") {
+    	    if (empty($form->auto)) {
+		$form->auto = "";
+    	    }
 	    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
+         	} else {
+             	    $newwindow = "checked";
+                    $rawoptions = explode(',', $form->popup); 
+                    foreach ($rawoptions as $rawoption) {
+                 	$option = explode('=', trim($rawoption));
+                 	if ((option != 'location') && (option != 'menubar') && (option != 'toolbar')) {
+                 	    $optionname = $option[0];
+                 	    $optionvalue = $option[1];
+                 	    if ($optionname == "height" or $optionname == "width") {
+                 	        $window->$optionname = $optionvalue;
+                 	    } else if ($optionvalue) {
+                 	        $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><p><b><?php print_string("autocontinue","scorm") ?>:</b></p></td>
+	    <td>
+	    <?php
+	    	$options[]=get_string("no");
+	    	$options[]=get_string("yes");
+	        choose_from_menu ($options, "auto", $form->auto);
+	    ?>
+	    </td>
+	  </tr>
+	  <tr valign="top">
+            <td align="right" nowrap>
+                <p><b><?php p($strnewwindow) ?></b></p>
+            </td>
+            <td>
+                <script>
+                    var subitems = [<?php echo $alljsoptions; ?>];
+                    
+                    function autowindow() {
+                        if (document.theform.newwindow.checked) 
+                            document.theform.auto.disabled=true;
+                        else
+                            document.theform.auto.disabled=false;
+                    }
+                </script>
+                <input name="setnewwindow" type=hidden value=1>
+                <input name="newwindow" type=checkbox value=1 <?php p($newwindow) ?> 
+                        onclick="autowindow();return lockoptions('theform','newwindow', subitems);"> 
+                <?php p($strnewwindowopen) ?>
+                <ul>
+                <?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";
+                        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) ?>">
+                 <?php p($strwidth) ?><br />
+
+                 <input name="hheight" type=hidden value=0>
+                 <input name="height" type=text size=4 value="<?php p($window->height) ?>">
+                 <?php p($strheight) ?><br />
+                 <?php
+                     if (!$newwindow) {
+                         echo "<script>";
+                         echo "lockoptions('theform','newwindow', subitems);";
+                         echo "</script>";
+                     }
+                 ?>
+                 </ul>
+                 </p>
+             </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="auto"	value="<?php p($form->auto) ?>">
         <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) ?>">
diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php
index 5aa5e02865..5340699562 100755
--- a/mod/scorm/lib.php
+++ b/mod/scorm/lib.php
@@ -3,8 +3,28 @@
 /// Library of functions and constants for module scorm
 /// (replace scorm with the name of your module and delete this line)
 
+$SCORM_WINDOW_OPTIONS = array("resizable", "scrollbars", "status", "height", "width");
+
+if (!isset($CFG->scorm_popup)) {
+    set_config("scorm_popup", "");
+}  
+
+foreach ($SCORM_WINDOW_OPTIONS as $popupoption) {
+    $popupoption = "scorm_popup$popupoption";
+    if (!isset($CFG->$popupoption)) {
+        if ($popupoption == "scorm_popupheight") {
+            set_config($popupoption, 450);
+        } else if ($popupoption == "scorm_popupwidth") {
+            set_config($popupoption, 620);
+        } else {
+            set_config($popupoption, "checked");
+        }
+    }  
+}
 
-$SCORM_FRAME_SIZE = 140;
+if (!isset($CFG->scorm_framesize)) {
+    set_config("scorm_framesize", 140);
+}
 
 function scorm_add_instance($scorm) {
 /// Given an object containing all the necessary data, 
@@ -15,6 +35,19 @@ function scorm_add_instance($scorm) {
     $scorm->timemodified = time();
 
     # May have to add extra stuff in here #
+    global $SCORM_WINDOW_OPTIONS;
+    
+    if (isset($scorm->setnewwindow)) {
+        $optionlist = array();
+        foreach ($SCORM_WINDOW_OPTIONS as $option) {
+            if (isset($scorm->$option)) {
+                $optionlist[] = $option."=".$scorm->$option;
+            }
+        }
+        $scorm->popup = implode(',', $optionlist);
+        $scorm->popup .= ',location=0,menubar=0,toolbar=0';
+        $scorm->auto = '0';
+    }
     
     return insert_record("scorm", $scorm);
 }
@@ -24,11 +57,24 @@ function scorm_update_instance($scorm) {
 /// Given an object containing all the necessary data, 
 /// (defined by the form in mod.html) this function 
 /// will update an existing instance with new data.
-
+    
     $scorm->timemodified = time();
     $scorm->id = $scorm->instance;
 
     # May have to add extra stuff in here #
+    global $SCORM_WINDOW_OPTIONS;
+    
+    if (isset($scorm->setnewwindow)) {
+        $optionlist = array();
+        foreach ($SCORM_WINDOW_OPTIONS as $option) {
+            if (isset($scorm->$option)) {
+                $optionlist[] = $option."=".$scorm->$option;
+            }
+        }
+        $scorm->popup = implode(',', $optionlist);
+        $scorm->popup .= ',location=0,menubar=0,toolbar=0';
+        $scorm->auto = '0';
+    }
 
     return update_record("scorm", $scorm);
 }
diff --git a/mod/scorm/mod.html b/mod/scorm/mod.html
index efd858e0dd..b6f874d8f6 100755
--- a/mod/scorm/mod.html
+++ b/mod/scorm/mod.html
@@ -11,9 +11,6 @@
     if (empty($form->launch)) {
 	$form->launch = "";
     }
-    if (empty($form->auto)) {
-	$form->auto = "";
-    }
 ?>
 
 
@@ -58,16 +55,6 @@
         <?php print_textarea($usehtmleditor, 20, 50, 680, 400, "summary", $form->summary); ?>
 	    </td>
 	</tr>
-	<tr valign=top>
-	    <td align=right><p><b><?php print_string("autocontinue","scorm") ?>:</b></p></td>
-	    <td>
-	    <?php
-	    	$options[]=get_string("no");
-	    	$options[]=get_string("yes");
-	        choose_from_menu ($options, "auto", $form->auto);
-	    ?>
-	    </td>
-	</tr>
     </table>
     <input type="hidden" name=course	value="<?php p($form->course) ?>">
     <input type="hidden" name=coursemodule	value="<?php p($form->coursemodule) ?>">
diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php
index 88b70ff6e3..8f7862a32e 100755
--- a/mod/scorm/playscorm.php
+++ b/mod/scorm/playscorm.php
@@ -64,55 +64,171 @@
 		"$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'));
     	
-    	echo "<table width=\"100%\">\n    <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td></tr></table>\n";
+    	echo "<table width=\"100%\">\n    <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td>\n";
+    	if ($_GET["mode"] == "browse")
+	    echo "<td align=\"right\" width=\"10%\" nowrap>".get_string("browsemode","scorm")."</td>\n";
+    	echo "     </tr>\n</table>\n";
+    	
     	
-    	if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' 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 {
-    			$level++;
-    			$parents[$level]=$sco->parent;
-    		    }
-    		}
-    		$indenting = "";
-    		for ($i=0;$i<$level;$i++) {
-    		     $indenting .= "-";
-    		}
-    		$options[$sco->id] = $indenting."&gt; ".$sco->title;
-	    }
-	}
 	    
     	echo "<table width=\"100%\">\n    <tr>\n";
-    	echo "          <td nowrap>
+    	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=\"mode\" type=\"hidden\" value=\"".$_GET["mode"]."\" />
 		     	<input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" />&nbsp;\n";
-	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('next')\" />
-		     </form>
+		     	
+	if ($scorm->popup == "") {
+	    if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' 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 {
+    			    $level++;
+    			    $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('next')\" />\n";
+	echo "	     </form>
 		</td>\n";
-	if ($_GET["mode"] == "browse")
-	    echo "<td align=\"right\">".get_string("browsemode","scorm")."</td>\n";
+	
     	echo "</tr>\n</table>\n";
+        if ($scorm->popup != "") {
+	    $currentSCO = "";
+            if (!empty($_GET['scoid']))
+                $currentSCO = $_GET['scoid'];
+        ?>
+            <br />
+            <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';");
+    		    }
+    	
+    		}
+            -->
+            </script>
+            <style type="text/css">
+                .scormlist { list-style-type:none; }
+            </style>
+        <?php
+            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' 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 {
+    			    echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
+    			    $level++;
+    			    $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])))) {
+    			$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 == $currentSCO) {
+    			    $startbold = '<b><u>';
+    			    $endbold = '</u></b>';
+    		    	}
+    			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><u>';
+    			    	    $endbold = '</u></b>';
+ 				}
+ 			    }
+    			} else {
+    			    echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
+    			    $incomplete = true;
+    			}
+    		        echo "      &nbsp;$startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a>$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 "</body>\n</html>\n";
     } else {
-    	// 
-    	// Frameset
-    	//
-	if ($_POST["scoid"])
+        if ($_POST["scoid"])
     	    $scoid = "&scoid=".$_POST["scoid"];
-	echo "<html>\n";
+    	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&mode=".$_POST["mode"].$scoid."\"></script>\n";
-        echo "<frameset rows=\"$SCORM_FRAME_SIZE,*\" onLoad=\"SCOInitialize();\">\n";
-        echo "	    <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top\">\n";
-        echo "	    <frame name=\"main\" src=\"\">\n";
+
+        if ($scorm->popup == "") {
+    	    // 
+    	    // Frameset
+    	    //
+	    echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\">\n";
+            echo "	    <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top\">\n";
+            echo "	    <frame name=\"main\" src=\"\">\n";
+        } else {
+            echo "<script language=\"Javascript\">\n";
+            echo '<!--';
+            echo "\nmain = window.open('','SCO Display','$scorm->popup');\n";
+            echo "-->\n";
+            echo '</script>';
+            echo "\n<frameset rows=\"*\" onLoad=\"SCOInitialize();\">\n";
+            echo "	    <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top".$scoid."\">\n";
+        }
         echo "</frameset>\n";
         echo "</html>\n";
     }
diff --git a/mod/scorm/report.php b/mod/scorm/report.php
index c5dbaf179e..42c7a43b81 100755
--- a/mod/scorm/report.php
+++ b/mod/scorm/report.php
@@ -90,6 +90,8 @@
     				    $scoreview = "";
     				    if ($data->cmi_core_score_raw > 0)
     				    	$scoreview = "<br />".get_string("score","scorm").":&nbsp;".$data->cmi_core_score_raw;
+    				    if ( $data->cmi_core_lesson_status == "")
+    		    			$data->cmi_core_lesson_status = "not attempted";
         		    	    $row[]="<img src=\"pix/".scorm_remove_spaces($data->cmi_core_lesson_status).".gif\" 
     						   alt=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\"
     						   title=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\">&nbsp;"
diff --git a/mod/scorm/scormAPI.php b/mod/scorm/scormAPI.php
index e61621b8b5..92880dfa6b 100755
--- a/mod/scorm/scormAPI.php
+++ b/mod/scorm/scormAPI.php
@@ -135,6 +135,7 @@
     include("api1_2.php");
 
 ?>
+
 function hilightcurrent(popupmenu) {
     for (i=0;i < popupmenu.options.length;i++) {
 	 if ( popupmenu.options[i].value == <?php echo $sco->id; ?> )
@@ -154,8 +155,9 @@ function SCOInitialize() {
     }
 ?>
 	top.main.location="<?php echo $result; ?>";
+<?php	if ($scorm->popup == "") { ?>
 	hilightcurrent(top.nav.document.navform.courseStructure);
-	
+<?php   } ?>
 } 
 
 function changeSco(direction) {
diff --git a/mod/scorm/version.php b/mod/scorm/version.php
index 26e5a16cfd..d1a9144f1e 100755
--- a/mod/scorm/version.php
+++ b/mod/scorm/version.php
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004060400;   // The (date) version of this module
+$module->version  = 2004061800;   // The (date) version of this module
 $module->requires = 2004051600;   // The version of Moodle that is required
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
diff --git a/mod/scorm/view.php b/mod/scorm/view.php
index f89a5627b4..97eae95c3b 100755
--- a/mod/scorm/view.php
+++ b/mod/scorm/view.php
@@ -93,7 +93,7 @@
         print_simple_box_start("CENTER");
     	echo "<table>\n";
     	echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
-    	echo "  <tr><td nowrap>\n<ul compact class=\"scormlist\"'>\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")){
     	    $level=0;
@@ -102,10 +102,10 @@
     	    foreach ($scoes as $sco) {
     		if ($parents[$level]!=$sco->parent) {
     		    if ($level>0 && $parents[$level-1]==$sco->parent) {
-    			echo "  </ul>\n";
+    			echo "  </ul></li>\n";
     			$level--;
     		    } else {
-    			echo "  <ul id='".$sublist."' compact class=\"scormlist\"'>\n";
+    			echo "  <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
     			$level++;
     			$parents[$level]=$sco->parent;
     		    }
@@ -135,7 +135,7 @@
 		}
 	    }
 	    for ($i=0;$i<$level;$i++){
-	    	 echo "  </ul>\n";
+	    	 echo "  </ul></li>\n";
 	    }
 	}
 	echo "</ul></td></tr>\n";