Quellcode durchsuchen

[svn r19538] Logic change - Force to get the first learnpath item id when you display it - partial FS#3909

Cristian Fasanando vor 16 Jahren
Ursprung
Commit
d3a401e9ec
3 geänderte Dateien mit 34 neuen und 4 gelöschten Zeilen
  1. 16 0
      main/newscorm/learnpath.class.php
  2. 2 2
      main/newscorm/lp_controller.php
  3. 16 2
      main/newscorm/lp_view.php

+ 16 - 0
main/newscorm/learnpath.class.php

@@ -1462,6 +1462,22 @@ class learnpath {
 		if($this->debug>2){error_log('New LP - In learnpath::get_current_item_id() - Returning '.$current,0);}
     	return $current;
     }
+    
+    
+     /** Force to get the first learnpath item id
+     * @return	integer	The current learnpath item id
+     */
+    function get_first_item_id()
+    {
+		$current = 0;
+		if (is_array($this->ordered_items)) {
+			$current = $this->ordered_items[0];
+		}
+    	return $current;
+    }
+    
+    
+    
     /**
      * Gets the total number of items available for viewing in this SCORM
      * @return	integer	The total number of items

+ 2 - 2
main/newscorm/lp_controller.php

@@ -724,10 +724,10 @@ switch($action)
 		else
 		{			
 			if($debug > 0){error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0);}
-			if ( !empty($_REQUEST['item_id']) )
+			/*if ( !empty($_REQUEST['item_id']) )
             {
                 $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
-            }            
+            }*/            
 			require('lp_view.php');
 		}
 		break;		

+ 16 - 2
main/newscorm/lp_view.php

@@ -79,9 +79,23 @@ $htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript">
 
 $_SESSION['oLP']->error = '';
 $lp_type = $_SESSION['oLP']->get_type();
-$lp_item_id = $_SESSION['oLP']->get_current_item_id();
+
+if (api_is_anonymous()) {
+		$lp_item_id = $_SESSION['oLP']->get_first_item_id();
+		if ( $lp_item_id != 0)
+			$_SESSION['oLP']->set_current_item($lp_item_id); // already done by lp_controller.php
+		else 
+ 			$lp_item_id = $_SESSION['oLP']->get_current_item_id();
+
+	} else {
+		//$lp_item_id = $_SESSION['oLP']->get_current_item_id();
+		$lp_item_id = $_SESSION['oLP']->get_first_item_id();	
+	}
+	
+//$lp_item_id = $_SESSION['oLP']->get_current_item_id();
+
 //$lp_item_id = learnpath::escape_string($_GET['item_id']);
-//$_SESSION['oLP']->set_current_item($lp_item_id); // already done by lp_controller.php
+$_SESSION['oLP']->set_current_item($lp_item_id); // already done by lp_controller.php
 
 //Prepare variables for the test tool (just in case) - honestly, this should disappear later on
 $_SESSION['scorm_view_id'] = $_SESSION['oLP']->get_view_id();