Browse Source

Adding c_id in queries in newscorm - LP

Julio Montoya 13 years ago
parent
commit
d08c14510d

+ 15 - 5
main/exercice/exercice.php

@@ -138,6 +138,8 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp
 	exit;
 }
 
+$course_id = api_get_course_int_id();
+
 //Send student email @todo move this code in a class, library
 if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) {
 	$id 		= intval($_GET['exeid']); //filtered by post-condition    
@@ -147,7 +149,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
     }
 	$test 		       = $track_exercise_info['title'];
 	$student_id        = $track_exercise_info['exe_user_id'];
-    $course_id         = $track_exercise_info['exe_cours_id'];
+//    $course_id         = $track_exercise_info['exe_cours_id'];
     $session_id        = $track_exercise_info['session_id'];
     $lp_id             = $track_exercise_info['orig_lp_id'];
     $lp_item_id        = $track_exercise_info['orig_lp_item_id'];
@@ -965,13 +967,21 @@ if ($show == 'test') {
     if ($is_allowedToEdit) {
         $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
                 FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
-                WHERE   d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
-                AND   d.path  LIKE '" . Database :: escape_string($uploadPath) . "/%/%' LIMIT " .$from . "," .$limit; // only .htm or .html files listed
+                WHERE   d.c_id = $course_id AND
+                        ip.c_id = $course_id AND
+                        d.id = ip.ref AND 
+                        ip.tool = '" . TOOL_DOCUMENT . "' AND 
+                        (d.path LIKE '%htm%') AND 
+                        d.path  LIKE '" . Database :: escape_string($uploadPath) . "/%/%' 
+                        LIMIT " .$from . "," .$limit; // only .htm or .html files listed
     } else {
         $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
                 FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
-                WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
-                AND   d.path  LIKE '" . Database :: escape_string($uploadPath) . "/%/%' AND ip.visibility='1' LIMIT " .$from . "," .$limit;
+                WHERE d.c_id = $course_id AND
+                        ip.c_id = $course_id AND 
+                d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND (d.path LIKE '%htm%')
+                AND   d.path  LIKE '" . Database :: escape_string($uploadPath) . "/%/%' AND ip.visibility='1' 
+                LIMIT " .$from . "," .$limit;
     }
     
     $result = Database::query($sql);

+ 15 - 10
main/forum/forumfunction.inc.php

@@ -1183,7 +1183,7 @@ function get_forums($id='', $course_code = '') {
     $condition_session = api_get_session_condition($session_id);
     $course_id = $course_info['real_id'];
     
-    $condition_course .= " AND forum.c_id = $course_id";
+    $condition_course = " AND forum.c_id = $course_id";
 
     $forum_list = array();
     if ($id == '') {
@@ -1310,7 +1310,7 @@ function get_forums($id='', $course_code = '') {
     if ($id == '') {
         if (is_array($forum_list)) {
             foreach ($forum_list as $key => $value) {
-                $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit(), $course_db_name);
+                $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit(), $course_id);
                 $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
                 $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
                 $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
@@ -1322,7 +1322,7 @@ function get_forums($id='', $course_code = '') {
             $forum_list = array();
         }
     } else {
-        $last_post_info_of_forum = get_last_post_information($id, api_is_allowed_to_edit(), $course_db_name);
+        $last_post_info_of_forum = get_last_post_information($id, api_is_allowed_to_edit(), $course_id);
         $forum_list['last_post_id'] = $last_post_info_of_forum['last_post_id'];
         $forum_list['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
         $forum_list['last_post_date'] = $last_post_info_of_forum['last_post_date'];
@@ -1344,15 +1344,17 @@ function get_forums($id='', $course_code = '') {
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @version february 2006, dokeos 1.8
  */
-function get_last_post_information($forum_id, $show_invisibles = false, $course_db_name = '') {
-    if (!isset($course_db_name)) {
-        $course_db_name = '';
+function get_last_post_information($forum_id, $show_invisibles = false, $course_id = null) {
+    if (!isset($course_id)) {
+        $course_id = api_get_course_int_id();
+    } else {
+        $course_id = intval($course_id);
     }
 
-    $table_forums 			= Database :: get_course_table(TABLE_FORUM, $course_db_name);
-    $table_threads 			= Database :: get_course_table(TABLE_FORUM_THREAD, $course_db_name);
-    $table_posts 			= Database :: get_course_table(TABLE_FORUM_POST, $course_db_name);
-    $table_item_property 	= Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_db_name);
+    $table_forums 			= Database :: get_course_table(TABLE_FORUM);
+    $table_threads 			= Database :: get_course_table(TABLE_FORUM_THREAD);
+    $table_posts 			= Database :: get_course_table(TABLE_FORUM_POST);
+    $table_item_property 	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
     $table_users 			= Database :: get_main_table(TABLE_MAIN_USER);
 
     $sql = "SELECT post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname, post.visible, thread_properties.visibility AS thread_visibility, forum_properties.visibility AS forum_visibility
@@ -1363,6 +1365,9 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_
                 AND thread_properties.tool='".TOOL_FORUM_THREAD."'
                 AND post.forum_id=forum_properties.ref
                 AND forum_properties.tool='".TOOL_FORUM."'
+                AND post.c_id = $course_id AND 
+                thread_properties.c_id = $course_id AND
+                forum_properties.c_id = $course_id 
                 ORDER BY post.post_id DESC";
     $result = Database::query($sql);
 

+ 2 - 2
main/inc/lib/document.lib.php

@@ -2643,13 +2643,13 @@ return 'application/octet-stream';
     	require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
     	
     	$img_path 		= api_get_path(WEB_IMG_PATH);
-    	$img_sys_path 	= api_get_path(SYS_CODE_PATH).'img/';
+    	$img_sys_path 	= api_get_path(SYS_CODE_PATH).'img/';   
     	$web_code_path 	= api_get_path(WEB_CODE_PATH);
     	
     	$return = '';
     	if (count($resources_sorted) > 0) {
     		foreach ($resources_sorted as $key => $resource) {    	
-    			$title = $resource['title'];
+    			$title = isset($resource['title']) ? $resource['title'] : null;
     			if (empty($title)) {
     				$title = $key;
     			}

+ 1 - 1
main/mySpace/lp_tracking.php

@@ -109,7 +109,7 @@ $table_title = ($session_name? Display::return_icon('session.png', get_lang('Ses
 echo '<h2>'.$table_title.'</h2>';
 echo '<h3>'.Display::return_icon('learnpath.png', get_lang('ToolLearnpath'), array(), 22).' '.$lp_title.'</h3>';
     
-$list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $course_info['db_name']);
+$list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $course_info['real_id']);
 $origin = 'tracking';
 if ($export_csv) {
 	require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php';

File diff suppressed because it is too large
+ 134 - 115
main/newscorm/learnpath.class.php


+ 33 - 31
main/newscorm/learnpathItem.class.php

@@ -419,7 +419,7 @@ class learnpathItem {
 			$lp_iv_id = $row[0];
 			$iva_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
 			$iva_sql = "SELECT * FROM $iva_table " .
-							"WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id ";
+					   "WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id ";
 			$res_sql = Database::query($iva_sql);
 			while ($row = Database::fetch_array($res_sql)) {
 				$this->interactions[$row['interaction_id']] = array($row['interaction_id'], $row['interaction_type'], $row['weighting'], $row['completion_time'], $row['correct_responses'], $row['student_responses'], $row['result'], $row['latency']);
@@ -2034,7 +2034,8 @@ class learnpathItem {
 		$new_terms_string = implode(',', $new_terms);
 		$terms_update_sql = '';
 		// TODO: Validate csv string.
-		$terms_update_sql = "UPDATE $lp_item SET terms = '". Database::escape_string(api_htmlentities($new_terms_string, ENT_QUOTES, $charset)) . "' WHERE c_id = $course_id AND id=".$this->get_id();
+		$terms_update_sql = "UPDATE $lp_item SET terms = '". Database::escape_string(api_htmlentities($new_terms_string, ENT_QUOTES, $charset)) . "' 
+		                      WHERE c_id = $course_id AND id=".$this->get_id();
 		$res = Database::query($terms_update_sql);
 		// Save it to search engine.
 		if (api_get_setting('search_enabled') == 'true') {
@@ -2169,7 +2170,8 @@ class learnpathItem {
 	/**
      * Special scorm update time function. This function will update time directly into db for scorm objects
      **/
-    public function scorm_update_time($total_sec=0){
+    public function scorm_update_time($total_sec=0) {
+        $course_id = api_get_course_int_id();
         //Step 1 : get actual total time stored in db
         $item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
         
@@ -2259,7 +2261,7 @@ class learnpathItem {
 		 				$ivai_sql = "INSERT INTO $iva_table " .
 		 						"(c_id, lp_iv_id, order_id, objective_id, status, score_raw, score_min, score_max )" .
 		 						"VALUES" .
-		 						"($this->course_id, ".$lp_iv_id.", ".$index.",'".Database::escape_string($objective[0])."','".Database::escape_string($objective[1])."'," .
+		 						"($course_id, ".$lp_iv_id.", ".$index.",'".Database::escape_string($objective[0])."','".Database::escape_string($objective[1])."'," .
 		 						"'".Database::escape_string($objective[2])."','".Database::escape_string($objective[4])."','".Database::escape_string($objective[3])."')";
 		 				$ivai_res = Database::query($ivai_sql);
 		 				//error_log($ivai_sql);
@@ -2492,33 +2494,33 @@ class learnpathItem {
 
             
             if ($this->type == 'sco'){ //IF scorm scorm_update_time has already updated total_tim in db
-			     	$sql = "UPDATE $item_view_table " .
-			     			" SET ".//start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
-			     			" score = ".$this->get_score().", " .
-			     			$my_status.
-			     			" max_score = '".$this->get_max()."'," .
-			     			" suspend_data = '".Database::escape_string($this->current_data)."'," .
-			     			//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
-			     			" lesson_location = '".$this->lesson_location."' " .
-			     			"WHERE c_id = '.$course_id.' AND lp_item_id = ".$this->db_id." " .
-			     			"AND lp_view_id = ".$this->view_id." " .
-			     			"AND view_count = ".$this->attempt_id;
+		     	$sql = "UPDATE $item_view_table " .
+		     			" SET ".//start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
+		     			" score = ".$this->get_score().", " .
+		     			$my_status.
+		     			" max_score = '".$this->get_max()."'," .
+		     			" suspend_data = '".Database::escape_string($this->current_data)."'," .
+		     			//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
+		     			" lesson_location = '".$this->lesson_location."' " .
+		     			"WHERE c_id = $course_id AND lp_item_id = ".$this->db_id." " .
+		     			"AND lp_view_id = ".$this->view_id." " .
+		     			"AND view_count = ".$this->attempt_id;
             } else {
-				 	$sql = "UPDATE $item_view_table " .
-				 			"SET " .$total_time.
-				 			" start_time = ".$this->get_current_start_time().", " .
-				 			" score = ".$this->get_score().", " .
-				 			$my_status.
-				 			" max_score = '".$this->get_max()."'," .
-				 			" suspend_data = '".Database::escape_string($this->current_data)."'," .
-				 			//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
-				 			" lesson_location = '".$this->lesson_location."' " .
-				 			"WHERE c_id = '.$course_id.' AND lp_item_id = ".$this->db_id." " .
-				 			"AND lp_view_id = ".$this->view_id." " .
-				 			"AND view_count = ".$this->attempt_id;
+			 	$sql = "UPDATE $item_view_table " .
+			 			"SET " .$total_time.
+			 			" start_time = ".$this->get_current_start_time().", " .
+			 			" score = ".$this->get_score().", " .
+			 			$my_status.
+			 			" max_score = '".$this->get_max()."'," .
+			 			" suspend_data = '".Database::escape_string($this->current_data)."'," .
+			 			//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
+			 			" lesson_location = '".$this->lesson_location."' " .
+			 			"WHERE c_id = $course_id AND lp_item_id = ".$this->db_id." " .
+			 			"AND lp_view_id = ".$this->view_id." " .
+			 			"AND view_count = ".$this->attempt_id;
             }
 
-				 	$this->current_start_time = time();
+			 	$this->current_start_time = time();
 		 		}
 			 	if (self::debug > 2) { error_log('New LP - In learnpathItem::write_to_db() - Updating item_view: '.$sql, 0); }
 			 	$res = Database::query($sql);
@@ -2531,7 +2533,7 @@ class learnpathItem {
 		 		// Save interactions.
 		 		$tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 		 		$sql = "SELECT id FROM $tbl " .
-		 				"WHERE c_id = '.$course_id.' AND lp_item_id = ".$this->db_id." " .
+		 				"WHERE c_id = $course_id AND lp_item_id = ".$this->db_id." " .
 		 				"AND   lp_view_id = ".$this->view_id." " .
 		 				"AND   view_count = ".$this->attempt_id;
 		 		$res = Database::query($sql);
@@ -2549,7 +2551,7 @@ class learnpathItem {
 			 			}
 			 			$iva_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
 			 			$iva_sql = "SELECT id FROM $iva_table " .
-			 					"WHERE c_id = '.$course_id.' AND lp_iv_id = $lp_iv_id " .
+			 					"WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id " .
 //			 					"AND order_id = $index";
 								//also check for the interaction ID as it must be unique for this SCO view
 			 					"AND (order_id = $index " .
@@ -2569,7 +2571,7 @@ class learnpathItem {
 			 					"student_response = '".Database::escape_string($interaction[5])."'," .
 			 					"result = '".Database::escape_string($interaction[6])."'," .
 			 					"latency = '".Database::escape_string($interaction[7])."'" .
-			 					"WHERE c_id = '.$course_id.' AND id = $iva_id";
+			 					"WHERE c_id = $course_id AND id = $iva_id";
 			 				$ivau_res = Database::query($ivau_sql);
 			 			} else {
 			 				// Insert new one.

+ 10 - 14
main/newscorm/learnpathList.class.php

@@ -31,18 +31,14 @@ class learnpathList {
      * @return	void
      */
     function __construct($user_id, $course_code = '', $session_id = null, $order_by = null) {
-
-        if (!empty($course_code)){
-            $course_info = api_get_course_info($course_code);
-            $lp_table = Database::get_course_table(TABLE_LP_MAIN, $course_info['db_name']);
-            $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST, $course_info['db_name']);
-        } else {
-            $course_code = api_get_course_id();
-            $lp_table = Database::get_course_table(TABLE_LP_MAIN);
-            $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
-        }
-        $this->course_code = $course_code;
+        $course_info = api_get_course_info($course_code);
+        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
+                
+        $this->course_code = $course_code;        
         $this->user_id = $user_id;
+        
+        $course_id = $course_info['real_id'];
 
         // Condition for the session.
         if (isset($session_id)) {
@@ -50,12 +46,12 @@ class learnpathList {
         } else {
             $session_id = api_get_session_id();
         }
-        $condition_session = api_get_session_condition($session_id, false, true);
+        $condition_session = api_get_session_condition($session_id, true, true);
         $order = "ORDER BY display_order ASC, name ASC";
         if (isset($order_by)) {
             $order =  Database::parse_conditions(array('order'=>$order_by));            
         }
-        $sql = "SELECT * FROM $lp_table $condition_session $order";
+        $sql = "SELECT * FROM $lp_table WHERE c_id = $course_id $condition_session $order";
         $res = Database::query($sql);
         $names = array();
         while ($row = Database::fetch_array($res,'ASSOC')) {
@@ -66,7 +62,7 @@ class learnpathList {
             // is done using domesticate()
             $myname = domesticate($row['name']);
             $mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row['id'].'&id_session='.$session_id;
-            $sql2="SELECT * FROM $tbl_tool where (name='$myname' and image='scormbuilder.gif' and link LIKE '$mylink%')";
+            $sql2="SELECT * FROM $tbl_tool WHERE c_id = $course_id AND (name='$myname' and image='scormbuilder.gif' and link LIKE '$mylink%')";
             //error_log('New LP - learnpathList::__construct - getting visibility - '.$sql2, 0);
             $res2 = Database::query($sql2);
             if (Database::num_rows($res2) > 0) {

+ 8 - 6
main/newscorm/lp_comm.server.php

@@ -139,11 +139,12 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
         return $objResponse;
     }
 
-    $mystatus = $mylpi->get_status(false);
-    $mytotal = $mylp->get_total_items_count_without_chapters();
-    $mycomplete = $mylp->get_complete_items_count();
-    $myprogress_mode = $mylp->get_progress_bar_mode();
-    $myprogress_mode = ($myprogress_mode == '' ? '%' : $myprogress_mode);
+    $mystatus           = $mylpi->get_status(false);
+    $mytotal            = $mylp->get_total_items_count_without_chapters();
+    $mycomplete         = $mylp->get_complete_items_count();
+    $myprogress_mode    = $mylp->get_progress_bar_mode();
+    $myprogress_mode    = ($myprogress_mode == '' ? '%' : $myprogress_mode);
+    
     //$mylpi->write_to_db();
     $_SESSION['lpobject'] = serialize($mylp);
     if ($mylpi->get_type()!='sco'){
@@ -169,7 +170,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
 
         $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
 
-        $sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='".api_get_user_id()."' ORDER BY login_date DESC LIMIT 0,1";
+        $sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login 
+                                WHERE login_user_id='".api_get_user_id()."' ORDER BY login_date DESC LIMIT 0,1";
 
         $q_last_connection = Database::query($sql_last_connection);
         if (Database::num_rows($q_last_connection) > 0) {

+ 4 - 2
main/newscorm/lp_controller.php

@@ -121,6 +121,8 @@ if (isset($_SESSION['lpobject'])) {
     }
 }
 
+$course_id = api_get_course_int_id();
+
 if ($debug>0) error_log('New LP - Passed data remains check', 0);
 
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
@@ -138,7 +140,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
         }
         if (is_numeric($lp_id)) {
             $lp_id = Database::escape_string($lp_id);
-            $sel = "SELECT * FROM $lp_table WHERE id = $lp_id";
+            $sel = "SELECT * FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
 
             if ($debug > 0) error_log('New LP - querying '.$sel, 0);
             $res = Database::query($sel);
@@ -325,7 +327,7 @@ switch ($action) {
 
     case 'build':
         if (!$is_allowed_to_edit) {
-            api_not_allowed(true);
+            api_not_allowed(true);  
         }
         if ($debug > 0) error_log('New LP - build action triggered', 0);
 

+ 1 - 1
main/newscorm/lp_edit.php

@@ -54,7 +54,7 @@ Display::display_header(get_lang('CourseSettings'), 'Path');
 
 // Action links
 echo '<div class="actions">';
-$gradebook = Security::remove_XSS($_GET['gradebook']);
+$gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null;
 echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=build&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang('Build').'">'.Display::return_icon('build_learnpath.png', get_lang('Build'),'','32').'</a>';
 echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=admin_view&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang('BasicOverview').'">'.Display::return_icon('move_learnpath.png', get_lang('BasicOverview'),'','32').'</a>';
 echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=view&lp_id='.Security::remove_XSS($_GET['lp_id']).'">'.Display::return_icon('view_remove.png', get_lang('Display'),'','32').'</a>';

+ 6 - 9
main/newscorm/lp_stats.php

@@ -16,12 +16,13 @@ require_once 'resourcelinker.inc.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 require_once '../exercice/exercise.lib.php';
 
-$course_id = api_get_course_id();
-if (empty($course_id ) && isset($_GET['course'])) {
+$course_code = api_get_course_id();
+if (isset($_GET['course'])) {
     $course_code = Security::remove_XSS($_GET['course']);    
-} else {
-    $course_code = $course_id;
-}
+} 
+
+$course_info = api_get_course_info($course_code);
+$course_id = $course_info['real_id']; 
 
 if (isset($_GET['student_id'])) {
     $student_id = intval($_GET['student_id']);
@@ -82,10 +83,6 @@ $output .= '<tr><td><table border="0" class="data_table"><tr>'.
 // we get them in the same order as in the imsmanifest file, which is rather random when using
 // the database table.
 
-$course_info            = api_get_course_info($course_code);
-
-$course_id = $course_info['real_id']; 
-
 $TBL_LP_ITEM            = Database :: get_course_table(TABLE_LP_ITEM);
 $TBL_LP_ITEM_VIEW       = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
 $TBL_LP_VIEW            = Database :: get_course_table(TABLE_LP_VIEW);

+ 8 - 7
main/newscorm/lp_view.php

@@ -35,6 +35,7 @@ if (!$is_allowed_in_course) api_not_allowed();
 
 $oLearnpath     = false;
 $course_code    = api_get_course_id();
+$course_id      = api_get_course_int_id();
 $user_id        = api_get_user_id();
 $platform_theme = api_get_setting('stylesheets'); // Plataform's css.
 $my_style       = $platform_theme;
@@ -172,8 +173,7 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
     $safe_item_id           = Database::escape_string($_GET['lp_item_id']);
     $safe_id                = $lp_id;
     $safe_exe_id            = intval($_REQUEST['exeId']);
-    $course_id 				= api_get_course_int_id();
-
+    
     if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) {
 		
         $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
@@ -187,7 +187,7 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
         $score 		= (float)$row_dates['exe_result'];
         $max_score 	= (float)$row_dates['exe_weighting'];
         
-        $sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE id = '".(int)$safe_item_id."'";
+        $sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE c_id = $course_id AND id = '".(int)$safe_item_id."'";
         if ($debug) error_log($sql_upd_max_score);
         Database::query($sql_upd_max_score);
 
@@ -197,7 +197,8 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
         if (Database::num_rows($res_last_attempt)) {
         	$row_last_attempt = Database::fetch_row($res_last_attempt);
         	$lp_item_view_id  = $row_last_attempt[0];
-            $sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score, total_time = $mytime WHERE id='".$lp_item_view_id."' AND c_id = $course_id ";
+            $sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score, total_time = $mytime 
+                              WHERE id='".$lp_item_view_id."' AND c_id = $course_id ";
             if ($debug) error_log($sql_upd_score);
             Database::query($sql_upd_score);
 
@@ -232,8 +233,8 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
 require_once '../inc/reduced_header.inc.php';
 //$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false;
 // Check if audio recorder needs to be in studentview.
-$course_id = $_SESSION['_course']['id'];
-if ($_SESSION['status'][$course_id] == 5) {
+//$course_id = $_SESSION['_course']['id'];
+if ($_SESSION['status'][$course_code] == 5) {
 	$audio_recorder_studentview = true;
 } else {
 	$audio_recorder_studentview = false;
@@ -314,7 +315,7 @@ if ($_SESSION['oLP']->mode == 'embedframe' ||$_SESSION['oLP']->get_hide_toc_fram
                         $tbl_lp_item    = Database::get_course_table(TABLE_LP_ITEM);
                         $show_audioplayer = false;
                         // Getting all the information about the item.
-                        $sql = "SELECT audio FROM " . $tbl_lp_item . " WHERE lp_id = '" . $_SESSION['oLP']->lp_id."'";
+                        $sql = "SELECT audio FROM " . $tbl_lp_item . " WHERE c_id = $course_id AND lp_id = '" . $_SESSION['oLP']->lp_id."'";
                         $res_media= Database::query($sql);
 
                         if (Database::num_rows($res_media) > 0) {

Some files were not shown because too many files changed in this diff