Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2487/head
jmontoyaa 8 years ago
commit d0196d44b8
  1. 8
      main/exercise/answer.class.php
  2. 4
      main/exercise/question.class.php
  3. 8
      main/gradebook/lib/be/category.class.php
  4. 3
      main/inc/lib/document.lib.php
  5. 6
      main/inc/lib/sessionmanager.lib.php
  6. 7
      main/lp/aicc.class.php
  7. 26
      main/lp/learnpathItem.class.php
  8. 67
      main/survey/surveyUtil.class.php
  9. 74
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

@ -836,13 +836,13 @@ class Answer
foreach ($temp as $index => $answer) { foreach ($temp as $index => $answer) {
if ($this->course['id'] != $course_info['id']) { if ($this->course['id'] != $course_info['id']) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['answer'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['answer'], $answer['answer'],
$this->course['id'], $this->course['id'],
$course_info['id'] $course_info['id']
); );
$answer['comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['comment'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['comment'], $answer['comment'],
$this->course['id'], $this->course['id'],
$course_info['id'] $course_info['id']
@ -882,12 +882,12 @@ class Answer
} else { } else {
for ($i = 1; $i <= $this->nbrAnswers; $i++) { for ($i = 1; $i <= $this->nbrAnswers; $i++) {
if ($this->course['id'] != $course_info['id']) { if ($this->course['id'] != $course_info['id']) {
$this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $this->answer[$i] = DocumentManager::replaceUrlWithNewCourseCode(
$this->answer[$i], $this->answer[$i],
$this->course['id'], $this->course['id'],
$course_info['id'] $course_info['id']
); );
$this->comment[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $this->comment[$i] = DocumentManager::replaceUrlWithNewCourseCode(
$this->comment[$i], $this->comment[$i],
$this->course['id'], $this->course['id'],
$course_info['id'] $course_info['id']

@ -1439,12 +1439,12 @@ abstract class Question
// Using the same method used in the course copy to transform URLs // Using the same method used in the course copy to transform URLs
if ($this->course['id'] != $course_info['id']) { if ($this->course['id'] != $course_info['id']) {
$description = DocumentManager::replace_urls_inside_content_html_from_copy_course( $description = DocumentManager::replaceUrlWithNewCourseCode(
$description, $description,
$this->course['code'], $this->course['code'],
$course_info['id'] $course_info['id']
); );
$question = DocumentManager::replace_urls_inside_content_html_from_copy_course( $question = DocumentManager::replaceUrlWithNewCourseCode(
$question, $question,
$this->course['code'], $this->course['code'],
$course_info['id'] $course_info['id']

@ -25,7 +25,6 @@ class Category implements GradebookItem
private $generateCertificates; private $generateCertificates;
private $isRequirement; private $isRequirement;
public $studentList; public $studentList;
public $evaluations; public $evaluations;
public $links; public $links;
public $subCategories; public $subCategories;
@ -276,7 +275,6 @@ class Category implements GradebookItem
{ {
if ($from_db) { if ($from_db) {
$cat_id = $this->get_id(); $cat_id = $this->get_id();
$gradebook = new Gradebook(); $gradebook = new Gradebook();
$skills = $gradebook->get_skills_by_gradebook($cat_id); $skills = $gradebook->get_skills_by_gradebook($cat_id);
} else { } else {
@ -463,7 +461,6 @@ class Category implements GradebookItem
} }
$result = Database::query($sql); $result = Database::query($sql);
$categories = array(); $categories = array();
if (Database::num_rows($result) > 0) { if (Database::num_rows($result) > 0) {
$categories = self::create_category_objects_from_sql_result( $categories = self::create_category_objects_from_sql_result(
@ -666,7 +663,10 @@ class Category implements GradebookItem
$parent_id = $this->get_parent_id(); $parent_id = $this->get_parent_id();
$grade_model_id = $this->get_grade_model_id(); $grade_model_id = $this->get_grade_model_id();
if ($parent_id == 0) { if ($parent_id == 0) {
if (isset($grade_model_id) && !empty($grade_model_id) && $grade_model_id != '-1') { if (isset($grade_model_id) &&
!empty($grade_model_id) &&
$grade_model_id != '-1'
) {
$obj = new GradeModel(); $obj = new GradeModel();
$components = $obj->get_components($grade_model_id); $components = $obj->get_components($grade_model_id);
$default_weight_setting = api_get_setting('gradebook_default_weight'); $default_weight_setting = api_get_setting('gradebook_default_weight');

@ -2587,7 +2587,7 @@ class DocumentManager
* *
* @return string new content html with replaced urls or return false if content is not a string * @return string new content html with replaced urls or return false if content is not a string
*/ */
public static function replace_urls_inside_content_html_from_copy_course( public static function replaceUrlWithNewCourseCode(
$content_html, $content_html,
$origin_course_code, $origin_course_code,
$destination_course_directory, $destination_course_directory,
@ -2621,7 +2621,6 @@ class DocumentManager
if (!empty($orig_source_html)) { if (!empty($orig_source_html)) {
foreach ($orig_source_html as $source) { foreach ($orig_source_html as $source) {
// Get information about source url // Get information about source url
$real_orig_url = $source[0]; // url $real_orig_url = $source[0]; // url
$scope_url = $source[1]; // scope (local, remote) $scope_url = $source[1]; // scope (local, remote)

@ -7602,6 +7602,8 @@ class SessionManager
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$sessionCourseUserTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $sessionCourseUserTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$tbl_session_field_options = Database::get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
$where = 'WHERE 1 = 1 '; $where = 'WHERE 1 = 1 ';
$user_id = api_get_user_id(); $user_id = api_get_user_id();
@ -7612,6 +7614,7 @@ class SessionManager
$where .= " WHERE s.session_admin_id = $user_id "; $where .= " WHERE s.session_admin_id = $user_id ";
} }
$extraFieldTables = '';
if (!empty($options['where'])) { if (!empty($options['where'])) {
$options['where'] = str_replace('course_title', 'c.title', $options['where']); $options['where'] = str_replace('course_title', 'c.title', $options['where']);
$options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']); $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']);
@ -7634,6 +7637,7 @@ class SessionManager
foreach ($options['extra'] as $extra) { foreach ($options['extra'] as $extra) {
$options['where'] = str_replace($extra['field'], 'fv.field_id = '.$extra['id'].' AND fvo.option_value', $options['where']); $options['where'] = str_replace($extra['field'], 'fv.field_id = '.$extra['id'].' AND fvo.option_value', $options['where']);
$extraFieldTables = "$tbl_session_field_values fv, $tbl_session_field_options fvo, ";
} }
} }
$where .= ' AND '.$options['where']; $where .= ' AND '.$options['where'];
@ -7648,7 +7652,7 @@ class SessionManager
(s.access_start_date <= '$today' AND ('0000-00-00 00:00:00' = s.access_end_date OR s.access_end_date IS NULL )) OR (s.access_start_date <= '$today' AND ('0000-00-00 00:00:00' = s.access_end_date OR s.access_end_date IS NULL )) OR
('$today' < s.access_end_date AND ('0000-00-00 00:00:00' = s.access_start_date OR s.access_start_date IS NULL) ) ('$today' < s.access_end_date AND ('0000-00-00 00:00:00' = s.access_start_date OR s.access_start_date IS NULL) )
, 1, 0) as session_active , 1, 0) as session_active
FROM $tbl_session s FROM $extraFieldTables $tbl_session s
LEFT JOIN $tbl_session_category sc LEFT JOIN $tbl_session_category sc
ON s.session_category_id = sc.id ON s.session_category_id = sc.id
INNER JOIN $tbl_user u INNER JOIN $tbl_user u

@ -33,9 +33,12 @@ class aicc extends learnpath
public $cstlist = array(); public $cstlist = array();
public $orelist = array(); public $orelist = array();
// Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package. // Path between the scorm/ directory and the config files
// e.g. maritime_nav/maritime_nav.
// This is the path that will be used in the lp_path when importing a package.
public $subdir = ''; public $subdir = '';
// Keeps the zipfile safe for the object's life so that we can use it if there is no title available. // Keeps the zipfile safe for the object's life
// so that we can use it if there is no title available.
public $zipname = ''; public $zipname = '';
// Keeps an index of the number of uses of the zipname so far. // Keeps an index of the number of uses of the zipname so far.
public $lastzipnameindex = 0; public $lastzipnameindex = 0;

@ -789,9 +789,14 @@ class learnpathItem
error_log('learnpathItem::get_max()', 0); error_log('learnpathItem::get_max()', 0);
} }
if ($this->type == 'sco') { if ($this->type == 'sco') {
if (isset($this->view_max_score) && !empty($this->view_max_score) && $this->view_max_score > 0) { if (isset($this->view_max_score) &&
!empty($this->view_max_score) &&
$this->view_max_score > 0
) {
return $this->view_max_score; return $this->view_max_score;
} elseif (isset($this->view_max_score) && $this->view_max_score === '') { } elseif (isset($this->view_max_score) &&
$this->view_max_score === ''
) {
return $this->view_max_score; return $this->view_max_score;
} else { } else {
if (!empty($this->max_score)) { if (!empty($this->max_score)) {
@ -996,7 +1001,7 @@ class learnpathItem
* objects, java applets, or any other stuff included in the source of the * objects, java applets, or any other stuff included in the source of the
* current item. The current item is expected to be an HTML file. If it * current item. The current item is expected to be an HTML file. If it
* is not, then the function will return and empty list. * is not, then the function will return and empty list.
* @param string $type type (one of the Chamilo tools) - optional (otherwise takes the current item's type) * @param string $type (one of the Chamilo tools) - optional (otherwise takes the current item's type)
* @param string $abs_path absolute file path - optional (otherwise takes the current item's path) * @param string $abs_path absolute file path - optional (otherwise takes the current item's path)
* @param int $recursivity level of recursivity we're in * @param int $recursivity level of recursivity we're in
* @return array List of file paths. * @return array List of file paths.
@ -2339,7 +2344,6 @@ class learnpathItem
return $mycond; return $mycond;
} }
} else { } else {
// Nothing found there either. Now return the // Nothing found there either. Now return the
// value of the corresponding resource completion status. // value of the corresponding resource completion status.
if (self::DEBUG > 1) { if (self::DEBUG > 1) {
@ -3097,10 +3101,12 @@ class learnpathItem
} }
/** /**
* Sets the prevent_reinit attribute. This is based on the LP value and is set at creation time for * Sets the prevent_reinit attribute.
* each learnpathItem. It is a (bad?) way of avoiding a reference to the LP when saving an item. * This is based on the LP value and is set at creation time for
* @param integer 1 for "prevent", 0 for "don't prevent" saving freshened values (new "not attempted" status etc) * each learnpathItem. It is a (bad?) way of avoiding
* @return void * a reference to the LP when saving an item.
* @param int 1 for "prevent", 0 for "don't prevent"
* saving freshened values (new "not attempted" status etc)
*/ */
public function set_prevent_reinit($prevent) public function set_prevent_reinit($prevent)
{ {
@ -3271,7 +3277,6 @@ class learnpathItem
* Sets the item viewing time in a usable form, given that SCORM packages * Sets the item viewing time in a usable form, given that SCORM packages
* often give it as 00:00:00.0000 * often give it as 00:00:00.0000
* @param string Time as given by SCORM * @param string Time as given by SCORM
* @return void
*/ */
public function set_time($scorm_time, $format = 'scorm') public function set_time($scorm_time, $format = 'scorm')
{ {
@ -3322,7 +3327,6 @@ class learnpathItem
/** /**
* Sets the item's title * Sets the item's title
* @param string $string Title * @param string $string Title
* @return void
*/ */
public function set_title($string = '') public function set_title($string = '')
{ {
@ -3539,7 +3543,7 @@ class learnpathItem
WHERE c_id = ' . $course_id.' WHERE c_id = ' . $course_id.'
AND lp_item_id="' . $this->db_id.'" AND lp_item_id="' . $this->db_id.'"
AND lp_view_id="' . $this->view_id.'" AND lp_view_id="' . $this->view_id.'"
AND view_count="' . $this->attempt_id.'" ;'; AND view_count="' . $this->attempt_id.'"';
Database::query($sql); Database::query($sql);
} }

@ -500,7 +500,12 @@ class SurveyUtil
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'">'. echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon(
'back.png',
get_lang('BackTo').' '.get_lang('ReportingOverview'),
'',
ICON_SIZE_MEDIUM
).'</a>';
echo '</div>'; echo '</div>';
if ($survey_data['number_of_questions'] > 0) { if ($survey_data['number_of_questions'] > 0) {
@ -531,12 +536,11 @@ class SurveyUtil
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".Database::escape_string($_GET['survey_id'])."' AND survey_id='".Database::escape_string($_GET['survey_id'])."' AND
type<>'pagebreak' AND type<>'comment' type <>'pagebreak' AND
type <>'comment'
ORDER BY sort ASC ORDER BY sort ASC
$limitStatement"; $limitStatement";
$result = Database::query($sql); $result = Database::query($sql);
//$question = Database::fetch_array($result);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$questions[$row['question_id']] = $row; $questions[$row['question_id']] = $row;
} }
@ -702,7 +706,6 @@ class SurveyUtil
// Database table definitions // Database table definitions
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Getting the options // Getting the options
@ -718,7 +721,8 @@ class SurveyUtil
} }
// Getting the answers // Getting the answers
$sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer $sql = "SELECT *, count(answer_id) as total
FROM $table_survey_answer
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
survey_id='".Database::escape_string($_GET['survey_id'])."' AND survey_id='".Database::escape_string($_GET['survey_id'])."' AND
@ -847,7 +851,9 @@ class SurveyUtil
$display_extra_user_fields = false; $display_extra_user_fields = false;
if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] || if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] ||
isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter'])) { isset($_POST['export_report']) && $_POST['export_report']) ||
!empty($_POST['fields_filter'])
) {
// Show user fields section with a big th colspan that spans over all fields // Show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false, true); $extra_user_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false, true);
$num = count($extra_user_fields); $num = count($extra_user_fields);
@ -1287,7 +1293,6 @@ class SurveyUtil
if ($survey_data['anonymous'] == 0) { if ($survey_data['anonymous'] == 0) {
if (intval($user) !== 0) { if (intval($user) !== 0) {
$userInfo = api_get_user_info($user); $userInfo = api_get_user_info($user);
if (!empty($userInfo)) { if (!empty($userInfo)) {
$user_displayed = $userInfo['complete_name_with_username']; $user_displayed = $userInfo['complete_name_with_username'];
} else { } else {
@ -1627,7 +1632,10 @@ class SurveyUtil
$my_answers_of_user = isset($answers_of_user[$question_id]) ? $answers_of_user[$question_id] : []; $my_answers_of_user = isset($answers_of_user[$question_id]) ? $answers_of_user[$question_id] : [];
$key = array_keys($my_answers_of_user); $key = array_keys($my_answers_of_user);
if (isset($key[0]) && substr($key[0], 0, 4) == 'open') { if (isset($key[0]) && substr($key[0], 0, 4) == 'open') {
$return[] = api_html_entity_decode(strip_tags($answers_of_user[$question_id][$key[0]]['option_id']), ENT_QUOTES); $return[] = api_html_entity_decode(
strip_tags($answers_of_user[$question_id][$key[0]]['option_id']),
ENT_QUOTES
);
} elseif (!empty($answers_of_user[$question_id][$option_id])) { } elseif (!empty($answers_of_user[$question_id][$option_id])) {
if ($answers_of_user[$question_id][$option_id]['value'] != 0) { if ($answers_of_user[$question_id][$option_id]['value'] != 0) {
$return[] = $answers_of_user[$question_id][$option_id]['value']; $return[] = $answers_of_user[$question_id][$option_id]['value'];
@ -1646,9 +1654,12 @@ class SurveyUtil
} }
/** /**
* This function displays the comparative report which allows you to compare two questions * This function displays the comparative report which
* A comparative report creates a table where one question is on the x axis and a second question is on the y axis. * allows you to compare two questions
* In the intersection is the number of people who have answerd positive on both options. * A comparative report creates a table where one question
* is on the x axis and a second question is on the y axis.
* In the intersection is the number of people who have
* answered positive on both options.
* *
* @return string HTML code * @return string HTML code
* *
@ -1903,8 +1914,10 @@ class SurveyUtil
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$sql = "SELECT * FROM $table_survey_answer $sql = "SELECT * FROM $table_survey_answer
WHERE c_id = $course_id AND survey_id='".intval($survey_id)."' WHERE
AND question_id='".intval($question_id)."' c_id = $course_id AND
survey_id='".intval($survey_id)."' AND
question_id='".intval($question_id)."'
ORDER BY USER ASC"; ORDER BY USER ASC";
$result = Database::query($sql); $result = Database::query($sql);
$return = []; $return = [];
@ -1956,7 +1969,9 @@ class SurveyUtil
// Check if the user has given $option_x as answer // Check if the user has given $option_x as answer
if (in_array($check_x, $answers)) { if (in_array($check_x, $answers)) {
// Check if the user has given $option_y as an answer // Check if the user has given $option_y as an answer
if (!is_null($answers_y[$user]) && in_array($check_y, $answers_y[$user])) { if (!is_null($answers_y[$user]) &&
in_array($check_y, $answers_y[$user])
) {
$counter++; $counter++;
} }
} }
@ -2063,7 +2078,8 @@ class SurveyUtil
} }
/** /**
* This function saves all the invitations of course users and additional users in the database * This function saves all the invitations of course users
* and additional users in the database
* and sends the invitations by email * and sends the invitations by email
* *
* @param $users_array Users $array array can be both a list of course uids AND a list of additional emailaddresses * @param $users_array Users $array array can be both a list of course uids AND a list of additional emailaddresses
@ -2213,7 +2229,8 @@ class SurveyUtil
) { ) {
$insertId = Database::insert($table, $params); $insertId = Database::insert($table, $params);
if ($insertId) { if ($insertId) {
$sql = "UPDATE $table SET survey_invitation_id = $insertId $sql = "UPDATE $table
SET survey_invitation_id = $insertId
WHERE iid = $insertId"; WHERE iid = $insertId";
Database::query($sql); Database::query($sql);
} }
@ -2871,7 +2888,10 @@ class SurveyUtil
$array[8] = $survey[8]; $array[8] = $survey[8];
if ($mandatoryAllowed) { if ($mandatoryAllowed) {
$efvMandatory = $efv->get_values_by_handler_and_field_variable($survey[9], 'is_mandatory'); $efvMandatory = $efv->get_values_by_handler_and_field_variable(
$survey[9],
'is_mandatory'
);
$array[9] = $efvMandatory ? $efvMandatory['value'] : 0; $array[9] = $efvMandatory ? $efvMandatory['value'] : 0;
$array[10] = $survey[9]; $array[10] = $survey[9];
@ -2950,7 +2970,10 @@ class SurveyUtil
while ($survey = Database::fetch_array($res)) { while ($survey = Database::fetch_array($res)) {
if ($mandatoryAllowed) { if ($mandatoryAllowed) {
$survey['col10'] = $survey['col9']; $survey['col10'] = $survey['col9'];
$efvMandatory = $efv->get_values_by_handler_and_field_variable($survey['col9'], 'is_mandatory'); $efvMandatory = $efv->get_values_by_handler_and_field_variable(
$survey['col9'],
'is_mandatory'
);
$survey['col9'] = $efvMandatory['value']; $survey['col9'] = $efvMandatory['value'];
} }
$surveys[] = $survey; $surveys[] = $survey;
@ -3062,7 +3085,8 @@ class SurveyUtil
} }
/** /**
* Creates a multi array with the user fields that we can show. We look the visibility with the api_get_setting function * Creates a multi array with the user fields that we can show.
* We look the visibility with the api_get_setting function
* The username is always NOT able to change it. * The username is always NOT able to change it.
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification * @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification
* @return array array[value_name][name], array[value_name][visibilty] * @return array array[value_name][name], array[value_name][visibilty]
@ -3234,7 +3258,8 @@ class SurveyUtil
answered="1" AND answered="1" AND
c_id = '.$course_id; c_id = '.$course_id;
$sql2 = 'SELECT COUNT(*) as count FROM '.$table_survey.' s $sql2 = 'SELECT COUNT(*) as count
FROM '.$table_survey.' s
INNER JOIN '.$table_survey_question.' q INNER JOIN '.$table_survey_question.' q
ON s.survey_id=q.survey_id ON s.survey_id=q.survey_id
WHERE WHERE

@ -171,7 +171,10 @@ class CourseRestorer
} }
} }
$sample_text = implode("\n", $sample_text); $sample_text = implode("\n", $sample_text);
$this->course->encoding = api_detect_encoding($sample_text, $course_info['language']); $this->course->encoding = api_detect_encoding(
$sample_text,
$course_info['language']
);
} }
// Encoding conversion of the course, if it is needed. // Encoding conversion of the course, if it is needed.
@ -179,7 +182,11 @@ class CourseRestorer
foreach ($this->tools_to_restore as $tool) { foreach ($this->tools_to_restore as $tool) {
$function_build = 'restore_'.$tool; $function_build = 'restore_'.$tool;
$this->$function_build($session_id, $respect_base_content, $destination_course_code); $this->$function_build(
$session_id,
$respect_base_content,
$destination_course_code
);
} }
if ($update_course_settings) { if ($update_course_settings) {
@ -253,7 +260,6 @@ class CourseRestorer
$params['visibility'] = $course_info['visibility']; $params['visibility'] = $course_info['visibility'];
$params['department_name'] = $course_info['department_name']; $params['department_name'] = $course_info['department_name'];
$params['department_url'] = $course_info['department_url']; $params['department_url'] = $course_info['department_url'];
$params['category_code'] = $course_info['categoryCode']; $params['category_code'] = $course_info['categoryCode'];
$params['subscribe'] = $course_info['subscribe_allowed']; $params['subscribe'] = $course_info['subscribe_allowed'];
$params['unsubscribe'] = $course_info['unsubscribe']; $params['unsubscribe'] = $course_info['unsubscribe'];
@ -542,7 +548,7 @@ class CourseRestorer
if (UTF8_CONVERT) { if (UTF8_CONVERT) {
$content = utf8_encode($content); $content = utf8_encode($content);
} }
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content = DocumentManager::replaceUrlWithNewCourseCode(
$content, $content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -662,7 +668,7 @@ class CourseRestorer
if (UTF8_CONVERT) { if (UTF8_CONVERT) {
$content = utf8_encode($content); $content = utf8_encode($content);
} }
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content = DocumentManager::replaceUrlWithNewCourseCode(
$content, $content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -725,7 +731,7 @@ class CourseRestorer
if (UTF8_CONVERT) { if (UTF8_CONVERT) {
$content = utf8_encode($content); $content = utf8_encode($content);
} }
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content = DocumentManager::replaceUrlWithNewCourseCode(
$content, $content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -791,7 +797,7 @@ class CourseRestorer
if (UTF8_CONVERT) { if (UTF8_CONVERT) {
$content = utf8_encode($content); $content = utf8_encode($content);
} }
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content = DocumentManager::replaceUrlWithNewCourseCode(
$content, $content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -867,7 +873,7 @@ class CourseRestorer
if (UTF8_CONVERT) { if (UTF8_CONVERT) {
$content = utf8_encode($content); $content = utf8_encode($content);
} }
$content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content = DocumentManager::replaceUrlWithNewCourseCode(
$content, $content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1070,7 +1076,7 @@ class CourseRestorer
$params['forum_id'] = 0; $params['forum_id'] = 0;
unset($params['iid']); unset($params['iid']);
$params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $params['forum_comment'] = DocumentManager::replaceUrlWithNewCourseCode(
$params['forum_comment'], $params['forum_comment'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1130,7 +1136,7 @@ class CourseRestorer
if ($forum_cat && !$forum_cat->is_restored()) { if ($forum_cat && !$forum_cat->is_restored()) {
$params = (array) $forum_cat->obj; $params = (array) $forum_cat->obj;
$params['c_id'] = $this->destination_course_id; $params['c_id'] = $this->destination_course_id;
$params['cat_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $params['cat_comment'] = DocumentManager::replaceUrlWithNewCourseCode(
$params['cat_comment'], $params['cat_comment'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1234,7 +1240,7 @@ class CourseRestorer
$params['post_id'] = 0; $params['post_id'] = 0;
unset($params['iid']); unset($params['iid']);
$params['post_text'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $params['post_text'] = DocumentManager::replaceUrlWithNewCourseCode(
$params['post_text'], $params['post_text'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1356,7 +1362,9 @@ class CourseRestorer
$new_id = Database::insert($link_cat_table, $params); $new_id = Database::insert($link_cat_table, $params);
if ($new_id) { if ($new_id) {
$sql = "UPDATE $link_cat_table SET id = iid WHERE iid = $new_id"; $sql = "UPDATE $link_cat_table
SET id = iid
WHERE iid = $new_id";
Database::query($sql); Database::query($sql);
api_set_default_visibility($new_id, TOOL_LINK_CATEGORY); api_set_default_visibility($new_id, TOOL_LINK_CATEGORY);
} }
@ -1385,7 +1393,7 @@ class CourseRestorer
id='".self::DBUTF8escapestring($tool_intro->id)."'"; id='".self::DBUTF8escapestring($tool_intro->id)."'";
Database::query($sql); Database::query($sql);
$tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( $tool_intro->intro_text = DocumentManager::replaceUrlWithNewCourseCode(
$tool_intro->intro_text, $tool_intro->intro_text,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1424,7 +1432,7 @@ class CourseRestorer
$resources = $this->course->resources; $resources = $this->course->resources;
foreach ($resources[RESOURCE_EVENT] as $id => $event) { foreach ($resources[RESOURCE_EVENT] as $id => $event) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $event->content = DocumentManager::replaceUrlWithNewCourseCode(
$event->content, $event->content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1544,7 +1552,7 @@ class CourseRestorer
$title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; $title = isset($courseDescription['title']) ? $courseDescription['title'] : '';
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $description_content = DocumentManager::replaceUrlWithNewCourseCode(
$content, $content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1588,7 +1596,7 @@ class CourseRestorer
$resources = $this->course->resources; $resources = $this->course->resources;
foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $announcement->content = DocumentManager::replaceUrlWithNewCourseCode(
$announcement->content, $announcement->content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1736,7 +1744,7 @@ class CourseRestorer
if ($id != -1) { if ($id != -1) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( $quiz->description = DocumentManager::replaceUrlWithNewCourseCode(
$quiz->description, $quiz->description,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1846,7 +1854,7 @@ class CourseRestorer
$table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( $question->description = DocumentManager::replaceUrlWithNewCourseCode(
$question->description, $question->description,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1901,7 +1909,7 @@ class CourseRestorer
foreach ($temp as $index => $answer) { foreach ($temp as $index => $answer) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['answer'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['answer'], $answer['answer'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1909,7 +1917,7 @@ class CourseRestorer
$this->course->info['path'] $this->course->info['path']
); );
$answer['comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['comment'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['comment'], $answer['comment'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1950,7 +1958,7 @@ class CourseRestorer
} else { } else {
foreach ($question->answers as $index => $answer) { foreach ($question->answers as $index => $answer) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['answer'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['answer'], $answer['answer'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -1958,7 +1966,7 @@ class CourseRestorer
$this->course->info['path'] $this->course->info['path']
); );
$answer['comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['comment'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['comment'], $answer['comment'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2220,7 +2228,7 @@ class CourseRestorer
$result_check = Database::query($sql); $result_check = Database::query($sql);
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( $survey->title = DocumentManager::replaceUrlWithNewCourseCode(
$survey->title, $survey->title,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2228,7 +2236,7 @@ class CourseRestorer
$this->course->info['path'] $this->course->info['path']
); );
$survey->subtitle = DocumentManager::replace_urls_inside_content_html_from_copy_course( $survey->subtitle = DocumentManager::replaceUrlWithNewCourseCode(
$survey->subtitle, $survey->subtitle,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2236,7 +2244,7 @@ class CourseRestorer
$this->course->info['path'] $this->course->info['path']
); );
$survey->intro = DocumentManager::replace_urls_inside_content_html_from_copy_course( $survey->intro = DocumentManager::replaceUrlWithNewCourseCode(
$survey->intro, $survey->intro,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2244,7 +2252,7 @@ class CourseRestorer
$this->course->info['path'] $this->course->info['path']
); );
$survey->surveythanks = DocumentManager::replace_urls_inside_content_html_from_copy_course( $survey->surveythanks = DocumentManager::replaceUrlWithNewCourseCode(
$survey->surveythanks, $survey->surveythanks,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2414,7 +2422,7 @@ class CourseRestorer
$table_ans = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_ans = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( $question->survey_question = DocumentManager::replaceUrlWithNewCourseCode(
$question->survey_question, $question->survey_question,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2443,7 +2451,7 @@ class CourseRestorer
foreach ($question->answers as $index => $answer) { foreach ($question->answers as $index => $answer) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$answer['option_text'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $answer['option_text'] = DocumentManager::replaceUrlWithNewCourseCode(
$answer['option_text'], $answer['option_text'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -2947,7 +2955,7 @@ class CourseRestorer
} }
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( $glossary->description = DocumentManager::replaceUrlWithNewCourseCode(
$glossary->description, $glossary->description,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -3001,7 +3009,7 @@ class CourseRestorer
// the sql statement to insert the groups from the old course to the new course // the sql statement to insert the groups from the old course to the new course
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $wiki->content = DocumentManager::replaceUrlWithNewCourseCode(
$wiki->content, $wiki->content,
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -3084,7 +3092,7 @@ class CourseRestorer
foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $thematic->params['content'] = DocumentManager::replaceUrlWithNewCourseCode(
$thematic->params['content'], $thematic->params['content'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -3175,7 +3183,7 @@ class CourseRestorer
$resources = $this->course->resources; $resources = $this->course->resources;
foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $obj->params['description'] = DocumentManager::replaceUrlWithNewCourseCode(
$obj->params['description'], $obj->params['description'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,
@ -3235,7 +3243,7 @@ class CourseRestorer
foreach ($resources[RESOURCE_WORK] as $obj) { foreach ($resources[RESOURCE_WORK] as $obj) {
// check resources inside html from ckeditor tool and copy correct urls into recipient course // check resources inside html from ckeditor tool and copy correct urls into recipient course
$obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( $obj->params['description'] = DocumentManager::replaceUrlWithNewCourseCode(
$obj->params['description'], $obj->params['description'],
$this->course->code, $this->course->code,
$this->course->destination_path, $this->course->destination_path,

Loading…
Cancel
Save