소스 검색

Bug #1370 - Before going further, cleaning code first. Clarification of using constants for selecting database tables. Replacing everywhere hardcoded database names with the corresponding constants.

Ivan Tcholakov 15 년 전
부모
커밋
e27f8ea601
38개의 변경된 파일215개의 추가작업 그리고 209개의 파일을 삭제
  1. 2 2
      main/announcements/announcements.inc.php
  2. 2 2
      main/announcements/announcements.php
  3. 5 5
      main/auth/my_progress.php
  4. 1 1
      main/exercice/answer.class.php
  5. 4 4
      main/forum/forumfunction.inc.php
  6. 1 1
      main/gradebook/lib/be/forumthreadlink.class.php
  7. 14 8
      main/inc/lib/database.lib.php
  8. 24 24
      main/inc/lib/surveymanager.lib.php
  9. 1 1
      main/metadata/importmanifest.php
  10. 1 1
      main/metadata/md_funcs.php
  11. 1 1
      main/metadata/md_scorm.php
  12. 3 3
      main/mySpace/myStudents.php
  13. 8 8
      main/newscorm/aicc.class.php
  14. 57 57
      main/newscorm/learnpath.class.php
  15. 18 18
      main/newscorm/learnpathItem.class.php
  16. 1 1
      main/newscorm/learnpathList.class.php
  17. 5 5
      main/newscorm/learnpath_functions.inc.php
  18. 3 3
      main/newscorm/lp_add.php
  19. 3 3
      main/newscorm/lp_add_item.php
  20. 5 5
      main/newscorm/lp_admin_view.php
  21. 3 3
      main/newscorm/lp_build.php
  22. 1 1
      main/newscorm/lp_controller.php
  23. 3 3
      main/newscorm/lp_edit_item.php
  24. 3 3
      main/newscorm/lp_edit_item_prereq.php
  25. 3 3
      main/newscorm/lp_move_item.php
  26. 4 4
      main/newscorm/lp_stats.php
  27. 2 2
      main/newscorm/lp_view.php
  28. 3 3
      main/newscorm/lp_view_item.php
  29. 4 4
      main/newscorm/resourcelinker.inc.php
  30. 2 2
      main/newscorm/resourcelinker.php
  31. 9 9
      main/newscorm/scorm.class.php
  32. 1 1
      main/survey/reporting.php
  33. 1 1
      main/survey/survey.php
  34. 1 1
      main/survey/survey_invite.php
  35. 1 1
      main/tracking/courseLog.php
  36. 5 5
      main/tracking/courseLogCSV.php
  37. 5 5
      main/tracking/userLog.php
  38. 5 5
      main/tracking/userlogCSV.php

+ 2 - 2
main/announcements/announcements.inc.php

@@ -44,8 +44,8 @@ function display_announcement($announcement_id)
 	
 	if ($announcement_id != strval(intval($announcement_id))) { return false; } // potencial sql injection
 	
-	$tbl_announcement 	= Database::get_course_table('announcement');
-	$tbl_item_property	= Database::get_course_table('item_property');
+	$tbl_announcement 	= Database::get_course_table(TABLE_ANNOUNCEMENT);
+	$tbl_item_property	= Database::get_course_table(TABLE_ITEM_PROPERTY);
 	
 	if ($_user['user_id'])
 	{

+ 2 - 2
main/announcements/announcements.php

@@ -590,7 +590,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 							$res_date=api_sql_query($sql_date, __FILE__, __LINE__);
 							$obj_date=Database::fetch_object($res_date);
 							$end_date=$obj_date->avail_till;
-							$table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
+							$table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
 							if ($_REQUEST['reminder']=="1") {
 								$time=getdate();
 								$time = $time['yday'];
@@ -737,7 +737,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
 							$res_date=api_sql_query($sql_date, __FILE__, __LINE__);
 							$obj_date=Database::fetch_object($res_date);
 							$end_date=$obj_date->avail_till;
-							$table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
+							$table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
 							
 							if ($_REQUEST['reminder']=="1") {
 								$time=getdate();

+ 5 - 5
main/auth/my_progress.php

@@ -27,11 +27,11 @@ $tbl_session_course 		= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session_course_user 	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 $tbl_stats_lastaccess 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
 $tbl_stats_exercices 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-$tbl_course_lp_view 		= Database :: get_course_table('lp_view');
-$tbl_course_lp_view_item 	= Database :: get_course_table('lp_item_view');
-$tbl_course_lp 				= Database :: get_course_table('lp');
-$tbl_course_lp_item 		= Database :: get_course_table('lp_item');
-$tbl_course_quiz 			= Database :: get_course_table('quiz');
+$tbl_course_lp_view 		= Database :: get_course_table(TABLE_LP_VIEW);
+$tbl_course_lp_view_item 	= Database :: get_course_table(TABLE_LP_ITEM_VIEW);
+$tbl_course_lp 				= Database :: get_course_table(TABLE_LP_MAIN);
+$tbl_course_lp_item 		= Database :: get_course_table(TABLE_LP_ITEM);
+$tbl_course_quiz 			= Database :: get_course_table(TABLE_QUIZ_TEST);
 
 
 // get course list

+ 1 - 1
main/exercice/answer.class.php

@@ -156,7 +156,7 @@ class Answer
 		{
 			$order = 'ASC';
 		}
-		$TBL_ANSWER = Database::get_course_table('quiz_answer');
+		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 		$questionId=$this->questionId;
 		//$answerType=$this->selectType();

+ 4 - 4
main/forum/forumfunction.inc.php

@@ -2828,7 +2828,7 @@ function send_notification_mails($thread_id, $reply_info) {
 		$sql="SELECT * FROM $table_posts WHERE thread_id='".Database::escape_string($thread_id)."' AND post_notification='1'";
 		$result=api_sql_query($sql, __LINE__, __FILE__);
 		*/
-		$table_notification = Database::get_course_table('forum_notification');
+		$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
 		$sql = "SELECT * FROM $table_notification WHERE forum_id = '".Database::escape_string($current_forum['forum_id'])."' OR thread_id = '".Database::escape_string($thread_id)."'";
 		$result=api_sql_query($sql, __FILE__, __LINE__);
 		while ($row=Database::fetch_array($result)) {
@@ -3595,7 +3595,7 @@ function set_notification($content,$id, $add_only = false) {
 	}
 	
 	// database table definition
-	$table_notification = Database::get_course_table('forum_notification');
+	$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
 	
 	// first we check if the notification is already set for this
 	$sql = "SELECT * FROM $table_notification WHERE $database_field = '".Database::escape_string($id)."' AND user_id = '".Database::escape_string($_user['user_id'])."'";
@@ -3642,7 +3642,7 @@ function get_notifications($content,$id) {
 		$database_field = 'thread_id';
 	}
 	// database table definition
-	$table_notification = Database::get_course_table('forum_notification');
+	$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
 	$sql = "SELECT user.user_id, user.firstname, user.lastname, user.email, user.user_id user FROM $table_users user, $table_notification notification
 			WHERE user.user_id = notification.user_id
 			AND notification.$database_field= '".Database::escape_string($id)."'";
@@ -3737,7 +3737,7 @@ function get_notifications_of_user($user_id = 0, $force = false) {
 	}
 	
 	// database table definition
-	$table_notification = Database::get_course_table('forum_notification');
+	$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
 	$my_code = isset($_course['code']) ? $_course['code'] : '';
 	if (!isset($_SESSION['forum_notification']) OR $_SESSION['forum_notification']['course'] <> $my_code OR $force=true) {
 		$_SESSION['forum_notification']['course'] = $my_code;

+ 1 - 1
main/gradebook/lib/be/forumthreadlink.class.php

@@ -125,7 +125,7 @@ class ForumThreadLink extends AbstractLink
 	    	$course_info = Database :: get_course_info($this->get_course_code());
 			$database_name = (empty($course_info['db_name']))?$course_info['dbName']:$course_info['db_name'];
 			if ($database_name!="") {
-			$thread_qualify = Database :: get_course_table('forum_thread_qualify', $database_name);
+			$thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY, $database_name);
 			
 	  		$sql = 'SELECT thread_qualify_max FROM '.Database :: get_course_table(TABLE_FORUM_THREAD, $database_name)." WHERE thread_id = '".$this->get_ref_id()."'";
 			$query = api_sql_query($sql,__FILE__,__LINE__);

+ 14 - 8
main/inc/lib/database.lib.php

@@ -83,21 +83,21 @@ define('TABLE_MAIN_RESERVATION_CATEGORY', 'reservation_category');
 define('TABLE_MAIN_RESERVATION_ITEM_RIGHTS', 'reservation_item_rights');
 
 // Social networking
-define('TABLE_MAIN_USER_FRIEND','user_friend');
+define('TABLE_MAIN_USER_FRIEND', 'user_friend');
 define('TABLE_MAIN_USER_FRIEND_RELATION_TYPE', 'user_friend_relation_type');
 
 // Web services
-define('TABLE_MAIN_USER_API_KEY','user_api_key');
+define('TABLE_MAIN_USER_API_KEY', 'user_api_key');
 define('TABLE_MAIN_COURSE_FIELD',			'course_field');
 define('TABLE_MAIN_COURSE_FIELD_VALUES',	'course_field_values');
 define('TABLE_MAIN_SESSION_FIELD',			'session_field');
 define('TABLE_MAIN_SESSION_FIELD_VALUES',	'session_field_values');
 
 // Message
-define('TABLE_MAIN_MESSAGE','message');
+define('TABLE_MAIN_MESSAGE', 'message');
 
 // Term and conditions
-define('TABLE_MAIN_LEGAL','legal');
+define('TABLE_MAIN_LEGAL', 'legal');
 
 // Statistic database tables
 define('TABLE_STATISTIC_TRACK_E_LASTACCESS', 'track_e_lastaccess');
@@ -123,7 +123,7 @@ define('TABLE_SCORM_SCO_DATA', 'scorm_sco_data');
 define('TABLE_AGENDA', 'calendar_event');
 define('TABLE_AGENDA_REPEAT', 'calendar_event_repeat');
 define('TABLE_AGENDA_REPEAT_NOT', 'calendar_event_repeat_not');
-define('TABLE_AGENDA_ATTACHMENT','calendar_event_attachment');
+define('TABLE_AGENDA_ATTACHMENT', 'calendar_event_attachment');
 define('TABLE_ANNOUNCEMENT', 'announcement');
 define('TABLE_CHAT_CONNECTED', 'chat_connected'); // @todo: probably no longer in use !!!
 define('TABLE_COURSE_DESCRIPTION', 'course_description');
@@ -219,17 +219,20 @@ define('TABLE_PERSONAL_AGENDA_REPEAT_NOT', 'personal_agenda_repeat_not');
 define('TABLE_USER_COURSE_CATEGORY', 'user_course_category');
 
 // Survey
-// @todo: are these MAIN tables or course tables ?
+// @TODO: Are these MAIN tables or course tables?
+// @TODO: Probably these constants are obsolete.
 define('TABLE_MAIN_SURVEY', 'survey');
 define('TABLE_MAIN_GROUP', 'survey_group');
 define('TABLE_MAIN_SURVEYQUESTION', 'questions');
+
 // Survey
 define('TABLE_SURVEY', 'survey');
 define('TABLE_SURVEY_QUESTION', 'survey_question');
 define('TABLE_SURVEY_QUESTION_OPTION', 'survey_question_option');
 define('TABLE_SURVEY_INVITATION', 'survey_invitation');
 define('TABLE_SURVEY_ANSWER', 'survey_answer');
-define('TABLE_SURVEY_QUESTION_GROUP','survey_group');
+define('TABLE_SURVEY_QUESTION_GROUP', 'survey_group');
+define('TABLE_SURVEY_REPORT', 'survey_report');
 
 // Wiki tables
 define('TABLE_WIKI', 'wiki');
@@ -244,7 +247,10 @@ define('TABLE_GLOSSARY', 'glossary');
 define('TABLE_NOTEBOOK', 'notebook');
 
 // Message
-define('TABLE_MESSAGE', 'message'); 
+define('TABLE_MESSAGE', 'message');
+
+// Metadata
+define('TABLE_METADATA', 'metadata');
 
 
 /*

+ 24 - 24
main/inc/lib/surveymanager.lib.php

@@ -39,7 +39,7 @@ class SurveyManager {
 	  * Possible  deprecated method
 	  */
 	public static function select_survey_list ($seleced_surveyid='', $extra_script='') {
-		$survey_table = Database :: get_course_table('survey');
+		$survey_table = Database :: get_course_table(TABLE_SURVEY);
 		$sql = "SELECT * FROM $survey_table";// WHERE is_shared='1'";
 		$sql_result = api_sql_query($sql,__FILE__,__LINE__);
 		if(mysql_num_rows($sql_result)>0)
@@ -123,7 +123,7 @@ class SurveyManager {
 	 */
 	function get_author($db_name,$survey_id)
 	{
-	    //$table_survey = Database :: get_course_table('survey');
+	    //$table_survey = Database :: get_course_table(TABLE_SURVEY);
 	    $survey_id = Database::escape_string($survey_id);
 		$sql = "SELECT author FROM $db_name.survey WHERE survey_id='$survey_id'";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
@@ -135,7 +135,7 @@ class SurveyManager {
 	 */
 	function get_surveyid($db_name,$group_id)
 	{
-	    //$group_table = Database :: get_course_table('survey_group');
+	    //$group_table = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 	    $group_id = Database::escape_string($group_id);
 		$sql = "SELECT survey_id FROM $db_name.survey_group WHERE group_id='$group_id'";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
@@ -144,7 +144,7 @@ class SurveyManager {
 	}
 
 	public static function get_groupname ($db_name,$gid) {
-		//$grouptable = Database :: get_course_table('survey_group');
+		//$grouptable = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 		$gid = Database::escape_string($gid);
 		$sql = "SELECT * FROM $db_name.survey_group WHERE group_id='$gid'";
 		$res=api_sql_query($sql);
@@ -183,7 +183,7 @@ class SurveyManager {
 	 */
 	function get_survey_list()
 	{
-		$survey_table = Database :: get_course_table('survey');
+		$survey_table = Database :: get_course_table(TABLE_SURVEY);
 		$sql_query = "SELECT survey_id,title FROM $survey_table where title!='' ";
 		$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
 		echo "<select name=\"author\">";
@@ -199,7 +199,7 @@ class SurveyManager {
 	 */
 	function create_survey ($surveycode,$surveytitle, $surveysubtitle, $author, $survey_language, $availablefrom, $availabletill,$isshare, $surveytemplate, $surveyintroduction, $surveythanks, $table_survey, $table_group)
 		{
-			//$table_survey = Database :: get_course_table('survey');
+			//$table_survey = Database :: get_course_table(TABLE_SURVEY);
 			$sql = "INSERT INTO $table_survey (code,title, subtitle, author,lang,avail_from,avail_till, is_shared,template,intro,surveythanks,creation_date) values('$surveycode','$surveytitle','$surveysubtitle','$author','$survey_language','$availablefrom','$availabletill','$isshare','$surveytemplate','$surveyintroduction','$surveythanks',curdate())";
 			$result = api_sql_query($sql, __FILE__, __LINE__);
 			//$result = api_sql_query($sql);
@@ -248,7 +248,7 @@ class SurveyManager {
 	 */
 	function create_survey_attach($surveycode,$surveytitle, $surveysubtitle, $author, $survey_language, $availablefrom, $availabletill,$isshare, $surveytemplate, $surveyintroduction, $surveythanks, $table_survey, $table_group)
 	{
-			//$table_survey = Database :: get_course_table('survey');
+			//$table_survey = Database :: get_course_table(TABLE_SURVEY);
 			$sql = "INSERT INTO $table_survey (code,title, subtitle, author,lang,avail_from,avail_till, is_shared,template,intro,surveythanks,creation_date) values('$surveycode','$surveytitle','$surveysubtitle','$author','$survey_language','$availablefrom','$availabletill','$isshare','$surveytemplate','$surveyintroduction','$surveythanks',curdate())";
 			$result = api_sql_query($sql, __FILE__, __LINE__);
 			$survey_id = mysql_insert_id();
@@ -380,7 +380,7 @@ class SurveyManager {
 	 */
 	 function get_question_type($questionid)
 	 {
-	  $table_question = Database :: get_course_table('questions');
+	  $table_question = Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
 	  $questionid = Database::escape_string($questionid);
 	  $sql = "SELECT * FROM $table_question WHERE qid='$questionid'";
 			$res=api_sql_query($sql);
@@ -393,7 +393,7 @@ class SurveyManager {
 	 */
 	 function no_of_question($db_name,$gid)
 	 {
-	  //$table_question = Database :: get_course_table('questions');
+	  //$table_question = Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
 	  $gid = Database::escape_string($gid);
 	  $sql = "SELECT * FROM $db_name.questions WHERE gid='$gid'";
 			$res=api_sql_query($sql);
@@ -444,7 +444,7 @@ class SurveyManager {
 	 */
 	function get_surveyname($db_name,$sid)
 	{
-			//$surveytable=Database:: get_course_table('survey');
+			//$surveytable=Database:: get_course_table(TABLE_SURVEY);
 			$sid = Database::escape_string($sid);
 			$sql="SELECT * FROM $db_name.survey WHERE survey_id=$sid";
 			$res=api_sql_query($sql);
@@ -457,7 +457,7 @@ class SurveyManager {
 	function get_surveyname_display($sid)
 	{
 			$sid = Database::escape_string($sid);
-			$surveytable=Database:: get_course_table('survey');
+			$surveytable=Database:: get_course_table(TABLE_SURVEY);
 			$sql="SELECT * FROM $surveytable WHERE survey_id=$sid";
 			$res=api_sql_query($sql);
 			$code=@mysql_result($res,0,'title');
@@ -498,7 +498,7 @@ class SurveyManager {
 
 				}
 			}
-			$table_question = Database :: get_course_table('questions');
+			$table_question = Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
 			if(isset($selected_group)){
 			 if($selected_group!=''){
 			  $sql = "SELECT $table_group('survey_id', 'groupname') values('$sid', '$groupname')";
@@ -524,9 +524,9 @@ class SurveyManager {
 	 */
 	function delete_survey($survey_id)
 	{
-		$table_survey 	= Database :: get_course_table('survey');
-		$table_group 	= Database :: get_course_table('survey_group');
-		$table_question = Database :: get_course_table('questions');
+		$table_survey 	= Database :: get_course_table(TABLE_SURVEY);
+		$table_group 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
+		$table_question = Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
 
 		$survey_id = Database::escape_string($survey_id);
 		
@@ -562,8 +562,8 @@ class SurveyManager {
 	{
 		// Database table definitions
 		/** @todo use database constants for the survey tables */
-		$table_question 	= Database :: get_course_table('questions');
-		$table_survey_group = Database :: get_course_table('survey_group');
+		$table_question 	= Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
+		$table_survey_group = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 
 		$sql = "DELETE FROM $table_question WHERE gid='".$group_id."'";
 		api_sql_query($sql,__FILE__,__LINE__);
@@ -576,7 +576,7 @@ class SurveyManager {
 	 */
 	function ques_id_group_name($qid)
 	{
-		$ques_table=Database::get_course_table('questions');
+		$ques_table=Database::get_course_table(TABLE_MAIN_SURVEYQUESTION);
 		$sql="SELECT gid FROM $ques_table where qid=$qid";
 		$res=api_sql_query($sql);
 		$id=@mysql_result($res,0,'gid');
@@ -604,7 +604,7 @@ class SurveyManager {
 	 */
 	function select_group_list($survey_id, $seleced_groupid='', $extra_script='')
 	{
-		$group_table = Database :: get_course_table('survey_group');
+		$group_table = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 		$sql = "SELECT * FROM $group_table WHERE survey_id='$survey_id'";
 		$sql_result = api_sql_query($sql,__FILE__,__LINE__);
 		if(mysql_num_rows($sql_result)>0)
@@ -1336,7 +1336,7 @@ function insert_existing_groups ($sid,$gids,$table_group,$table_question)
 	 */
  function pick_surveyname($sid)
 		{
-			$surveytable=Database:: get_course_table('survey');
+			$surveytable=Database:: get_course_table(TABLE_SURVEY);
 			$sql="SELECT * FROM $surveytable WHERE survey_id=$sid";
 			$res=api_sql_query($sql);
 			$code=@mysql_result($res,0,'title');
@@ -1347,7 +1347,7 @@ function insert_existing_groups ($sid,$gids,$table_group,$table_question)
 	 */
 function pick_author($survey_id)
 	{
-	    $survey_table = Database :: get_course_table('survey');
+	    $survey_table = Database :: get_course_table(TABLE_SURVEY);
 		$sql = "SELECT author FROM $survey_table WHERE survey_id='$survey_id'";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		$author=@mysql_result($res,0,'author');
@@ -1679,7 +1679,7 @@ function get_questions_move($curr_dbname)
  */
 function listGroups($id_survey, $fields = '*')
 {
-	$groups_table = Database :: get_course_table(TABLE_MAIN_GROUP);
+	$groups_table = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 	$sql = 'SELECT '.$fields.' FROM '.$groups_table.'
 			WHERE survey_id='.$id_survey.' ORDER BY sortby';
 	$rs = api_sql_query($sql, __FILE__, __LINE__);
@@ -1696,7 +1696,7 @@ function listQuestions($id_survey, $fields = '*')
 {
 
 	$questions_table = Database :: get_course_table(TABLE_MAIN_SURVEYQUESTION);
-	$groups_table = Database :: get_course_table('survey_group');
+	$groups_table = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 
 	$sql = 'SELECT '.$fields.'
 			FROM '.$questions_table.' questions
@@ -1720,7 +1720,7 @@ function listQuestions($id_survey, $fields = '*')
  */
 function listAnswers($qid){
 
-	$answers_table = Database :: get_course_table('survey_report');
+	$answers_table = Database :: get_course_table(TABLE_SURVEY_REPORT);
 
 	$sql = 'SELECT DISTINCT answer FROM '.$answers_table.'
 			WHERE qid='.$qid;

+ 1 - 1
main/metadata/importmanifest.php

@@ -59,7 +59,7 @@ require('md_phpdig.php');
 
 if (isset($workWith))  // explicit in URL, or selected at bottom of screen
 {
-    $scormdocument = Database::get_course_table('lp');
+    $scormdocument = Database::get_course_table(TABLE_LP_MAIN);
     $sql = "SELECT id FROM $scormdocument WHERE path='". Database::escape_string(api_substr($workWith,1)) . "' OR path='". Database::escape_string(substr($workWith,1)) . "/.'";
     $result = api_sql_query($sql, __FILE__, __LINE__);
 

+ 1 - 1
main/metadata/md_funcs.php

@@ -418,7 +418,7 @@ function mdstore($allow_create)
 {
     global $_course; if (!isset($_course)) return;
     
-    define('MDS_TABLE', Database::get_course_table('metadata'));
+    define('MDS_TABLE', Database::get_course_table(TABLE_METADATA));
 
     if (!api_sql_query("SELECT eid FROM " . MDS_TABLE))
     if ($allow_create)

+ 1 - 1
main/metadata/md_scorm.php

@@ -80,7 +80,7 @@ function mdobject($_course, $id)
 {
     global $ieee_dcmap_e, $ieee_dcmap_v;  // md_funcs
 
-    $scormdocument = Database::get_course_table('lp');
+    $scormdocument = Database::get_course_table(TABLE_LP_MAIN);
 
     $this->mdo_course = $_course; $this->mdo_type = 'Scorm';
     $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id;

+ 3 - 3
main/mySpace/myStudents.php

@@ -150,9 +150,9 @@ $tbl_course 				= Database :: get_main_table(TABLE_MAIN_COURSE);
 $tbl_course_user 			= Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $tbl_stats_exercices 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 $tbl_stats_exercices_attempts 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
-//$tbl_course_lp_view 		= Database :: get_course_table('lp_view');
-//$tbl_course_lp_view_item = Database :: get_course_table('lp_item_view');
-//$tbl_course_lp_item 		= Database :: get_course_table('lp_item');
+//$tbl_course_lp_view 		= Database :: get_course_table(TABLE_LP_VIEW);
+//$tbl_course_lp_view_item = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
+//$tbl_course_lp_item 		= Database :: get_course_table(TABLE_LP_ITEM);
 
 $tbl_course_lp_view = 'lp_view';
 $tbl_course_lp_view_item = 'lp_item_view';

+ 8 - 8
main/newscorm/aicc.class.php

@@ -235,8 +235,8 @@ class aicc extends learnpath {
         $row = Database::fetch_array($res);
         $dbname = Database::get_course_table_prefix().$row['db_name'].Database::get_database_glue();
 		
-		$new_lp = Database::get_course_table('lp');
-		$new_lp_item = Database::get_course_table('lp_item');
+		$new_lp = Database::get_course_table(TABLE_LP_MAIN);
+		$new_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     	$get_max = "SELECT MAX(display_order) FROM $new_lp";
     	$res_max = api_sql_query($get_max);
     	if(Database::num_rows($res_max)<1){
@@ -561,7 +561,7 @@ class aicc extends learnpath {
 		if($this->debug>0){error_log('In aicc::set_proximity('.$proxy.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET content_local = '$proxy' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -578,7 +578,7 @@ class aicc extends learnpath {
 		if($this->debug>0){error_log('In aicc::set_theme('.$theme.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET theme = '$theme' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -595,7 +595,7 @@ class aicc extends learnpath {
 		if($this->debug>0){error_log('In aicc::set_preview_image('.$preview_image.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -612,7 +612,7 @@ class aicc extends learnpath {
 		if($this->debug>0){error_log('In aicc::set_author('.$author.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET author = '$author' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -631,7 +631,7 @@ class aicc extends learnpath {
 		if($this->debug>0){error_log('In aicc::set_maker method('.$maker.')',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET content_maker = '$maker' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -668,7 +668,7 @@ class aicc extends learnpath {
 		require_once (api_get_path(LIBRARY_PATH)."document.lib.php");
 		require_once (api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
 		require_once ("learnpath_functions.inc.php");
-		$tbl_lp = Database::get_course_table('lp');
+		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 		$_course = Database::get_course_info(api_get_course_id());
 
 		$sql = "SELECT * FROM $tbl_lp WHERE id=".$lp_id;

+ 57 - 57
main/newscorm/learnpath.class.php

@@ -128,7 +128,7 @@ class learnpath {
     	else
     	{    		
     		//TODO make it flexible to use any course_code (still using env course code here)
-	    	$lp_table = Database::get_course_table('lp');
+	    	$lp_table = Database::get_course_table(TABLE_LP_MAIN);
 
     		//$id = Database::escape_integer($id);
     		$lp_id = $this->escape_string($lp_id);
@@ -379,7 +379,7 @@ class learnpath {
 		if ($this->debug > 0) {
 			error_log('New LP - In learnpath::add_item(' . $parent . ',' . $previous . ',' . $type . ',' . $id . ',' . $title . ')', 0);
 		}
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$parent = intval($parent);
 		$previous = intval($previous);
 		$type = $this->escape_string($type);
@@ -610,7 +610,7 @@ class learnpath {
 
 		//if($this->debug>0){error_log('New LP - In learnpath::add_lp()',0);}
 		//TODO
-		$tbl_lp = Database :: get_course_table('lp');
+		$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
 		//check course code exists
 		//check lp_name doesn't exist, otherwise append something
 		$i = 0;
@@ -832,9 +832,9 @@ class learnpath {
 			return false;
 		}
 
-		$lp = Database :: get_course_table('lp');
-		$lp_view = Database :: get_course_table('lp_view');
-		$lp_item_view = Database :: get_course_table('lp_item_view');
+		$lp = Database :: get_course_table(TABLE_LP_MAIN);
+		$lp_view = Database :: get_course_table(TABLE_LP_VIEW);
+		$lp_item_view = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
 
 		//if($this->debug>0){error_log('New LP - In learnpath::delete()',0);}
 		//delete lp item id
@@ -911,7 +911,7 @@ class learnpath {
 		if (empty ($id) || $id != strval(intval($id))) {
 			return false;
 		}
-		$lp_item = Database :: get_course_table('lp_item');
+		$lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$sql = "SELECT * FROM $lp_item WHERE parent_item_id = $id";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		while ($row = Database :: fetch_array($res)) {
@@ -939,7 +939,7 @@ class learnpath {
 			return false;
 		}
 		//first select item to get previous, next, and display order
-		$lp_item = Database :: get_course_table('lp_item');
+		$lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$sql_sel = "SELECT * FROM $lp_item WHERE id = $id";
 		$res_sel = api_sql_query($sql_sel, __FILE__, __LINE__);
 		if (Database :: num_rows($res_sel) < 1) {
@@ -1016,7 +1016,7 @@ class learnpath {
 		$title 		 = api_convert_encoding($title, $this->encoding, $charset);
 		$description = api_convert_encoding($description, $this->encoding, $charset);
 		
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$sql_select = "SELECT * FROM " . $tbl_lp_item . " WHERE id = " . $id;
 		$res_select = api_sql_query($sql_select, __FILE__, __LINE__);
 		$row_select = Database :: fetch_array($res_select);
@@ -1244,7 +1244,7 @@ class learnpath {
 
 		$prerequisite_id = $this->escape_string($prerequisite_id);
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		if (!is_numeric($mastery_score) || $mastery_score < 0)
 			$mastery_score = 0;
@@ -1361,7 +1361,7 @@ class learnpath {
 			return array ();
 		}
 
-		$lp_item = Database :: get_course_table('lp_item');
+		$lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		$sql_parent = "SELECT * FROM $lp_item WHERE id = $id AND item_type='dokeos_chapter'";
 
@@ -1415,7 +1415,7 @@ class learnpath {
 			return array ();
 		}
 
-		$lp_item = Database :: get_course_table('lp_item');
+		$lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		$sql_parent = "SELECT * FROM $lp_item WHERE id = $id";
 
@@ -2030,7 +2030,7 @@ class learnpath {
 	 */
 	function get_db_progress($lp_id, $user_id, $mode = '%', $course_db = '', $sincere = false) {
 		//if($this->debug>0){error_log('New LP - In learnpath::get_db_progress()',0);}
-		$table = Database :: get_course_table('lp_view', $course_db);
+		$table = Database :: get_course_table(TABLE_LP_VIEW, $course_db);
 		$sql = "SELECT * FROM $table WHERE lp_id = $lp_id AND user_id = $user_id";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		$view_id = 0;
@@ -2050,14 +2050,14 @@ class learnpath {
 			return $progress . '%';
 		} else {
 			//get the number of items completed and the number of items total
-			$tbl = Database :: get_course_table('lp_item', $course_db);
+			$tbl = Database :: get_course_table(TABLE_LP_ITEM, $course_db);
 			$sql = "SELECT count(*) FROM $tbl WHERE lp_id = " . $lp_id . " 
 								AND item_type NOT IN('dokeos_chapter','chapter','dir')";
 			$res = api_sql_query($sql, __FILE__, __LINE__);
 			$row = Database :: fetch_array($res);
 			$total = $row[0];
-			$tbl_item_view = Database :: get_course_table('lp_item_view', $course_db);
-			$tbl_item = Database :: get_course_table('lp_item', $course_db);
+			$tbl_item_view = Database :: get_course_table(TABLE_LP_ITEM_VIEW, $course_db);
+			$tbl_item = Database :: get_course_table(TABLE_LP_ITEM, $course_db);
 
 			//$sql = "SELECT count(distinct(lp_item_id)) FROM $tbl WHERE lp_view_id = ".$view_id." AND status IN ('passed','completed','succeeded')";
 			//trying as also counting browsed and failed items
@@ -2093,8 +2093,8 @@ class learnpath {
 		global $_course;
 
 		// Database table definition
-		$tbl_lp_item = Database :: get_course_table('lp_item');
-		$tbl_lp_item_view = Database :: get_course_table('lp_item_view');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
+		$tbl_lp_item_view = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
 		
 		// getting all the information about the item
 		$sql = "SELECT * FROM " . $tbl_lp_item . " as lp inner join " . $tbl_lp_item_view . " as lp_view on lp.id = lp_view.lp_item_id " .
@@ -2491,7 +2491,7 @@ class learnpath {
 		if (empty ($lp_iv_id)) {
 			return -1;
 		}
-		$table = Database :: get_course_table('lp_iv_interaction');
+		$table = Database :: get_course_table(TABLE_LP_IV_INTERACTION);
 		$sql = "SELECT count(*) FROM $table WHERE lp_iv_id = $lp_iv_id";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		$row = Database :: fetch_array($res);
@@ -2510,7 +2510,7 @@ class learnpath {
 		$charset = api_get_setting('platform_charset');
 
 		$list = array ();
-		$table = Database :: get_course_table('lp_iv_interaction');
+		$table = Database :: get_course_table(TABLE_LP_IV_INTERACTION);
 		$sql = "SELECT * FROM $table WHERE lp_iv_id = $lp_iv_id ORDER BY order_id ASC";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		$num = Database :: num_rows($res);
@@ -2552,7 +2552,7 @@ class learnpath {
 		if (empty ($lp_iv_id)) {
 			return -1;
 		}
-		$table = Database :: get_course_table('lp_iv_objective');
+		$table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE);
 		$sql = "SELECT count(*) FROM $table WHERE lp_iv_id = $lp_iv_id";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		$row = Database :: fetch_array($res);
@@ -2571,7 +2571,7 @@ class learnpath {
 		global $chatset;
 
 		$list = array ();
-		$table = Database :: get_course_table('lp_iv_objective');
+		$table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE);
 		$sql = "SELECT * FROM $table WHERE lp_iv_id = $lp_iv_id ORDER BY order_id ASC";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		$num = Database :: num_rows($res);
@@ -2659,7 +2659,7 @@ class learnpath {
 	 * @return	mixed		Type ID or name, depending on the parameter
 	 */
 	function get_type_static($lp_id = 0) {
-		$tbl_lp = Database :: get_course_table('lp');
+		$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
 		$sql = "SELECT lp_type FROM $tbl_lp WHERE id = '" . $lp_id . "'";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		if ($res === false) {
@@ -2685,7 +2685,7 @@ class learnpath {
 		if (empty ($lp)) {
 			return false;
 		}
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$sql = "SELECT * FROM $tbl_lp_item WHERE lp_id = $lp AND parent_item_id = $parent ORDER BY display_order";
 		$res = api_sql_query($sql, __FILE__, __LINE__);
 		while ($row = Database :: fetch_array($res)) {
@@ -3180,7 +3180,7 @@ class learnpath {
 			$search = 'AND view_count = ' . $attempt_num;
 		}
 		//when missing $attempt_num, search for a unique lp_view record for this lp and user
-		$lp_view_table = Database :: get_course_table('lp_view');
+		$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW);
 		$sql = "SELECT id, view_count FROM $lp_view_table " .
 		"WHERE lp_id = " . $this->get_id() . " " .
 		"AND user_id = " . $this->get_user_id() . " " .
@@ -3283,7 +3283,7 @@ class learnpath {
 		if (empty ($id) or empty ($direction)) {
 			return false;
 		}
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$sql_sel = "
 					SELECT *
 					FROM " . $tbl_lp_item . "
@@ -3623,7 +3623,7 @@ class learnpath {
 
 	function toggle_publish($lp_id, $set_visibility = 'v') {
 		//if($this->debug>0){error_log('New LP - In learnpath::toggle_publish()',0);}
-		$tbl_lp = Database :: get_course_table('lp');
+		$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
 		$sql = "SELECT * FROM $tbl_lp where id=$lp_id";
 		$result = api_sql_query($sql, __FILE__, __LINE__);
 		$row = Database :: fetch_array($result);
@@ -3671,7 +3671,7 @@ class learnpath {
 		//TODO
 		//call autosave method to save the current progress
 		//$this->index = 0;
-		$lp_view_table = Database :: get_course_table('lp_view');
+		$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW);
 		$sql = "INSERT INTO $lp_view_table (lp_id, user_id, view_count) " .
 		"VALUES (" . $this->lp_id . "," . $this->get_user_id() . "," . ($this->attempt + 1) . ")";
 		if ($this->debug > 2) {
@@ -3760,7 +3760,7 @@ class learnpath {
 		if ($this->debug > 0) {
 			error_log('New LP - In learnpath::save_last()', 0);
 		}
-		$table = Database :: get_course_table('lp_view');
+		$table = Database :: get_course_table(TABLE_LP_VIEW);
 		if (isset ($this->current)) {
 			if ($this->debug > 2) {
 				error_log('New LP - Saving current item (' . $this->current . ') for later review', 0);
@@ -3852,7 +3852,7 @@ class learnpath {
 		if (in_array($enc, $encodings)) {
 			$lp = $this->get_id();
 			if ($lp != 0) {
-				$tbl_lp = Database :: get_course_table('lp');
+				$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
 				$sql = "UPDATE $tbl_lp SET default_encoding = '$enc' WHERE id = " . $lp;
 				$res = api_sql_query($sql, __FILE__, __LINE__);
 				return $res;
@@ -3871,7 +3871,7 @@ class learnpath {
 		}
 		$lp = $this->get_id();
 		if ($lp != 0) {
-			$tbl_lp = Database :: get_course_table('lp');
+			$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
 			$sql = "UPDATE $tbl_lp SET js_lib = '$lib' WHERE id = " . $lp;
 			$res = api_sql_query($sql, __FILE__, __LINE__);
 			return $res;
@@ -3894,7 +3894,7 @@ class learnpath {
 
 		$this->maker = $this->escape_string($name);
 
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 
 		$lp_id = $this->get_id();
 
@@ -3928,7 +3928,7 @@ class learnpath {
 			return false;
 
 		$this->name = $this->escape_string($name);
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 		$lp_id = $this->get_id();
 		$sql = "UPDATE $lp_table SET name = '" . $this->name . "' WHERE id = '$lp_id'";
 		if ($this->debug > 2) {
@@ -3979,7 +3979,7 @@ class learnpath {
 		require_once (api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php');
 		require_once (api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
 
-		$items_table = Database :: get_course_table('lp_item');
+		$items_table = Database :: get_course_table(TABLE_LP_ITEM);
 		//TODO: make query secure agains XSS : use member attr instead of post var
 		$lp_id = $_POST['lp_id'];
 		$sql = "SELECT * FROM $items_table WHERE lp_id = $lp_id";
@@ -4033,7 +4033,7 @@ class learnpath {
 			error_log('New LP - In learnpath::set_theme()', 0);
 		}
 		$this->theme = $this->escape_string($name);
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 		$lp_id = $this->get_id();
 		$sql = "UPDATE $lp_table SET theme = '" . $this->theme . "' WHERE id = '$lp_id'";
 		if ($this->debug > 2) {
@@ -4054,7 +4054,7 @@ class learnpath {
 			error_log('New LP - In learnpath::set_preview_image()', 0);
 		}
 		$this->preview_image = $this->escape_string($name);
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 		$lp_id = $this->get_id();
 		$sql = "UPDATE $lp_table SET preview_image = '" . $this->preview_image . "' WHERE id = '$lp_id'";
 		if ($this->debug > 2) {
@@ -4074,7 +4074,7 @@ class learnpath {
 			error_log('New LP - In learnpath::set_author()', 0);
 		}
 		$this->author = $this->escape_string($name);
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 		$lp_id = $this->get_id();
 		$sql = "UPDATE $lp_table SET author = '" . $this->author . "' WHERE id = '$lp_id'";
 		if ($this->debug > 2) {
@@ -4096,7 +4096,7 @@ class learnpath {
 			return false;
 
 		$this->proximity = $this->escape_string($name);
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 		$lp_id = $this->get_id();
 		$sql = "UPDATE $lp_table SET content_local = '" . $this->proximity . "' WHERE id = '$lp_id'";
 		if ($this->debug > 2) {
@@ -4239,7 +4239,7 @@ class learnpath {
 			error_log('New LP - In learnpath::update_default_view_mode()', 0);
 		}
 
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 
 		$sql = "SELECT * FROM $lp_table WHERE id = " . $this->get_id();
 
@@ -4296,7 +4296,7 @@ class learnpath {
 			error_log('New LP - In learnpath::update_default_scorm_commit()', 0);
 		}
 
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 
 		$sql = "SELECT * FROM $lp_table WHERE id = " . $this->get_id();
 
@@ -4386,7 +4386,7 @@ class learnpath {
 			error_log('New LP - In learnpath::update_reinit()', 0);
 		}
 
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 
 		$sql = "SELECT * FROM $lp_table WHERE id = " . $this->get_id();
 
@@ -4443,7 +4443,7 @@ class learnpath {
 			error_log('New LP - In learnpath::update_scorm_debug()', 0);
 		}
 
-		$lp_table = Database :: get_course_table('lp');
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
 
 		$sql = "SELECT * FROM $lp_table WHERE id = " . $this->get_id();
 
@@ -4586,7 +4586,7 @@ class learnpath {
 		$_SESSION['gradebook'] = Security :: remove_XSS($_GET['gradebook']);
 		$return = '';
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		$sql = "SELECT * FROM " . $tbl_lp_item . "
 				WHERE lp_id = " . $this->lp_id;
@@ -4808,7 +4808,7 @@ class learnpath {
 		$menu = 0;
 		$parent = '';
 		$return .= "\tm.add(" . $menu . ", -1, '" . addslashes(Security::remove_XSS(($this->name))) . "');\n";
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		$sql = " SELECT * FROM " . $tbl_lp_item . "
 				 WHERE lp_id = " . Database :: escape_string($this->lp_id);
@@ -5033,7 +5033,7 @@ class learnpath {
 		global $_course; //will disappear		
 		$return = '';
 		if (is_numeric($item_id)) {
-			$tbl_lp_item = Database :: get_course_table('lp_item');
+			$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 			$tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
 			$sql = "SELECT lp.*
 								FROM " . $tbl_lp_item . " as lp
@@ -5086,7 +5086,7 @@ class learnpath {
 		global $_course; //will disappear	
 		$return = '';
 		if (is_numeric($item_id)) {
-			$tbl_lp_item = Database :: get_course_table('lp_item');
+			$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 			$sql = "SELECT *
 								FROM " . $tbl_lp_item . "
 								WHERE id = " . Database :: escape_string($item_id);
@@ -5476,7 +5476,7 @@ class learnpath {
 	function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '') {
 		global $charset;
 		$uploadPath = DIR_HOTPOTATOES; //defined in main_api
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		if ($id != 0 && is_array($extra_info)) {
 			$item_title = stripslashes($extra_info['title']);
@@ -5726,7 +5726,7 @@ class learnpath {
 	function display_forum_form($action = 'add', $id = 0, $extra_info = '') {
 		global $charset;
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$tbl_forum = Database :: get_course_table(TABLE_FORUM);
 
 		if ($id != 0 && is_array($extra_info)) {
@@ -5973,7 +5973,7 @@ class learnpath {
 				}
 				</style>';
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$tbl_forum = Database :: get_course_table(TABLE_FORUM_THREAD);
 
 		if ($id != 0 && is_array($extra_info)) {
@@ -6214,7 +6214,7 @@ class learnpath {
 		global $_course;
 		global $charset;
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		if ($id != 0 && is_array($extra_info)) {
 			$item_title = $extra_info['title'];
@@ -6385,7 +6385,7 @@ class learnpath {
 	 */
 	function display_document_form($action = 'add', $id = 0, $extra_info = 'new') {
 		global $charset;
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
 
 		$path_parts = pathinfo($extra_info['dir']);
@@ -6753,7 +6753,7 @@ class learnpath {
 	 */
 	function display_link_form($action = 'add', $id = 0, $extra_info = '') {
 		global $charset;
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$tbl_link = Database :: get_course_table(TABLE_LINK);
 
 		if ($id != 0 && is_array($extra_info)) {
@@ -7013,7 +7013,7 @@ class learnpath {
 	function display_student_publication_form($action = 'add', $id = 0, $extra_info = '') {
 		global $charset;
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 		$tbl_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
 
 		if ($id != 0 && is_array($extra_info)) {
@@ -7287,7 +7287,7 @@ class learnpath {
 				break;
 		}
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		$sql = "
 					SELECT
@@ -7372,7 +7372,7 @@ class learnpath {
 		$return .= 'child_name[0] = new Array();' . "\n";
 		$return .= 'child_value[0] = new Array();' . "\n\n";
 
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		$sql_zero = "
 					SELECT *
@@ -7438,7 +7438,7 @@ class learnpath {
 		$return = '';
 
 		if (is_numeric($item_id)) {
-			$tbl_lp_item = Database :: get_course_table('lp_item');
+			$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 			$sql = "SELECT *
 					FROM " . $tbl_lp_item . "
@@ -7548,7 +7548,7 @@ class learnpath {
 	 */
 	function display_item_prerequisites_form($item_id) {
 		global $charset;
-		$tbl_lp_item = Database :: get_course_table('lp_item');
+		$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
 
 		/* current prerequisite */
 		$sql = "

+ 18 - 18
main/newscorm/learnpathItem.class.php

@@ -69,7 +69,7 @@ class learnpathItem{
     function learnpathItem($db_id, $user_id) {
     	//get items table
     	if($this->debug>0){error_log('New LP - In learnpathItem constructor: '.$db_id.','.$user_id,0);}
-    	$items_table = Database::get_course_table('lp_item');
+    	$items_table = Database::get_course_table(TABLE_LP_ITEM);
     	$id = (int) $db_id;
     	$sql = "SELECT * FROM $items_table WHERE id = $id";
     	//error_log('New LP - Creating item object from DB: '.$sql,0);
@@ -207,8 +207,8 @@ class learnpathItem{
     function delete()
     {
     	if($this->debug>0){error_log('New LP - In learnpath_item::delete() for item '.$this->db_id,0);}
-    	$lp_item_view = Database::get_course_table('lp_item_view');
-    	$lp_item = Database::get_course_table('lp_item');
+    	$lp_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
+    	$lp_item = Database::get_course_table(TABLE_LP_ITEM);
     	$sql_del_view = "DELETE FROM $lp_item_view WHERE item_id = ".$this->db_id;
 		//error_log('New LP - Deleting from lp_item_view: '.$sql_del_view,0);
 		$res_del_view = api_sql_query($sql_del_view);
@@ -403,7 +403,7 @@ class learnpathItem{
      */
     function load_interactions() {
             $this->interactions = array();
-            $tbl = Database::get_course_table('lp_item_view');
+            $tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
             $sql = "SELECT id FROM $tbl " .
                     "WHERE lp_item_id = ".$this->db_id." " .
                     "AND   lp_view_id = ".$this->view_id." " .
@@ -412,7 +412,7 @@ class learnpathItem{
             if (Database::num_rows($res)>0) {
                 $row = Database::fetch_array($res);
                 $lp_iv_id = $row[0];
-                $iva_table = Database::get_course_table('lp_iv_interaction');
+                $iva_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
                 $iva_sql = "SELECT * FROM $iva_table " .
                             "WHERE lp_iv_id = $lp_iv_id ";
                 $res_sql = api_sql_query($iva_sql);
@@ -431,7 +431,7 @@ class learnpathItem{
     	if($this->debug>1){error_log('New LP - In learnpathItem::get_interactions_count()',0);}
     	$return = 0;
         if ($checkdb) {
-            $tbl = Database::get_course_table('lp_item_view');
+            $tbl = Database::get_course_table(TABLE_LP_VIEW);
             $sql = "SELECT id FROM $tbl " .
                     "WHERE lp_item_id = ".$this->db_id." " .
                     "AND   lp_view_id = ".$this->view_id." " .
@@ -440,7 +440,7 @@ class learnpathItem{
             if (Database::num_rows($res)>0) {
                 $row = Database::fetch_array($res);
                 $lp_iv_id = $row[0];
-                $iva_table = Database::get_course_table('lp_iv_interaction');
+                $iva_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
                 $iva_sql = "SELECT count(id) as mycount FROM $iva_table " .
                             "WHERE lp_iv_id = $lp_iv_id ";
                 $res_sql = api_sql_query($iva_sql);
@@ -626,7 +626,7 @@ class learnpathItem{
 		if($this->debug>2){error_log('New LP - In learnpathItem::get_prevent_reinit()',0);}
     	if(!isset($this->prevent_reinit)){
 	    	if(!empty($this->lp_id)){
-	    		$db = Database::get_course_table('lp');
+	    		$db = Database::get_course_table(TABLE_LP_MAIN);
 			   	$sql = "SELECT * FROM $db WHERE id = ".$this->lp_id;
 		    	$res = @api_sql_query($sql);
 		    	if(Database::num_rows($res)<1)
@@ -1010,7 +1010,7 @@ class learnpathItem{
     	if($this->debug>0){error_log('New LP - In learnpathItem::get_status() on item '.$this->db_id,0);}
     	if($check_db) {
     		if($this->debug>2){error_log('New LP - In learnpathItem::get_status(): checking db',0);}
-    		$table = Database::get_course_table('lp_item_view');
+    		$table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
     		$sql = "SELECT * FROM $table WHERE id = '".$this->db_item_view_id."' AND view_count = '".$this->get_attempt_id()."'";
     		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Checking DB: '.$sql,0);}
 
@@ -1828,7 +1828,7 @@ function get_terms()
     	if(!empty($lp_view_id) and $lp_view_id = intval(strval($lp_view_id)))
      	{
      		$this->view_id = $lp_view_id;
-	     	$item_view_table = Database::get_course_table('lp_item_view');
+	     	$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 	     	//get the lp_item_view with the highest view_count
 	     	$sql = "SELECT * FROM $item_view_table WHERE lp_item_id = ".$this->get_id()." " .
 	     			" AND lp_view_id = ".$lp_view_id." ORDER BY view_count DESC";
@@ -1850,7 +1850,7 @@ function get_terms()
 		     	if($this->debug>2){error_log('New LP - In learnpathItem::set_lp_view() - Updated item object with database values',0);}
 
 		     	//now get the number of interactions for this little guy
-		     	$item_view_interaction_table = Database::get_course_table('lp_iv_interaction');
+		     	$item_view_interaction_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
 		     	$sql = "SELECT * FROM $item_view_interaction_table WHERE lp_iv_id = '".$this->db_item_view_id."'"; 
 				$res = api_sql_query($sql,__FILE__,__LINE__);
 				if($res !== false){
@@ -1859,7 +1859,7 @@ function get_terms()
 					$this->interactions_count = 0;
 				}
 		     	//now get the number of objectives for this little guy
-		     	$item_view_objective_table = Database::get_course_table('lp_iv_objective');
+		     	$item_view_objective_table = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
 		     	$sql = "SELECT * FROM $item_view_objective_table WHERE lp_iv_id = '".$this->db_item_view_id."'"; 
 				$res = api_sql_query($sql,__FILE__,__LINE__);
 				if($res !== false){
@@ -2116,7 +2116,7 @@ function get_terms()
    		if($this->debug>0){error_log('New LP - In learnpathItem::write_objectives_to_db()',0);}
      	if(is_array($this->objectives) && count($this->objectives)>0){
      		//save objectives
-     		$tbl = Database::get_course_table('lp_item_view');
+     		$tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
      		$sql = "SELECT id FROM $tbl " .
      				"WHERE lp_item_id = ".$this->db_id." " .
      				"AND   lp_view_id = ".$this->view_id." " .
@@ -2127,7 +2127,7 @@ function get_terms()
      			$lp_iv_id = $row[0];
      			if($this->debug>2){error_log('New LP - In learnpathItem::write_to_db() - Got item_view_id '.$lp_iv_id.', now checking objectives ',0);}
 	     		foreach($this->objectives as $index => $objective){
-	     			$iva_table = Database::get_course_table('lp_iv_objective');
+	     			$iva_table = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
 	     			$iva_sql = "SELECT id FROM $iva_table " .
 	     					"WHERE lp_iv_id = $lp_iv_id " .
 	     					//"AND order_id = $index";
@@ -2178,7 +2178,7 @@ function get_terms()
    		$credit = $this->get_credit();
    		$my_verified_status=$this->get_status(false);
    		
-   		$item_view_table = Database::get_course_table('lp_item_view');
+   		$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 		$sql_verified='SELECT status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
 		$rs_verified=api_sql_query($sql_verified,__FILE__,__LINE__);
 		$row_verified=Database::fetch_array($rs_verified);
@@ -2234,7 +2234,7 @@ function get_terms()
 		     	$inserted = true;	
 		   }     		
       		
-	     	$item_view_table = Database::get_course_table('lp_item_view');
+	     	$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 	     	$check = "SELECT * FROM $item_view_table " .
 	     			"WHERE lp_item_id = ".$this->db_id. " " .
 	     			"AND   lp_view_id = ".$this->view_id. " ".
@@ -2405,7 +2405,7 @@ function get_terms()
 	     	//}
 	     	if(is_array($this->interactions) && count($this->interactions)>0){
 	     		//save interactions
-	     		$tbl = Database::get_course_table('lp_item_view');
+	     		$tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 	     		$sql = "SELECT id FROM $tbl " .
 	     				"WHERE lp_item_id = ".$this->db_id." " .
 	     				"AND   lp_view_id = ".$this->view_id." " .
@@ -2423,7 +2423,7 @@ function get_terms()
 		     				}
 		     				$correct_resp = substr($correct_resp,0,strlen($correct_resp)-1);
 		     			}
-		     			$iva_table = Database::get_course_table('lp_iv_interaction');
+		     			$iva_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
 		     			$iva_sql = "SELECT id FROM $iva_table " .
 		     					"WHERE lp_iv_id = $lp_iv_id " .
 //		     					"AND order_id = $index";

+ 1 - 1
main/newscorm/learnpathList.class.php

@@ -31,7 +31,7 @@ class learnpathList {
     		//proceed with course code given
     	}else{
 		$course_code = api_get_course_id();
-		$lp_table = Database::get_course_table('lp');
+		$lp_table = Database::get_course_table(TABLE_LP_MAIN);
     	}
     	$this->course_code = $course_code;
     	$this->user_id = $user_id;

+ 5 - 5
main/newscorm/learnpath_functions.inc.php

@@ -414,7 +414,7 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array (), $leve
 	global $color2;
 	global $xml_output;
 	global $learnpath_id;
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 	
 	
 	// @todo: coding standards: Language variables are CaMMelCaSe, all other variables should use the underscoring method.
@@ -703,7 +703,7 @@ function display_learnpath_items($categoryid)
 {
 	global $xml_output;
 	global $lang_prerequisites, $lang_move_down, $lang_move_up, $lang_edit_learnpath_item, $lang_delete_learnpath_item, $learnpath_id, $lang_add_prereq, $lang_prereq_deleted_error, $lang_pre_short, $langThisItem;
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 
 	$sql_items = "SELECT * FROM $tbl_lp_item WHERE parent_item_id='$categoryid' ORDER BY display_order ASC";
 	$result_items = api_sql_query($sql_items,__FILE__,__LINE__);
@@ -844,7 +844,7 @@ function learnpath_chapters($learnpath_id)
 {
 	global $xml_output, $learnpath_id;
 	//$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 	
 
 	$sql_items = "SELECT * FROM $tbl_lp_item WHERE lp_id='$learnpath_id' AND item_type='dokeos_chapter' ORDER BY display_order ASC";
@@ -868,7 +868,7 @@ function learnpath_chapters($learnpath_id)
 function is_prereq($learnpath_id)
 {
 	global $xml_output;
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 	
 	$prereq = false;
 
@@ -1050,7 +1050,7 @@ function get_learnpath_tree($learnpath_id)
 	$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
 	$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
 	*/
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 
 	$tree = array ();
 	$chapters = array ();

+ 3 - 3
main/newscorm/lp_add.php

@@ -72,9 +72,9 @@ $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="dtree.css" />';
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 3 - 3
main/newscorm/lp_add_item.php

@@ -98,9 +98,9 @@ $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 5 - 5
main/newscorm/lp_admin_view.php

@@ -63,9 +63,9 @@ $language_file = "learnpath";
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];
@@ -207,7 +207,7 @@ if (isset($_POST['save_audio']))
 		if (substr($key,0,9) == 'removemp3') {
 			$lp_items_to_remove_audio[] = str_ireplace('removemp3','',$key);			
 			// removing the audio from the learning path item
-			$tbl_lp_item = Database::get_course_table('lp_item');
+			$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 			$in = implode(',',$lp_items_to_remove_audio);
 		}
 	}
@@ -272,7 +272,7 @@ if (isset($_POST['save_audio']))
 			$file = $file_components[count($file_components)-1];	
 
 			// store the mp3 file in the lp_item table
-			$tbl_lp_item = Database::get_course_table('lp_item');
+			$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 			$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file)."' WHERE id = '".Database::escape_string($lp_item_id)."'";
 			api_sql_query($sql_insert_audio, __FILE__, __LINE__);			
 			

+ 3 - 3
main/newscorm/lp_build.php

@@ -66,9 +66,9 @@ $language_file = "learnpath";
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 1 - 1
main/newscorm/lp_controller.php

@@ -100,7 +100,7 @@ if($lp_found == false || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id
 		if($debug>0) error_log('New LP - lp_id is defined',0);
 		//select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
 		//right object
-		$lp_table = Database::get_course_table('lp');
+		$lp_table = Database::get_course_table(TABLE_LP_MAIN);
 		if(!empty($_REQUEST['lp_id'])){
 			$lp_id = $_REQUEST['lp_id'];
 		} else {

+ 3 - 3
main/newscorm/lp_edit_item.php

@@ -97,9 +97,9 @@ $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 3 - 3
main/newscorm/lp_edit_item_prereq.php

@@ -66,9 +66,9 @@ $language_file = "learnpath";
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 3 - 3
main/newscorm/lp_move_item.php

@@ -72,9 +72,9 @@ $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 4 - 4
main/newscorm/lp_stats.php

@@ -123,9 +123,9 @@ $output .= "<tr><td>&nbsp;</td></tr>" . "<tr><td>" . "<table border='0' class='d
 //going through the items using the $items[] array instead of the database order ensures
 // we get them in the same order as in the imsmanifest file, which is rather random when using
 // the database table
-$TBL_LP_ITEM = Database :: get_course_table('lp_item');
-$TBL_LP_ITEM_VIEW = Database :: get_course_table('lp_item_view');
-$TBL_LP_VIEW = Database :: get_course_table('lp_view');
+$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);
 $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 $tbl_stats_attempts= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 $tbl_quiz_questions= Database :: get_course_table(TABLE_QUIZ_QUESTION);
@@ -174,7 +174,7 @@ if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) {
 						
 }
 
-$TBL_QUIZ = Database :: get_course_table('quiz');
+$TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
 
 if (is_array($list) && count($list) > 0){
 	foreach ($list as $my_item_id) {

+ 2 - 2
main/newscorm/lp_view.php

@@ -289,7 +289,7 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
 						$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
 						$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);	
 						
-						$tbl_lp_item	= Database::get_course_table('lp_item');
+						$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."'";
@@ -497,7 +497,7 @@ else
 						$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
 						$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);
 						
-						$tbl_lp_item	= Database::get_course_table('lp_item');
+						$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."'";

+ 3 - 3
main/newscorm/lp_view_item.php

@@ -76,9 +76,9 @@ $language_file = "learnpath";
 */ 
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
-$tbl_lp_view = Database::get_course_table('lp_view');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (empty($_REQUEST['isStudentView'])?0:(int) $_REQUEST['isStudentView']);
 $learnpath_id   = (int) $_REQUEST['lp_id'];

+ 4 - 4
main/newscorm/resourcelinker.inc.php

@@ -370,7 +370,7 @@ function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_
 	global $_course, $learnpath_id, $tbl_learnpath_item, $items;
 	global $curDirPath, $_configuration, $enableDocumentParsing, $_course, $_user, $_cid;
 
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 	$hyperlink_target_parameter = ''; //or e.g. 'target="_blank"'
 
 	$length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
@@ -1166,7 +1166,7 @@ function get_addedresource_link_in_learnpath($type, $id, $id_in_path)
 	global $_course, $learnpath_id, $tbl_learnpath_item, $items;
 	global $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;
 
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 	$hyperlink_target_parameter = ""; //or e.g. target='_blank'
  $builder = 'player';
 	$origin='learnpath';
@@ -1803,7 +1803,7 @@ function rl_get_resource_link_for_learnpath($course_code, $learnpath_id, $id_in_
 	//error_log('In rl_get_resource_link_for_learnpath()',0);
 	$_course = Database::get_course_info($course_code);
 	
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 
 	$sql_item = "SELECT * FROM $tbl_lp_item " .
 			"WHERE lp_id = $learnpath_id AND id = $id_in_path";
@@ -1946,7 +1946,7 @@ function rl_get_resource_link_for_learnpath($course_code, $learnpath_id, $id_in_
 function rl_get_resource_name($course_code, $learnpath_id, $id_in_path)
 {
 	$_course = Database::get_course_info($course_code);
-	$tbl_lp_item = Database::get_course_table('lp_item');
+	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 
 	$sql_item = "SELECT * FROM $tbl_lp_item " .
 			"WHERE lp_id = $learnpath_id AND id = $id_in_path";

+ 2 - 2
main/newscorm/resourcelinker.php

@@ -66,8 +66,8 @@ $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
 //$tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
 //$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
 //$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
-$tbl_lp = Database::get_course_table('lp');
-$tbl_lp_item = Database::get_course_table('lp_item');
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 
 $action = $_REQUEST['action'];
 $add = $_REQUEST['add'];

+ 9 - 9
main/newscorm/scorm.class.php

@@ -361,8 +361,8 @@ class scorm extends learnpath {
         $dbname = $row['db_name'];
 
 		//get table names
-		$new_lp = Database::get_course_table('lp',$dbname);
-		$new_lp_item = Database::get_course_table('lp_item',$dbname);
+		$new_lp = Database::get_course_table(TABLE_LP_MAIN, $dbname);
+		$new_lp_item = Database::get_course_table(TABLE_LP_ITEM, $dbname);
 		
 		foreach($this->organizations as $id => $dummy)
 		{
@@ -748,7 +748,7 @@ class scorm extends learnpath {
 		if($this->debug>0){error_log('In scorm::set_proximity('.$proxy.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET content_local = '$proxy' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -765,7 +765,7 @@ class scorm extends learnpath {
 		if($this->debug>0){error_log('In scorm::set_theme('.$theme.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET theme = '$theme' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -782,7 +782,7 @@ class scorm extends learnpath {
 		if($this->debug>0){error_log('In scorm::set_theme('.$preview_image.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -800,7 +800,7 @@ class scorm extends learnpath {
 		if($this->debug>0){error_log('In scorm::set_author('.$author.') method',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET author = '$author' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -820,7 +820,7 @@ class scorm extends learnpath {
 		if($this->debug>0){error_log('In scorm::set_maker method('.$maker.')',0);}
 	 	$lp = $this->get_id();
 	 	if($lp!=0){
-	 		$tbl_lp = Database::get_course_table('lp');
+	 		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	 		$sql = "UPDATE $tbl_lp SET content_maker = '$maker' WHERE id = ".$lp;
 	 		$res = api_sql_query($sql);
 	 		return $res;
@@ -857,7 +857,7 @@ class scorm extends learnpath {
 		require_once (api_get_path(LIBRARY_PATH)."document.lib.php");
 		require_once (api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
 		require_once ("learnpath_functions.inc.php");
-		$tbl_lp = Database::get_course_table('lp');
+		$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 		$_course = Database::get_course_info(api_get_course_id());
 
 		$sql = "SELECT * FROM $tbl_lp WHERE id=".$lp_id;
@@ -976,7 +976,7 @@ class scorm extends learnpath {
    		
    		//TODO make it flexible to use any course_code (still using env course code here)
 		//$lp_table = Database::get_course_table(LEARNPATH_TABLE);
-    	$lp_table = Database::get_course_table('lp');
+    	$lp_table = Database::get_course_table(TABLE_LP_MAIN);
 
 		//$id = Database::escape_integer($id);
 		$lp_id = $this->escape_string($lp_id);

+ 1 - 1
main/survey/reporting.php

@@ -109,7 +109,7 @@ $table_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
 $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
 $table_course 					= Database :: get_main_table(TABLE_MAIN_COURSE);
 $table_user 					= Database :: get_main_table(TABLE_MAIN_USER);
-$user_info 						= Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
+$user_info 						= Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
 
 // getting the survey information
 

+ 1 - 1
main/survey/survey.php

@@ -38,7 +38,7 @@ $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUEST
 $table_survey_question_group    = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP);
 $table_course 					= Database :: get_main_table(TABLE_MAIN_COURSE);
 $table_user 					= Database :: get_main_table(TABLE_MAIN_USER);
-$user_info 						= Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
+$user_info 						= Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
 $survey_id = intval($_GET['survey_id']);
 
 // breadcrumbs

+ 1 - 1
main/survey/survey_invite.php

@@ -59,7 +59,7 @@ $table_survey_question 		= Database::get_course_table(TABLE_SURVEY_QUESTION);
 $table_survey_question_option 	= Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
 $table_course 			= Database::get_main_table(TABLE_MAIN_COURSE);
 $table_user 			= Database::get_main_table(TABLE_MAIN_USER);
-$user_info 			= Database::get_main_table(TABLE_MAIN_SURVEY_REMINDER);
+$user_info 			= Database::get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
 
 // getting the survey information
 $survey_id = Security::remove_XSS($_GET['survey_id']);

+ 1 - 1
main/tracking/courseLog.php

@@ -56,7 +56,7 @@ $csv_content = array();
 
 // charset determination
 if (!empty($_GET['scormcontopen'])) {
-    $tbl_lp = Database::get_course_table('lp');
+    $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
     $contopen = (int) $_GET['scormcontopen'];
     $sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen;
     $res = api_sql_query($sql,__FILE__,__LINE__);

+ 5 - 5
main/tracking/courseLogCSV.php

@@ -53,7 +53,7 @@ require_once('../newscorm/scormItem.class.php');
 // charset determination
 if ($_GET['scormcontopen'])
 {
-	$tbl_lp = Database::get_course_table('lp');
+	$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	$contopen = (int) $_GET['scormcontopen'];
 	$sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen;
 	$res = api_sql_query($sql,__FILE__,__LINE__);
@@ -83,10 +83,10 @@ $table_user = Database::get_main_table(TABLE_MAIN_USER);
 //$tbl_learnpath_item = Database::get_course_table(TABLE_LEARNPATH_ITEM);
 //$tbl_learnpath_chapter = Database::get_course_table(TABLE_LEARNPATH_CHAPTER);
 
-$tbl_learnpath_main = Database::get_course_table('lp');
-$tbl_learnpath_item = Database::get_course_table('lp_item');
-$tbl_learnpath_view = Database::get_course_table('lp_view');
-$tbl_learnpath_item_view = Database::get_course_table('lp_item_view');
+$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
+$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 
 $view = $_REQUEST['view'];
 

+ 5 - 5
main/tracking/userLog.php

@@ -69,7 +69,7 @@ require_once(api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php');
 */
 // charset determination
 if (isset($_GET['scormcontopen'])) {
-	$tbl_lp = Database::get_course_table('lp');
+	$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	$contopen = Database::escape_string($_GET['scormcontopen']);
 	if (is_numeric($contopen)) {
 		$contopen = intval($contopen);
@@ -150,10 +150,10 @@ if(api_get_setting('use_session_mode') == "true") {
 	}
 }
 
-$tbl_learnpath_main = Database::get_course_table('lp');
-$tbl_learnpath_item = Database::get_course_table('lp_item');
-$tbl_learnpath_view = Database::get_course_table('lp_view');
-$tbl_learnpath_item_view = Database::get_course_table('lp_item_view');
+$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
+$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 
 $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 

+ 5 - 5
main/tracking/userlogCSV.php

@@ -73,7 +73,7 @@ require_once(api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php');
 // charset determination
 if ($_GET['scormcontopen'])
 {
-	$tbl_lp = Database::get_course_table('lp');
+	$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 	$contopen = (int) $_GET['scormcontopen'];
 	$sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen;
 	$res = api_sql_query($sql,__FILE__,__LINE__);
@@ -141,10 +141,10 @@ if(api_get_setting('use_session_mode') == "true") {
 	}
 }
 
-$tbl_learnpath_main = Database::get_course_table('lp');
-$tbl_learnpath_item = Database::get_course_table('lp_item');
-$tbl_learnpath_view = Database::get_course_table('lp_view');
-$tbl_learnpath_item_view = Database::get_course_table('lp_item_view');
+$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
+$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
+$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 
 $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';