From f1474362cba93fe16998de1eaaa1fad4a15e645f Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 11 Aug 2010 15:56:15 +0300 Subject: [PATCH 1/5] Updating license information for the internationalization library. --- main/inc/lib/internationalization.lib.php | 2 +- main/inc/lib/internationalization_internal.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 98537ccc97..f7aeb01ba4 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -5,7 +5,7 @@ * File: internationalization.lib.php * Internationalization library for Chamilo 1.8.7 LMS * A library implementing internationalization related functions. - * License: GNU/GPL version 2 or later (Free Software Foundation) + * License: GNU General Public License Version 3 (Free Software Foundation) * @author Ivan Tcholakov, , 2009, 2010 * @author More authors, mentioned in the correpsonding fragments of this source. * @package chamilo.library diff --git a/main/inc/lib/internationalization_internal.lib.php b/main/inc/lib/internationalization_internal.lib.php index d823b84926..813259d8d0 100755 --- a/main/inc/lib/internationalization_internal.lib.php +++ b/main/inc/lib/internationalization_internal.lib.php @@ -5,7 +5,7 @@ * File: internationalization_internal.lib.php * Main API extension library for Chamilo 1.8.7 LMS, * contains functions for internal use only. - * License: GNU/GPL version 2 or later (Free Software Foundation) + * License: GNU General Public License Version 3 (Free Software Foundation) * @author Ivan Tcholakov, , 2009, 2010 * @author More authors, mentioned in the correpsonding fragments of this source. * @package chamilo.library From cbf2d50681a4d3760d48ddeb8591129472e88566 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 11 Aug 2010 16:01:47 +0300 Subject: [PATCH 2/5] Updating license information for the internationalization library. --- .../internationalization_database/language_detection/readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 main/inc/lib/internationalization_database/language_detection/readme.txt diff --git a/main/inc/lib/internationalization_database/language_detection/readme.txt b/main/inc/lib/internationalization_database/language_detection/readme.txt old mode 100644 new mode 100755 index 8787798396..55f62a9d14 --- a/main/inc/lib/internationalization_database/language_detection/readme.txt +++ b/main/inc/lib/internationalization_database/language_detection/readme.txt @@ -12,6 +12,6 @@ To understand how does language recognition work you need to read the following W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization. Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis and Information Retrieval, 1994. http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf -License: GNU General Public License (GPL) as published by the Free Software Foundation (http://www.fsf.org/); either version 2 of the License, or (at your option) any later version. +License: GNU General Public License 3 as published by the Free Software Foundation (http://www.fsf.org/). Assembled by Ivan Tcholakov, November, 2009 \ No newline at end of file From 7cf77ea7fb5c6d1b9bbcaf1c5637c6f95ca344f3 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 11 Aug 2010 17:01:56 +0200 Subject: [PATCH 3/5] Partial fix when trying to import qti exercises see BT#1368 --- main/exercice/answer.class.php | 9 +++++- main/exercice/export/exercise_import.inc.php | 5 ++-- main/exercice/export/qti2/qti2_classes.php | 31 ++++++++++---------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index b3592277d8..1df188984b 100755 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -266,11 +266,18 @@ class Answer * @author Yannick Warnier * @return array List of answers where each answer is an array of (id, answer, comment, grade) and grade=weighting */ - function getAnswersList() + function getAnswersList($decode = false) { $list = array(); for($i = 1; $i<=$this->nbrAnswers;$i++){ if(!empty($this->answer[$i])){ + + //Avoid problems when parsing elements with accents + if ($decode) { + $this->answer[$i] = html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); + $this->comment[$i] = html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); + } + $list[] = array( 'id'=>$i, 'answer'=>$this->answer[$i], diff --git a/main/exercice/export/exercise_import.inc.php b/main/exercice/export/exercise_import.inc.php index 2d88651a36..701c9a4360 100755 --- a/main/exercice/export/exercise_import.inc.php +++ b/main/exercice/export/exercise_import.inc.php @@ -195,7 +195,8 @@ function parse_file($exercisePath, $file, $questionFile) { } //parse XML question file - + $data = str_replace(array('

', '

'), '', $data); + //used global variable start values declaration : $record_item_body = false; @@ -533,7 +534,7 @@ function elementData($parser, $data) { if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); } else { - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ' ' . trim($data); + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); } } break; diff --git a/main/exercice/export/qti2/qti2_classes.php b/main/exercice/export/qti2/qti2_classes.php index 2d4613c839..009d4ac2b8 100755 --- a/main/exercice/export/qti2/qti2_classes.php +++ b/main/exercice/export/qti2/qti2_classes.php @@ -96,12 +96,13 @@ class ImsAnswerMultipleChoice extends Answer */ function imsExportResponses($questionIdent, $questionStatment) { - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $out = ' ' . "\n"; $out .= ' ' . $questionStatment . ' '. "\n"; if (is_array($this->answerList)) { - foreach ($this->answerList as $current_answer) - { + foreach ($this->answerList as $current_answer) { + + $out .= ' ' . $current_answer['answer']; if (isset($current_answer['comment']) && $current_answer['comment'] != '') { @@ -120,7 +121,7 @@ class ImsAnswerMultipleChoice extends Answer */ function imsExportResponsesDeclaration($questionIdent) { - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $type = $this->getQuestionType(); if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; @@ -130,8 +131,7 @@ class ImsAnswerMultipleChoice extends Answer $out .= ' '. "\n"; if (is_array($this->answerList)) { - foreach($this->answerList as $current_answer) - { + foreach($this->answerList as $current_answer) { if ($current_answer['correct']) { $out .= ' answer_'. $current_answer['id'] .''. "\n"; @@ -170,7 +170,7 @@ class ImsAnswerFillInBlanks extends Answer function imsExportResponses($questionIdent, $questionStatment) { global $charset; - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); //switch ($this->type) //{ @@ -179,8 +179,7 @@ class ImsAnswerFillInBlanks extends Answer $text = ''; $text .= $this->answerText; if (is_array($this->answerList)) { - foreach ($this->answerList as $key=>$answer) - { + foreach ($this->answerList as $key=>$answer) { $key = $answer['id']; $answer = $answer['answer']; $len = api_strlen($answer); @@ -243,12 +242,12 @@ class ImsAnswerFillInBlanks extends Answer function imsExportResponsesDeclaration($questionIdent) { - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $this->gradeList = $this->getGradesList(); $out = ''; if (is_array($this->answerList)) { - foreach ($this->answerList as $answerKey=>$answer) - { + foreach ($this->answerList as $answerKey=>$answer) { + $answerKey = $answer['id']; $answer = $answer['answer']; $out .= ' ' . "\n"; @@ -296,7 +295,7 @@ class ImsAnswerMatching extends Answer */ function imsExportResponses($questionIdent, $questionStatment) { - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $maxAssociation = max(count($this->leftList), count($this->rightList)); $out = ""; @@ -341,7 +340,7 @@ class ImsAnswerMatching extends Answer */ function imsExportResponsesDeclaration($questionIdent) { - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $out = ' ' . "\n"; $out .= ' ' . "\n"; @@ -387,7 +386,7 @@ class ImsAnswerHotspot extends Answer function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') { global $charset; - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; $mimetype = mime_content_type($questionMedia); if(empty($mimetype)){ @@ -446,7 +445,7 @@ class ImsAnswerHotspot extends Answer function imsExportResponsesDeclaration($questionIdent) { - $this->answerList = $this->getAnswersList(); + $this->answerList = $this->getAnswersList(true); $this->gradeList = $this->getGradesList(); $out = ''; $out .= ' ' . "\n"; From 89224a077ac1fa0746c28676fcf4feac19d43b1e Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 11 Aug 2010 19:15:36 +0300 Subject: [PATCH 4/5] Feature #747 - The function api_parse_tex() and _text_parse_texexplorer() have been announced as deprecated. All the parsers inside the function text_filter() have been disabled, because their code is old. --- main/inc/lib/text.lib.php | 87 ++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/main/inc/lib/text.lib.php b/main/inc/lib/text.lib.php index d891055411..7550f1a7f2 100755 --- a/main/inc/lib/text.lib.php +++ b/main/inc/lib/text.lib.php @@ -304,21 +304,6 @@ function make_clickable($string) { return $string; } -/** - * Applies parsing the content for tex commands that are separated by [tex] - * [/tex] to make it readable for techexplorer plugin. - * @param string $text The text to parse - * @return string The text after parsing. - * @author Patrick Cool - * @version June 2004 - */ -function api_parse_tex($textext) { - if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { - return str_replace(array('[tex]', '[/tex]'), array(""), $textext); - } - return str_replace(array('[tex]', '[/tex]'), array(""), $textext); -} - /** * @desc This function does some parsing on the text that gets inputted. This parsing can be of any kind * LaTeX notation, Word Censoring, Glossary Terminology (extension will available soon), Musical Notations, ... @@ -337,7 +322,7 @@ function text_filter($input, $filter = true) { // *** parse [tex]...[/tex] tags *** // // which will return techexplorer or image html depending on the capabilities of the // browser of the user (using some javascript that checks if the browser has the TechExplorer plugin installed or not) - $input = _text_parse_tex($input); + //$input = _text_parse_tex($input); // *** parse [teximage]...[/teximage] tags *** // // these force the gif rendering of LaTeX using the mimetex gif renderer @@ -345,7 +330,7 @@ function text_filter($input, $filter = true) { // *** parse [texexplorer]...[/texexplorer] tags *** // // these force the texeplorer LaTeX notation - $input = _text_parse_texexplorer($input); + //$input = _text_parse_texexplorer($input); // *** Censor Words *** // // censor words. This function removes certain words by [censored] @@ -354,7 +339,7 @@ function text_filter($input, $filter = true) { // *** parse [?]...[/?] tags *** // // for the glossary tool - $input = _text_parse_glossary($input); + //$input = _text_parse_glossary($input); // parse [wiki]...[/wiki] tags // this is for the coolwiki plugin. @@ -402,24 +387,6 @@ function _text_parse_tex($textext) { return $output; } -/** - * Applies parsing for tex commandos that are seperated by [tex] - * [/tex] to make it readable for techexplorer plugin. - * This function should not be accessed directly but should be accesse through the text_filter function - * @param string $text The text to parse - * @return string The text after parsing. - * @author Patrick Cool - * @version June 2004 - */ -function _text_parse_texexplorer($textext) { - if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { - $textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array(""), $textext); - } else { - $textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array(""), $textext); - } - return $textext; -} - /** * This function should not be accessed directly but should be accesse through the text_filter function * @author Patrick Cool @@ -454,10 +421,10 @@ function latex_gif_renderer($latex_code) { $latex_filename = md5($latex_code).'.gif'; if (!file_exists($temp_path.$latex_filename) OR isset($_GET['render'])) { - if ((PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows")) { + if (IS_WINDOWS_OS) { $mimetex_command = $mimetex_path.'mimetex.exe -e "'.$temp_path.md5($latex_code).'.gif" '.escapeshellarg($latex_code).''; } else { - $mimetex_command = $mimetex_path.'mimetex.linux -e "'.$temp_path.md5($latex_code).'.gif" '.escapeshellarg($latex_code); + $mimetex_command = $mimetex_path.'mimetex.cgi -e "'.$temp_path.md5($latex_code).'.gif" '.escapeshellarg($latex_code); } exec($mimetex_command); //echo 'volgende shell commando werd uitgevoerd:
'.$mimetex_command.'

'; @@ -529,3 +496,47 @@ function get_last_week() { } return $arrdays; } + + +/** + * Deprecated functions + */ + +/** + * Applies parsing the content for tex commands that are separated by [tex] + * [/tex] to make it readable for techexplorer plugin. + * @param string $text The text to parse + * @return string The text after parsing. + * @author Patrick Cool + * @version June 2004 + */ +function api_parse_tex($textext) { + /* + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { + return str_replace(array('[tex]', '[/tex]'), array(""), $textext); + } + return str_replace(array('[tex]', '[/tex]'), array(""), $textext); + */ + return $textext; +} + +/** + * Applies parsing for tex commandos that are seperated by [tex] + * [/tex] to make it readable for techexplorer plugin. + * This function should not be accessed directly but should be accesse through the text_filter function + * @param string $text The text to parse + * @return string The text after parsing. + * @author Patrick Cool + * @version June 2004 + */ +function _text_parse_texexplorer($textext) { + /* + if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { + $textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array(""), $textext); + } else { + $textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array(""), $textext); + } + return $textext; + */ + return $textext; +} From 992bea3b9a3ba5c7ed7cd3c40f5a70435652b884 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 11 Aug 2010 20:50:19 +0300 Subject: [PATCH 5/5] Cleaning the newly added upgrade scripts from old code, as much as it is possible. --- main/install/update-db-1.8.7-1.8.8.inc.php | 281 +----------------- main/install/update-files-1.8.7-1.8.8.inc.php | 2 +- 2 files changed, 14 insertions(+), 269 deletions(-) diff --git a/main/install/update-db-1.8.7-1.8.8.inc.php b/main/install/update-db-1.8.7-1.8.8.inc.php index 308b4501af..c41804afb9 100755 --- a/main/install/update-db-1.8.7-1.8.8.inc.php +++ b/main/install/update-db-1.8.7-1.8.8.inc.php @@ -17,8 +17,8 @@ * @todo use database library */ -$old_file_version = '1.8.6.2'; -$new_file_version = '1.8.7'; +$old_file_version = '1.8.7'; +$new_file_version = '1.8.8'; // Check if we come from index.php or update_courses.php - otherwise display error msg if (defined('SYSTEM_INSTALLATION')) { @@ -100,125 +100,16 @@ if (defined('SYSTEM_INSTALLATION')) { } } } - $tables = Database::get_tables($dbNameForm); - foreach ($tables as $table) { - $query = "ALTER TABLE `".$table."` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - } - $query = "ALTER DATABASE `".$dbNameForm."` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - } - } - - // Converting dates and times to UTC using the default timezone of PHP - // Converting gradebook dates and times - $timezone = date_default_timezone_get(); - // Calculating the offset - $dateTimeZoneCurrent = new DateTimeZone($timezone); - $dateTimeUTC = new DateTime("now", new DateTimeZone('UTC')); - $timeOffsetSeconds = $dateTimeZoneCurrent->getOffset($dateTimeUTC); - $timeOffsetHours = $timeOffsetSeconds / 3600; - $timeOffsetString = ""; - - if($timeOffsetHours < 0) { - $timeOffsetString .= "-"; - $timeOffsetHours = abs($timeOffsetHours); - } else { - $timeOffsetString .= "+"; - } - - if($timeOffsetHours < 10) { - $timeOffsetString .= "0"; - } - - $timeOffsetString .= "$timeOffsetHours"; - $timeOffsetString .= ":00"; - - // Executing the queries to convert everything - $queries[] = "UPDATE gradebook_certificate SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_evaluation SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_link SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_linkeval_log SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_result SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_result_log SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - - foreach ($queries as $query) { - Database::query($query); - } - - // Moving user followed by a human resource manager from hr_dept_id field to user_rel_user table - $query = "SELECT user_id, hr_dept_id FROM $dbNameForm.user"; - $result = Database::query($query); - if (Database::num_rows($result) > 0) { - require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; - while ($row = Database::fetch_array($result, 'ASSOC')) { - $user_id = $row['user_id']; - $hr_dept_id = $row['hr_dept_id']; - // moving data to user_rel_user table - if (!empty($hr_dept_id)) { - $sql = " SELECT id FROM $dbNameForm.user_rel_user WHERE user_id = $user_id AND friend_user_id = $hr_dept_id AND relation_type = ".USER_RELATION_TYPE_RRHH." "; - $rs = Database::query($sql); - if (Database::num_rows($rs) == 0) { - $ins = "INSERT INTO $dbNameForm.user_rel_user SET user_id = $user_id, friend_user_id = $hr_dept_id, relation_type = ".USER_RELATION_TYPE_RRHH." "; - Database::query($ins); - } - } - } - // cleaning hr_dept_id field inside user table - $upd = "UPDATE $dbNameForm.user SET hr_dept_id = 0"; - Database::query($upd); - } - - // Updating score display for each gradebook category - - // first we check if there already is migrated data to categoy_id field - $query = "SELECT id FROM $dbNameForm.gradebook_score_display WHERE category_id = 0"; - $rs_check = Database::query($query); - - if (Database::num_rows($rs_check) > 0) { - // get all gradebook categories id - $a_categories = array(); - $query = "SELECT id FROM $dbNameForm.gradebook_category"; - $rs_gradebook = Database::query($query); - if (Database::num_rows($rs_gradebook) > 0) { - while($row_gradebook = Database::fetch_row($rs_gradebook)) { - $a_categories[] = $row_gradebook[0]; - } - } - - // get all gradebook score display - $query = "SELECT * FROM $dbNameForm.gradebook_score_display"; - $rs_score_display = Database::query($query); - if (Database::num_rows($rs_score_display) > 0) { - $score_color_percent = api_get_setting('gradebook_score_display_colorsplit'); - while ($row_score_display = Database::fetch_array($rs_score_display)) { - $score = $row_score_display['score']; - $display = $row_score_display['display']; - foreach ($a_categories as $category_id) { - $ins = "INSERT INTO $dbNameForm.gradebook_score_display(score, display, category_id, score_color_percent) VALUES('$score', '$display', $category_id, '$score_color_percent')"; - Database::query($ins); - } - } - // remove score display with category id = 0 - $del = "DELETE FROM $dbNameForm.gradebook_score_display WHERE category_id = 0"; - Database::query($del); } } - // Now clean the deprecated id_coach field from the session_rel_course table + /* // This fragment of code is not necessary so far. + // Get the main queries list (m_q_list) $m_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'main'); if (count($m_q_list) > 0) { // Now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ + // We connect to the right DB first to make sure we can use the queries + // without a database name. if (strlen($dbNameForm) > 40) { error_log('Database name '.$dbNameForm.' is too long, skipping', 0); } elseif (!in_array($dbNameForm,$dblist)) { @@ -237,6 +128,7 @@ if (defined('SYSTEM_INSTALLATION')) { } } } + */ // 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'); @@ -266,61 +158,11 @@ if (defined('SYSTEM_INSTALLATION')) { } } } - $tables = Database::get_tables($dbStatsForm); - foreach ($tables as $table) { - $query = "ALTER TABLE `".$table."` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - } - $query = "ALTER DATABASE `".$dbStatsForm."` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - - - // chamilo_stat.track_e_attempt table update changing id by id_auto - - $sql = "SELECT exe_id, question_id, course_code, answer FROM $dbStatsForm.track_e_attempt"; - $result = Database::query($sql); - if (Database::num_rows($result) > 0) { - while ($row = Database::fetch_array($result)) { - $course_code = $row['course_code']; - $course_info = api_get_course_info($course_code); - $my_course_db = $course_info['dbName']; - $question_id = $row['question_id']; - $answer = $row['answer']; - $exe_id = $row['exe_id']; - - //getting the type question id - $sql_question = "SELECT type FROM $my_course_db.quiz_question where id = $question_id"; - $res_question = Database::query($sql_question); - $row = Database::fetch_array($res_question); - $type = $row['type']; - - require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php'; - //this type of questions produce problems in the track_e_attempt table - if (in_array($type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MATCHING, MULTIPLE_ANSWER_COMBINATION))) { - $sql_question = "SELECT id_auto FROM $my_course_db.quiz_answer where question_id = $question_id and id = $answer"; - $res_question = Database::query($sql_question); - $row = Database::fetch_array($res_question); - $id_auto = $row['id_auto']; - if (!empty($id_auto)) { - $sql = "UPDATE $dbStatsForm.track_e_attempt SET answer = '$id_auto' WHERE exe_id = $exe_id AND question_id = $question_id AND course_code = '$course_code' and answer = $answer "; - Database::query($sql); - } - } - } - } - } } - // Get the user queries list (u_q_list) $u_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'user'); if (count($u_q_list) > 0) { @@ -346,19 +188,6 @@ if (defined('SYSTEM_INSTALLATION')) { } } } - $tables = Database::get_tables($dbUserForm); - foreach ($tables as $table) { - $query = "ALTER TABLE `".$table."` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - } - $query = "ALTER DATABASE `".$dbUserForm."` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } } } // The SCORM database doesn't need a change in the pre-migrate part - ignore @@ -418,95 +247,12 @@ if (defined('SYSTEM_INSTALLATION')) { } } - if (!$singleDbForm) { - $tables = Database::get_tables($row_course['db_name']); - foreach ($tables as $table) { - $query = "ALTER TABLE `".$table."` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - } - $query = "ALTER DATABASE `".$row_course['db_name']."` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"; - $res = Database::query($query); - if ($res === false) { - error_log('Error in '.$query.': '.Database::error()); - } - } - $t_student_publication = $row_course['db_name'].".student_publication"; - $t_item_property = $row_course['db_name'].".item_property"; - - if ($singleDbForm) { - $t_student_publication = "$prefix{$row_course['db_name']}_student_publication"; - $t_item_property = "$prefix{$row_course['db_name']}_item_property"; - } - - $sql_insert_user = "SELECT ref, insert_user_id FROM $t_item_property WHERE tool='work'"; - - $rs_insert_user = Database::query($sql_insert_user); - - if ($rs_insert_user === false) { - error_log('Could not query insert_user_id table: '.Database::error()); - } else { - if (Database::num_rows($rs_insert_user) > 0) { - while ($row_ids = Database::fetch_array($rs_insert_user)) { - $user_id = $row_ids['insert_user_id']; - $ref = $row_ids['ref']; - $sql_upd = "UPDATE $t_student_publication SET user_id='$user_id' WHERE id='$ref'"; - Database::query($sql_upd); - } - } - } - - //updating parent_id of the student_publication table - $sql = 'SELECT id, url, parent_id FROM '.$t_student_publication; - $result = Database::query($sql); - if (Database::num_rows($result) > 0) { - $items = api_store_result($result); - $directory_list = $file_list=array(); - - foreach($items as $item) { - $student_slash = substr($item['url'], 0, 1); - //means this is a directory - if ($student_slash == '/') { - $directory_list[$item['id']]= $item['url']; - } else { - // this is a file with no parents - if ($item['parent_id'] == 0) - $file_list []= $item; - } - } - - if (is_array($file_list) && count($file_list) > 0) { - foreach ($file_list as $file) { - $parent_id = 0; - if (is_array($directory_list) && count($directory_list) > 0) { - foreach($directory_list as $id => $dir) { - $pos = strpos($file['url'], $dir.'/'); - if ($pos !== false) { - $parent_id = $id; - break; - } - } - } - - if ($parent_id != 0 ) { - $sql = 'UPDATE '.$t_student_publication.' SET parent_id = '.$parent_id.' WHERE id = '.$file['id'].''; - Database::query($sql); - } - } - } - } - - - - - - } } } } + + /* // This fragment of code is not necessary so far. // Get the courses databases queries list (c_q_list) $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'course'); if (count($c_q_list) > 0) { @@ -518,7 +264,7 @@ if (defined('SYSTEM_INSTALLATION')) { } else { Database::select_db($dbNameForm); $res = Database::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-1.8.6.2-1.8.7.inc.php'); } + if ($res === false) { die('Error while querying the courses list in update_db-1.8.7-1.8.8.inc.php'); } if (Database::num_rows($res) > 0) { $i = 0; while ($row = Database::fetch_array($res)) { @@ -527,10 +273,8 @@ if (defined('SYSTEM_INSTALLATION')) { } foreach ($list as $row) { // Now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ + // We connect to the right DB first to make sure we can use the queries + // without a database name $prefix_course = $prefix; if ($singleDbForm) { $prefix_course = $prefix.$row['db_name']."_"; @@ -555,6 +299,7 @@ if (defined('SYSTEM_INSTALLATION')) { } } } + */ } else { diff --git a/main/install/update-files-1.8.7-1.8.8.inc.php b/main/install/update-files-1.8.7-1.8.8.inc.php index c008f6997d..648e9aaa66 100755 --- a/main/install/update-files-1.8.7-1.8.8.inc.php +++ b/main/install/update-files-1.8.7-1.8.8.inc.php @@ -4,7 +4,7 @@ /** * Chamilo LMS * - * Updates the Chamilo files from version 1.8.6.2 to version 1.8.7 + * Updates the Chamilo files from version 1.8.7 to version 1.8.8 * This script operates only in the case of an update, and only to change the * active version number (and other things that might need a change) in the * current configuration file.