diff --git a/main/install/update-db-1.6.x-1.8.0.inc.php b/main/install/update-db-1.6.x-1.8.0.inc.php index 9e08487807..712d3bf487 100755 --- a/main/install/update-db-1.6.x-1.8.0.inc.php +++ b/main/install/update-db-1.6.x-1.8.0.inc.php @@ -263,7 +263,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) }else{ mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php');} if(mysql_num_rows($res)>0) { $i=0; @@ -579,7 +579,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) }else{ mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php');} if(mysql_num_rows($res)>0) { $i=0; diff --git a/main/install/update-db-1.8.0-1.8.2.inc.php b/main/install/update-db-1.8.0-1.8.2.inc.php index 57fefc3c43..9006acff67 100755 --- a/main/install/update-db-1.8.0-1.8.2.inc.php +++ b/main/install/update-db-1.8.0-1.8.2.inc.php @@ -264,7 +264,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) }else{ mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.0-1.8.2.inc.php');} if(mysql_num_rows($res)>0) { $i=0; diff --git a/main/install/update-db-1.8.2-1.8.3.inc.php b/main/install/update-db-1.8.2-1.8.3.inc.php index 03f45ba38e..6d1541c396 100755 --- a/main/install/update-db-1.8.2-1.8.3.inc.php +++ b/main/install/update-db-1.8.2-1.8.3.inc.php @@ -264,7 +264,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) }else{ mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.2-1.8.3.inc.php');} if(mysql_num_rows($res)>0) { $i=0; diff --git a/main/install/update-db-1.8.3-1.8.4.inc.php b/main/install/update-db-1.8.3-1.8.4.inc.php index 400508af63..e3f0207969 100755 --- a/main/install/update-db-1.8.3-1.8.4.inc.php +++ b/main/install/update-db-1.8.3-1.8.4.inc.php @@ -264,7 +264,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) }else{ mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.3-1.8.4.inc.php');} if(mysql_num_rows($res)>0) { $i=0; diff --git a/main/install/update-db-1.8.4-1.8.5.inc.php b/main/install/update-db-1.8.4-1.8.5.inc.php index eb606f6e24..07d8780826 100755 --- a/main/install/update-db-1.8.4-1.8.5.inc.php +++ b/main/install/update-db-1.8.4-1.8.5.inc.php @@ -254,7 +254,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.4-1.8.5.inc.php');} if(mysql_num_rows($res)>0) { diff --git a/main/install/update-db-1.8.5-1.8.6.inc.php b/main/install/update-db-1.8.5-1.8.6.inc.php index 3deb9659a7..495550b786 100755 --- a/main/install/update-db-1.8.5-1.8.6.inc.php +++ b/main/install/update-db-1.8.5-1.8.6.inc.php @@ -1165,7 +1165,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.5-1.8.6.inc.php');} if(mysql_num_rows($res)>0) { diff --git a/main/install/update-db-1.8.6-1.8.6.1.inc.php b/main/install/update-db-1.8.6-1.8.6.1.inc.php index 11d8c3d265..69acc62b4c 100755 --- a/main/install/update-db-1.8.6-1.8.6.1.inc.php +++ b/main/install/update-db-1.8.6-1.8.6.1.inc.php @@ -256,7 +256,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.6-1.8.6.1.inc.php');} if(mysql_num_rows($res)>0) { diff --git a/main/install/update-db-1.8.6.1-1.8.6.2.inc.php b/main/install/update-db-1.8.6.1-1.8.6.2.inc.php index 0bfb88ea6a..c7ff627d77 100755 --- a/main/install/update-db-1.8.6.1-1.8.6.2.inc.php +++ b/main/install/update-db-1.8.6.1-1.8.6.2.inc.php @@ -156,18 +156,18 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) } } } - - + + // There might now be multiple course coaches. This implies // moving the previous course coach elements from the // session_rel_course table to the session_rel_course_rel_user // table with status 2 - // Select all the current course coaches in sessions - - $sql = "SELECT id_session, course_code, id_coach - FROM session_rel_course + // Select all the current course coaches in sessions + + $sql = "SELECT id_session, course_code, id_coach + FROM session_rel_course ORDER BY id_session, course_code"; - + $res = mysql_query($sql); if ($res === false) { @@ -176,18 +176,18 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) // For each coach found, add him as a course coach in the // session_rel_course_rel_user table while ($row = mysql_fetch_array($res)) { - + // chech if coach is a student - $sql = "SELECT 1 FROM session_rel_course_rel_user + $sql = "SELECT 1 FROM session_rel_course_rel_user WHERE id_session='{$row[id_session]}' AND course_code='{$row[course_code]}' AND id_user='{$row[id_coach]}'"; - $rs = mysql_query($sql); - + $rs = mysql_query($sql); + if (mysql_num_rows($rs)>0) { - $sql_upd = "UPDATE session_rel_course_rel_user SET status=2 + $sql_upd = "UPDATE session_rel_course_rel_user SET status=2 WHERE id_session='{$row[id_session]}' AND course_code='{$row[course_code]}' AND id_user='{$row[id_coach]}'"; } else { - $sql_ins = "INSERT INTO session_rel_course_rel_user(id_session, course_code, id_user, status) - VALUES ('{$row[id_session]}','{$row[course_code]}','{$row[id_coach]}',2)"; + $sql_ins = "INSERT INTO session_rel_course_rel_user(id_session, course_code, id_user, status) + VALUES ('{$row[id_session]}','{$row[course_code]}','{$row[id_coach]}',2)"; } $rs_coachs = mysql_query($sql_ins); @@ -198,47 +198,47 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) } } - + // Remove duplicated rows for 'show_tutor_data' AND 'show_teacher_data' into settings_current table - + $sql = "SELECT id FROM settings_current WHERE variable='show_tutor_data' ORDER BY id"; $rs_chk_id1 = mysql_query($sql); - + if ($rs_chk_id1 === false) { error_log('Could not query settings_current ids table: '.mysql_error()); - } else { + } else { $i = 1; while ($row_id1 = mysql_fetch_array($rs_chk_id1)) { $id = $row_id1['id']; - if ($i>1) { + if ($i>1) { $sql_del = "DELETE FROM settings_current WHERE id = '$id'"; mysql_query($sql_del); - } + } $i++; - } + } } - + $sql = "SELECT id FROM settings_current WHERE variable='show_teacher_data' ORDER BY id"; $rs_chk_id2 = mysql_query($sql); - + if ($rs_chk_id2 === false) { error_log('Could not query settings_current ids table: '.mysql_error()); - } else { + } else { $i = 1; while ($row_id2 = mysql_fetch_array($rs_chk_id2)) { $id = $row_id2['id']; - if ($i>1) { + if ($i>1) { $sql_del = "DELETE FROM settings_current WHERE id = '$id'"; mysql_query($sql_del); - } + } $i++; - } + } } } } - // now clean the deprecated id_coach field from the session_rel_course - // table + // now clean the deprecated id_coach field from the session_rel_course + // table $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql','main'); if(count($m_q_list)>0) { @@ -266,7 +266,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) } } } - + //get the stats queries list (s_q_list) $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','stats'); @@ -363,7 +363,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.6.1-1.8.6.2.inc.php');} if(mysql_num_rows($res)>0) { @@ -406,33 +406,33 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) error_log("In ".$row_course['db_name'].", executed: $query",0); } } - } - + } + // fill description type into course_description table - + $t_course_description = $row_course['db_name'].".course_description"; if($singleDbForm) - { + { $t_course_description = "$prefix{$row_course['db_name']}_course_description"; } // get all ids and update description_type field with them from course_description table $sql_sel = "SELECT id FROM $t_course_description"; $rs_sel = mysql_query($sql_sel); - + if ($rs_sel === false) { error_log('Could not query course_description ids table: '.mysql_error()); - } else { - if (mysql_num_rows($rs_sel) > 0) { + } else { + if (mysql_num_rows($rs_sel) > 0) { while ($row_ids = mysql_fetch_array($rs_sel)) { - $description_id = $row_ids['id']; + $description_id = $row_ids['id']; $sql_upd = "UPDATE $t_course_description SET description_type='$description_id' WHERE id='$description_id'"; mysql_query($sql_upd); - } - } + } + } } - + } } } diff --git a/main/install/update-db-1.8.6.2-1.8.7.inc.php b/main/install/update-db-1.8.6.2-1.8.7.inc.php index 4e0f85b997..979d1ec8a1 100755 --- a/main/install/update-db-1.8.6.2-1.8.7.inc.php +++ b/main/install/update-db-1.8.6.2-1.8.7.inc.php @@ -162,10 +162,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) } } // - - - // now clean the deprecated id_coach field from the session_rel_course - // table + + + // now clean the deprecated id_coach field from the session_rel_course + // table /* $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql','main'); if(count($m_q_list)>0) @@ -193,7 +193,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) } } */ - + //get the stats queries list (s_q_list) $s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','stats'); @@ -296,7 +296,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) mysql_select_db($dbNameForm); $res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} + if($res===false){die('Error while querying the courses list in update_db-1.8.6.2-1.8.7.inc.php');} if(mysql_num_rows($res)>0) { @@ -342,7 +342,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) error_log('Error in '.$query.': '.mysql_error()); } } - } + } } } }