From dcab5adbda7cf546a04a9f055af999d32e018a0f Mon Sep 17 00:00:00 2001 From: Cesar Perales Date: Wed, 27 Mar 2013 18:31:03 -0500 Subject: [PATCH 01/38] Sender don't see file he've just uploaded in group document tool refs 6046 --- main/document/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/document/document.php b/main/document/document.php index 029d0046e5..494b9dda8c 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -1008,7 +1008,7 @@ $table_footer = ''; $total_size = 0; if (isset($docs_and_folders) && is_array($docs_and_folders)) { - if (api_get_group_id() == 0 || ( api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), 0) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()))) { + if (api_get_group_id() == 0 || ( api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()))) { // Create a sortable table with our data $sortable_data = array(); From 498e4baf93e72f1c18b2a13cd01fadbec3744836 Mon Sep 17 00:00:00 2001 From: Cesar Perales Date: Wed, 27 Mar 2013 18:40:32 -0500 Subject: [PATCH 02/38] Sender don't see file he've just uploaded in group document tool - refs #6046 --- main/document/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/document/document.php b/main/document/document.php index 029d0046e5..494b9dda8c 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -1008,7 +1008,7 @@ $table_footer = ''; $total_size = 0; if (isset($docs_and_folders) && is_array($docs_and_folders)) { - if (api_get_group_id() == 0 || ( api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), 0) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()))) { + if (api_get_group_id() == 0 || ( api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id()))) { // Create a sortable table with our data $sortable_data = array(); From 8c9570dcd025339afe12cc8eff6dc14604a50908 Mon Sep 17 00:00:00 2001 From: Cesar Perales Date: Wed, 27 Mar 2013 19:13:22 -0500 Subject: [PATCH 03/38] Fixed missing Return-link for categories and removed useless and non-working 'up' link - refs #5986 --- main/inc/lib/userportal.lib.php | 85 +++++++++++++++------------------ 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index c8ef57ccf3..83cbefd891 100644 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -431,58 +431,51 @@ class IndexManager { $resCats = Database::query($sqlGetSubCatList); $thereIsSubCat = false; if (Database::num_rows($resCats) > 0) { - $htmlListCat = Display::page_header(get_lang('CatList')); - $htmlListCat .= '
    '; - while ($catLine = Database::fetch_array($resCats)) { - if ($catLine['code'] != $category) { - $category_has_open_courses = self::category_has_open_courses($catLine['code']); - if ($category_has_open_courses) { - // The category contains courses accessible to anonymous visitors. - $htmlListCat .= '
  • '; - $htmlListCat .= ''.$catLine['name'].''; - if (api_get_setting('show_number_of_courses') == 'true') { - $htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')'; - } - $htmlListCat .= "
  • "; - $thereIsSubCat = true; - } elseif ($catLine['children_count'] > 0) { - // The category has children, subcategories. - $htmlListCat .= '
  • '; - $htmlListCat .= ''.$catLine['name'].''; - $htmlListCat .= "
  • "; - $thereIsSubCat = true; - } - /* End changed code to eliminate the (0 courses) after empty categories. */ - elseif (api_get_setting('show_empty_course_categories') == 'true') { - $htmlListCat .= '
  • '; - $htmlListCat .= $catLine['name']; - $htmlListCat .= "
  • "; - $thereIsSubCat = true; - } // Else don't set thereIsSubCat to true to avoid printing things if not requested. - } else { - $htmlTitre = '

    '; - if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { - $htmlTitre .= '<< '.get_lang('BackToHomePage').''; - } - if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') != 'true' && !is_null($catLine['code']))) { - $htmlTitre .= '<< '.get_lang('Up').''; - } - $htmlTitre .= "

    "; - if ($category != "" && !is_null($catLine['code'])) { - $htmlTitre .= '

    '.$catLine['name']."

    "; - } else { - $htmlTitre .= '

    '.get_lang('Categories')."

    "; - } - } - } + $htmlListCat = Display::page_header(get_lang('CatList')); + $htmlListCat .= '
      '; + $htmlTitre = ''; + while ($catLine = Database::fetch_array($resCats)) { + $category_has_open_courses = self::category_has_open_courses($catLine['code']); + if ($category_has_open_courses) { + // The category contains courses accessible to anonymous visitors. + $htmlListCat .= '
    • '; + $htmlListCat .= ''.$catLine['name'].''; + if (api_get_setting('show_number_of_courses') == 'true') { + $htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')'; + } + $htmlListCat .= "
    • "; + $thereIsSubCat = true; + } elseif ($catLine['children_count'] > 0) { + // The category has children, subcategories. + $htmlListCat .= '
    • '; + $htmlListCat .= ''.$catLine['name'].''; + $htmlListCat .= "
    • "; + $thereIsSubCat = true; + } + /* End changed code to eliminate the (0 courses) after empty categories. */ + elseif (api_get_setting('show_empty_course_categories') == 'true') { + $htmlListCat .= '
    • '; + $htmlListCat .= $catLine['name']; + $htmlListCat .= "
    • "; + $thereIsSubCat = true; + } // Else don't set thereIsSubCat to true to avoid printing things if not requested. + // TODO: deprecate this useless feature - this includes removing system variable + if (empty($htmlTitre)) { + $htmlTitre = '

      '; + if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { + $htmlTitre .= '<< '.get_lang('BackToHomePage').''; + } + $htmlTitre .= "

      "; + } + } $htmlListCat .= "
    "; } $result .= $htmlTitre; if ($thereIsSubCat) { - $result .= $htmlListCat; + $result .= $htmlListCat; } while ($categoryName = Database::fetch_array($resCats)) { - $result .= '

    ' . $categoryName['name'] . "

    \n"; + $result .= '

    ' . $categoryName['name'] . "

    \n"; } $numrows = Database::num_rows($sql_result_courses); $courses_list_string = ''; From 2d69b5d9f43a5dfdba7a7c85a60c4da145b4cbcb Mon Sep 17 00:00:00 2001 From: Cesar Perales Date: Wed, 27 Mar 2013 19:48:29 -0500 Subject: [PATCH 04/38] custom stylesheet in archive - client denied by server configuration - refs #5967 --- main/admin/settings.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index ad0d6d0b4b..53cdb5cc17 100644 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -314,7 +314,8 @@ function handle_stylesheets() { // Remove path prefix except the style name and put file on disk $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($safe_style_dir))); } - $str = ''.get_lang('ClickHereToDownloadTheFile').''; + //@TODO: use more generic script to download. + $str = ''.get_lang('ClickHereToDownloadTheFile').''; Display::display_normal_message($str,false); } } From 4ee421017fa503585c831e330dc9ab81f4f80068 Mon Sep 17 00:00:00 2001 From: Yoselyn Castillo Date: Thu, 28 Mar 2013 19:28:14 -0500 Subject: [PATCH 05/38] Removing survey invitation on user removed - fixes #5847 --- main/inc/lib/usermanager.lib.php | 2 +- main/survey/survey.lib.php | 7949 +++++++++++++++--------------- 2 files changed, 3980 insertions(+), 3971 deletions(-) diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index f05b8418df..ed88958b23 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -371,7 +371,7 @@ class UserManager survey_manager::delete_all_survey_invitations_by_user($user_id); // Delete students works - $sqlw = "DELETE FROM $table_work WHERE user_id = $user_id"; + $sqlw = "DELETE FROM $table_work WHERE user_id = $user_id AND c_id <> 0"; Database::query($sqlw); unset($sqlw); // Add event to system log diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index 46b7e6419b..f9692ad207 100644 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -34,13 +34,26 @@ class survey_manager { */ public static function delete_all_survey_invitations_by_user($user_id) { $user_id = intval($user_id); - + if (empty($user_id)) { return false; } $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); - $sql = "DELETE FROM $table_survey_invitation WHERE user = '$user_id'"; - Database::query($sql); + $table_survey = Database :: get_course_table(TABLE_SURVEY); + + $sql = "SELECT survey_invitation_id, survey_code FROM $table_survey_invitation WHERE user = '$user_id' AND c_id <> 0 "; + $result = Database::query($sql); + $deleted = array(); + while ($row = Database::fetch_array($result ,'ASSOC')){ + $survey_invitation_id = $row['survey_invitation_id']; + $survey_code = $row['survey_code']; + $sql2 = "DELETE FROM $table_survey_invitation WHERE survey_invitation_id = '$survey_invitation_id' AND c_id <> 0"; + if (Database::query($sql2)) { + $sql3 = "UPDATE $table_survey SET invited = invited-1 ". + " WHERE c_id <> 0 AND code ='$survey_code'"; + Database::query($sql3); + } + } } /** * @@ -63,188 +76,188 @@ class survey_manager { return $result; } - /** - * Retrieves all the survey information - * - * @param integer $survey_id the id of the survey - * @param boolean $shared this parameter determines if we have to get the information of a survey from the central (shared) database or from the - * course database - * @param string course code optional - * - * @author Patrick Cool , Ghent University - * @version February 2007 + /** + * Retrieves all the survey information + * + * @param integer $survey_id the id of the survey + * @param boolean $shared this parameter determines if we have to get the information of a survey from the central (shared) database or from the + * course database + * @param string course code optional + * + * @author Patrick Cool , Ghent University + * @version February 2007 * @assert ('') === false - * - * @todo this is the same function as in create_new_survey.php - */ - static function get_survey($survey_id, $shared = 0, $course_code = '') { - global $_course; - - // Table definition - if (!empty($course_code)) { - $my_course_id = $course_code; - } else if (isset($_GET['course'])) { - $my_course_id = Security::remove_XSS($_GET['course']); - } else { - $my_course_id = api_get_course_id(); - } - $my_course_info = api_get_course_info($my_course_id); - $table_survey = Database :: get_course_table(TABLE_SURVEY); + * + * @todo this is the same function as in create_new_survey.php + */ + static function get_survey($survey_id, $shared = 0, $course_code = '') { + global $_course; + + // Table definition + if (!empty($course_code)) { + $my_course_id = $course_code; + } else if (isset($_GET['course'])) { + $my_course_id = Security::remove_XSS($_GET['course']); + } else { + $my_course_id = api_get_course_id(); + } + $my_course_info = api_get_course_info($my_course_id); + $table_survey = Database :: get_course_table(TABLE_SURVEY); - if ($shared != 0) { - $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); + if ($shared != 0) { + $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); $sql = "SELECT * FROM $table_survey WHERE survey_id='".Database::escape_string($survey_id)."' "; - } else { - $sql = "SELECT * FROM $table_survey WHERE survey_id='".Database::escape_string($survey_id)."' AND c_id = ".$my_course_info['real_id']; - } + } else { + $sql = "SELECT * FROM $table_survey WHERE survey_id='".Database::escape_string($survey_id)."' AND c_id = ".$my_course_info['real_id']; + } - $result = Database::query($sql); - $return = array(); - - if (Database::num_rows($result)> 0) { - $return = Database::fetch_array($result,'ASSOC'); - // We do this (temporarily) to have the array match the quickform elements immediately - // idealiter the fields in the db match the quickform fields - $return['survey_code'] = $return['code']; - $return['survey_title'] = $return['title']; - $return['survey_subtitle'] = $return['subtitle']; - $return['survey_language'] = $return['lang']; - $return['start_date'] = $return['avail_from']; - $return['end_date'] = $return['avail_till']; - $return['survey_share'] = $return['is_shared']; - $return['survey_introduction'] = $return['intro']; - $return['survey_thanks'] = $return['surveythanks']; - $return['survey_type'] = $return['survey_type']; - $return['one_question_per_page']= $return['one_question_per_page']; - $return['show_form_profile'] = $return['show_form_profile']; - $return['input_name_list'] = isset($return['input_name_list']) ? $return['input_name_list'] : null; - $return['shuffle'] = $return['shuffle']; - $return['parent_id'] = $return['parent_id']; - $return['survey_version'] = $return['survey_version']; + $result = Database::query($sql); + $return = array(); + + if (Database::num_rows($result)> 0) { + $return = Database::fetch_array($result,'ASSOC'); + // We do this (temporarily) to have the array match the quickform elements immediately + // idealiter the fields in the db match the quickform fields + $return['survey_code'] = $return['code']; + $return['survey_title'] = $return['title']; + $return['survey_subtitle'] = $return['subtitle']; + $return['survey_language'] = $return['lang']; + $return['start_date'] = $return['avail_from']; + $return['end_date'] = $return['avail_till']; + $return['survey_share'] = $return['is_shared']; + $return['survey_introduction'] = $return['intro']; + $return['survey_thanks'] = $return['surveythanks']; + $return['survey_type'] = $return['survey_type']; + $return['one_question_per_page']= $return['one_question_per_page']; + $return['show_form_profile'] = $return['show_form_profile']; + $return['input_name_list'] = isset($return['input_name_list']) ? $return['input_name_list'] : null; + $return['shuffle'] = $return['shuffle']; + $return['parent_id'] = $return['parent_id']; + $return['survey_version'] = $return['survey_version']; } return $return; - } - - /** - * This function stores a survey in the database. - * - * @param array $values - * @return array $return the type of return message that has to be displayed and the message in it - * - * @author Patrick Cool , Ghent University - * @version February 2007 - */ - static function store_survey($values) { - global $_user; - - // Table defnitions - $table_survey = Database :: get_course_table(TABLE_SURVEY); - $shared_survey_id = 0; + } + + /** + * This function stores a survey in the database. + * + * @param array $values + * @return array $return the type of return message that has to be displayed and the message in it + * + * @author Patrick Cool , Ghent University + * @version February 2007 + */ + static function store_survey($values) { + global $_user; + + // Table defnitions + $table_survey = Database :: get_course_table(TABLE_SURVEY); + $shared_survey_id = 0; $course_id = api_get_course_int_id(); - if (!$values['survey_id'] || !is_numeric($values['survey_id'])) { - // Check if the code doesn't soon exists in this language - $sql = 'SELECT 1 FROM '.$table_survey.' + if (!$values['survey_id'] || !is_numeric($values['survey_id'])) { + // Check if the code doesn't soon exists in this language + $sql = 'SELECT 1 FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND code="'.Database::escape_string($values['survey_code']).'" AND lang="'.Database::escape_string($values['survey_language']).'"'; - $rs = Database::query($sql); - if (Database::num_rows($rs) > 0) { - $return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage'; - $return['type'] = 'error'; - $return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0; - return $return; - } - - if ($values['anonymous'] == '') { - $values['anonymous'] = 0; - } + $rs = Database::query($sql); + if (Database::num_rows($rs) > 0) { + $return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage'; + $return['type'] = 'error'; + $return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0; + return $return; + } - $additional['columns'] = ''; - $additional['values'] = ''; - - if ($values['anonymous'] == 0) { - // Input_name_list - $additional['columns'] .= ', show_form_profile'; - $additional['values'] .= ",'".Database::escape_string($values['show_form_profile'])."'"; - - if ($values['show_form_profile'] == 1) { - // Input_name_list - $fields = explode(',', $values['input_name_list']); - $field_values = ''; - foreach ($fields as & $field) { - if ($field != '') { - if ($values[$field] == '') { - $values[$field] = 0; - } - $field_values.= $field.':'.$values[$field].'@'; - } - } - $additional['columns'] .= ', form_fields'; - $additional['values'] .= ",'".Database::escape_string($field_values)."'"; - } else { - $additional['columns'] .= ', form_fields'; - $additional['values'] .= ",''"; - } - } else { - // Input_name_list - $additional['columns'] .= ', show_form_profile'; - $additional['values'] .= ",'0'"; + if ($values['anonymous'] == '') { + $values['anonymous'] = 0; + } - $additional['columns'] .= ', form_fields'; - $additional['values'] .= ",''"; - } + $additional['columns'] = ''; + $additional['values'] = ''; + + if ($values['anonymous'] == 0) { + // Input_name_list + $additional['columns'] .= ', show_form_profile'; + $additional['values'] .= ",'".Database::escape_string($values['show_form_profile'])."'"; + + if ($values['show_form_profile'] == 1) { + // Input_name_list + $fields = explode(',', $values['input_name_list']); + $field_values = ''; + foreach ($fields as & $field) { + if ($field != '') { + if ($values[$field] == '') { + $values[$field] = 0; + } + $field_values.= $field.':'.$values[$field].'@'; + } + } + $additional['columns'] .= ', form_fields'; + $additional['values'] .= ",'".Database::escape_string($field_values)."'"; + } else { + $additional['columns'] .= ', form_fields'; + $additional['values'] .= ",''"; + } + } else { + // Input_name_list + $additional['columns'] .= ', show_form_profile'; + $additional['values'] .= ",'0'"; + + $additional['columns'] .= ', form_fields'; + $additional['values'] .= ",''"; + } - if ($values['survey_type'] == 1) { - $additional['columns'] .= ', survey_type'; - $additional['values'] .= ",'1'"; - - $additional['columns'] .= ', shuffle'; - $additional['values'] .= ",'".Database::escape_string($values['shuffle'])."'"; - - $additional['columns'] .= ', one_question_per_page'; - $additional['values'] .= ",'".Database::escape_string($values['one_question_per_page'])."'"; - - $additional['columns'] .= ', parent_id'; - $additional['values'] .= ",'".Database::escape_string($values['parent_id'])."'"; - - // Logic for versioning surveys - if (!empty($values['parent_id'])) { - $additional['columns'] .= ', survey_version'; - $sql = 'SELECT survey_version FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND parent_id = '.Database::escape_string($values['parent_id']).' ORDER BY survey_version DESC LIMIT 1'; - $rs = Database::query($sql); - if (Database::num_rows($rs) === 0) { - $sql = 'SELECT survey_version FROM '.$table_survey.' WHERE c_id = '.$course_id.' survey_id = '.Database::escape_string($values['parent_id']); - $rs = Database::query($sql); - $getversion = Database::fetch_array($rs, 'ASSOC'); - if (empty($getversion['survey_version'])) { - $additional['values'] .= ",'".++$getversion['survey_version']."'"; - } else { - $additional['values'] .= ",'".$getversion['survey_version'].".1'"; - } - } else { - $row = Database::fetch_array($rs, 'ASSOC'); - $pos = api_strpos($row['survey_version']); - if ($pos === false) { - //$new_version = substr($row['survey_version'],$pos, count()) - $row['survey_version'] = $row['survey_version'] + 1; - $additional['values'] .= ",'".$row['survey_version']."'"; - } else { - $getlast = api_split('\.', $row['survey_version']); - $lastversion = array_pop($getlast); - $lastversion = $lastversion + 1; - $add = implode('.', $getlast); - if ($add != '') { - $insertnewversion = $add.'.'.$lastversion; - } else { - $insertnewversion = $lastversion; - } - $additional['values'] .= ",'".$insertnewversion."'"; - } - } - } - } - $course_id = api_get_course_int_id(); - $sql = "INSERT INTO $table_survey (c_id, code, title, subtitle, author, lang, avail_from, avail_till, is_shared, template, intro, surveythanks, creation_date, anonymous".$additional['columns'].", session_id) VALUES ( + if ($values['survey_type'] == 1) { + $additional['columns'] .= ', survey_type'; + $additional['values'] .= ",'1'"; + + $additional['columns'] .= ', shuffle'; + $additional['values'] .= ",'".Database::escape_string($values['shuffle'])."'"; + + $additional['columns'] .= ', one_question_per_page'; + $additional['values'] .= ",'".Database::escape_string($values['one_question_per_page'])."'"; + + $additional['columns'] .= ', parent_id'; + $additional['values'] .= ",'".Database::escape_string($values['parent_id'])."'"; + + // Logic for versioning surveys + if (!empty($values['parent_id'])) { + $additional['columns'] .= ', survey_version'; + $sql = 'SELECT survey_version FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND parent_id = '.Database::escape_string($values['parent_id']).' ORDER BY survey_version DESC LIMIT 1'; + $rs = Database::query($sql); + if (Database::num_rows($rs) === 0) { + $sql = 'SELECT survey_version FROM '.$table_survey.' WHERE c_id = '.$course_id.' survey_id = '.Database::escape_string($values['parent_id']); + $rs = Database::query($sql); + $getversion = Database::fetch_array($rs, 'ASSOC'); + if (empty($getversion['survey_version'])) { + $additional['values'] .= ",'".++$getversion['survey_version']."'"; + } else { + $additional['values'] .= ",'".$getversion['survey_version'].".1'"; + } + } else { + $row = Database::fetch_array($rs, 'ASSOC'); + $pos = api_strpos($row['survey_version']); + if ($pos === false) { + //$new_version = substr($row['survey_version'],$pos, count()) + $row['survey_version'] = $row['survey_version'] + 1; + $additional['values'] .= ",'".$row['survey_version']."'"; + } else { + $getlast = api_split('\.', $row['survey_version']); + $lastversion = array_pop($getlast); + $lastversion = $lastversion + 1; + $add = implode('.', $getlast); + if ($add != '') { + $insertnewversion = $add.'.'.$lastversion; + } else { + $insertnewversion = $lastversion; + } + $additional['values'] .= ",'".$insertnewversion."'"; + } + } + } + } + $course_id = api_get_course_int_id(); + $sql = "INSERT INTO $table_survey (c_id, code, title, subtitle, author, lang, avail_from, avail_till, is_shared, template, intro, surveythanks, creation_date, anonymous".$additional['columns'].", session_id) VALUES ( $course_id, '".Database::escape_string(strtolower(generate_course_code(api_substr($values['survey_code'],0))))."', '".Database::escape_string($values['survey_title'])."', @@ -261,63 +274,63 @@ class survey_manager { '".Database::escape_string($values['anonymous'])."'".$additional['values'].", ".intval($_SESSION['id_session'])." )"; - $result = Database::query($sql); - $survey_id = Database::insert_id(); - if ($survey_id > 0) { - // Insert into item_property - api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id()); - } + $result = Database::query($sql); + $survey_id = Database::insert_id(); + if ($survey_id > 0) { + // Insert into item_property + api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id()); + } - if ($values['survey_type'] == 1 && !empty($values['parent_id'])) { - survey_manager::copy_survey($values['parent_id'],$survey_id); - } + if ($values['survey_type'] == 1 && !empty($values['parent_id'])) { + survey_manager::copy_survey($values['parent_id'],$survey_id); + } - $return['message'] = 'SurveyCreatedSuccesfully'; - $return['type'] = 'confirmation'; - $return['id'] = $survey_id; + $return['message'] = 'SurveyCreatedSuccesfully'; + $return['type'] = 'confirmation'; + $return['id'] = $survey_id; - } else { + } else { - // Check whether the code doesn't soon exists in this language - $sql = 'SELECT 1 FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND code="'.Database::escape_string($values['survey_code']).'" AND lang="'.Database::escape_string($values['survey_language']).'" AND survey_id!='.intval($values['survey_id']); - $rs = Database::query($sql); - if (Database::num_rows($rs) > 0) { - $return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage'; - $return['type'] = 'error'; - $return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0; - return $return; - } + // Check whether the code doesn't soon exists in this language + $sql = 'SELECT 1 FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND code="'.Database::escape_string($values['survey_code']).'" AND lang="'.Database::escape_string($values['survey_language']).'" AND survey_id!='.intval($values['survey_id']); + $rs = Database::query($sql); + if (Database::num_rows($rs) > 0) { + $return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage'; + $return['type'] = 'error'; + $return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0; + return $return; + } - if ($values['anonymous'] == '') { - $values['anonymous'] = 0; - } + if ($values['anonymous'] == '') { + $values['anonymous'] = 0; + } - $additionalsets = ", shuffle = '".Database::escape_string($values['shuffle'])."'"; - $additionalsets .= ", one_question_per_page = '".Database::escape_string($values['one_question_per_page'])."'"; - - if ($values['anonymous'] == 0) { - $additionalsets .= ", show_form_profile = '".Database::escape_string($values['show_form_profile'])."'"; - if ($values['show_form_profile'] == 1) { - $fields = explode(',',$values['input_name_list']); - $field_values = ''; - foreach ($fields as & $field) { - if ($field != '') { - if ($values[$field] == '') { - $values[$field] = 0; - } - $field_values.= $field.':'.$values[$field].'@'; - } - } - $additionalsets .= ", form_fields = '".Database::escape_string($field_values)."'"; - } else { - $additionalsets .= ", form_fields = '' "; - } - } else { - $additionalsets .= ", show_form_profile = '0'"; - $additionalsets .= ", form_fields = '' "; - } + $additionalsets = ", shuffle = '".Database::escape_string($values['shuffle'])."'"; + $additionalsets .= ", one_question_per_page = '".Database::escape_string($values['one_question_per_page'])."'"; + + if ($values['anonymous'] == 0) { + $additionalsets .= ", show_form_profile = '".Database::escape_string($values['show_form_profile'])."'"; + if ($values['show_form_profile'] == 1) { + $fields = explode(',',$values['input_name_list']); + $field_values = ''; + foreach ($fields as & $field) { + if ($field != '') { + if ($values[$field] == '') { + $values[$field] = 0; + } + $field_values.= $field.':'.$values[$field].'@'; + } + } + $additionalsets .= ", form_fields = '".Database::escape_string($field_values)."'"; + } else { + $additionalsets .= ", form_fields = '' "; + } + } else { + $additionalsets .= ", show_form_profile = '0'"; + $additionalsets .= ", form_fields = '' "; + } - $sql = "UPDATE $table_survey SET + $sql = "UPDATE $table_survey SET title = '".Database::escape_string($values['survey_title'])."', subtitle = '".Database::escape_string($values['survey_subtitle'])."', author = '".Database::escape_string($_user['user_id'])."', @@ -330,35 +343,35 @@ class survey_manager { surveythanks = '".Database::escape_string($values['survey_thanks'])."', anonymous = '".Database::escape_string($values['anonymous'])."'".$additionalsets." WHERE c_id = $course_id AND survey_id = '".Database::escape_string($values['survey_id'])."'"; - $result = Database::query($sql); - - // Update into item_property (update) - api_item_property_update(api_get_course_info(), TOOL_SURVEY, $values['survey_id'], 'SurveyUpdated', api_get_user_id()); - - $return['message'] = 'SurveyUpdatedSuccesfully'; - $return['type'] = 'confirmation'; - $return['id'] = $values['survey_id']; - } - return $return; - } + $result = Database::query($sql); - /** - * This function stores a shared survey in the central database. - * - * @param array $values - * @return array $return the type of return message that has to be displayed and the message in it - * - * @author Patrick Cool , Ghent University - * @version February 2007 - */ - function store_shared_survey($values) { - global $_user, $_course; + // Update into item_property (update) + api_item_property_update(api_get_course_info(), TOOL_SURVEY, $values['survey_id'], 'SurveyUpdated', api_get_user_id()); - // Table defnitions - $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY); - - if (!$values['survey_id'] || !is_numeric($values['survey_id']) || $values['survey_share']['survey_share'] == 'true') { - $sql = "INSERT INTO $table_survey (code, title, subtitle, author, lang, template, intro, surveythanks, creation_date, course_code) VALUES ( + $return['message'] = 'SurveyUpdatedSuccesfully'; + $return['type'] = 'confirmation'; + $return['id'] = $values['survey_id']; + } + return $return; + } + + /** + * This function stores a shared survey in the central database. + * + * @param array $values + * @return array $return the type of return message that has to be displayed and the message in it + * + * @author Patrick Cool , Ghent University + * @version February 2007 + */ + function store_shared_survey($values) { + global $_user, $_course; + + // Table defnitions + $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY); + + if (!$values['survey_id'] || !is_numeric($values['survey_id']) || $values['survey_share']['survey_share'] == 'true') { + $sql = "INSERT INTO $table_survey (code, title, subtitle, author, lang, template, intro, surveythanks, creation_date, course_code) VALUES ( '".Database::escape_string($values['survey_code'])."', '".Database::escape_string($values['survey_title'])."', '".Database::escape_string($values['survey_subtitle'])."', @@ -369,10 +382,10 @@ class survey_manager { '".Database::escape_string($values['survey_thanks'])."', '".date('Y-m-d H:i:s')."', '".$_course['id']."')"; - $result = Database::query($sql); - $return = Database::insert_id(); - } else { - $sql = "UPDATE $table_survey SET + $result = Database::query($sql); + $return = Database::insert_id(); + } else { + $sql = "UPDATE $table_survey SET code = '".Database::escape_string($values['survey_code'])."', title = '".Database::escape_string($values['survey_title'])."', subtitle = '".Database::escape_string($values['survey_subtitle'])."', @@ -382,23 +395,23 @@ class survey_manager { intro = '".Database::escape_string($values['survey_introduction'])."', surveythanks = '".Database::escape_string($values['survey_thanks'])."' WHERE survey_id = '".Database::escape_string($values['survey_share']['survey_share'])."'"; - $result = Database::query($sql); - $return = $values['survey_share']['survey_share']; - } - return $return; - } - - /** - * This function deletes a survey (and also all the question in that survey - * - * @param $survey_id the id of the survey that has to be deleted - * @return true - * - * @author Patrick Cool , Ghent University - * @version January 2007 - */ - static function delete_survey($survey_id, $shared = false, $course_id = '') { - // Database table definitions + $result = Database::query($sql); + $return = $values['survey_share']['survey_share']; + } + return $return; + } + + /** + * This function deletes a survey (and also all the question in that survey + * + * @param $survey_id the id of the survey that has to be deleted + * @return true + * + * @author Patrick Cool , Ghent University + * @version January 2007 + */ + static function delete_survey($survey_id, $shared = false, $course_id = '') { + // Database table definitions if (empty($course_id)) { $course_id = api_get_course_int_id(); } @@ -409,383 +422,383 @@ class survey_manager { return false; } - $course_info = api_get_course_info_by_id($course_id); - $course_id = $course_info['real_id']; + $course_info = api_get_course_info_by_id($course_id); + $course_id = $course_info['real_id']; - $table_survey = Database :: get_course_table(TABLE_SURVEY); - $table_survey_question_group = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP); + $table_survey = Database :: get_course_table(TABLE_SURVEY); + $table_survey_question_group = Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP); - if ($shared) { - $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY); - // Deleting the survey + if ($shared) { + $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY); + // Deleting the survey $sql = "DELETE FROM $table_survey WHERE survey_id='".$survey_id."'"; $res = Database::query($sql); - } else { - $sql = "DELETE FROM $table_survey WHERE c_id = $course_id AND survey_id='".$survey_id."'"; + } else { + $sql = "DELETE FROM $table_survey WHERE c_id = $course_id AND survey_id='".$survey_id."'"; $res = Database::query($sql); - } - - // Deleting groups of this survey - $sql = "DELETE FROM $table_survey_question_group WHERE c_id = $course_id AND survey_id='".$survey_id."'"; - $res = Database::query($sql); - - // Deleting the questions of the survey - survey_manager::delete_all_survey_questions($survey_id, $shared); - - // Update into item_property (delete) - api_item_property_update($course_info, TOOL_SURVEY, $survey_id, 'SurveyDeleted', api_get_user_id()); - return true; - } + } - function copy_survey($parent_survey, $new_survey_id) { - $course_id = api_get_course_int_id(); + // Deleting groups of this survey + $sql = "DELETE FROM $table_survey_question_group WHERE c_id = $course_id AND survey_id='".$survey_id."'"; + $res = Database::query($sql); - // Database table definitions - $table_survey = Database::get_course_table(TABLE_SURVEY); - $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); - $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); - $table_survey_options = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); - $parent_survey = Database::escape_string($parent_survey); - // Get groups - $sql = "SELECT * from $table_survey_question_group WHERE c_id = $course_id AND survey_id='".$parent_survey."'"; - $res = Database::query($sql); - if (Database::num_rows($res) === 0) { - return true; - } - $new_survey_id = intval($new_survey_id); - while($row = Database::fetch_array($res, 'ASSOC')){ - $sql1 = 'INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) VALUES + // Deleting the questions of the survey + survey_manager::delete_all_survey_questions($survey_id, $shared); + + // Update into item_property (delete) + api_item_property_update($course_info, TOOL_SURVEY, $survey_id, 'SurveyDeleted', api_get_user_id()); + return true; + } + + function copy_survey($parent_survey, $new_survey_id) { + $course_id = api_get_course_int_id(); + + // Database table definitions + $table_survey = Database::get_course_table(TABLE_SURVEY); + $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); + $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); + $table_survey_options = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); + $parent_survey = Database::escape_string($parent_survey); + // Get groups + $sql = "SELECT * from $table_survey_question_group WHERE c_id = $course_id AND survey_id='".$parent_survey."'"; + $res = Database::query($sql); + if (Database::num_rows($res) === 0) { + return true; + } + $new_survey_id = intval($new_survey_id); + while($row = Database::fetch_array($res, 'ASSOC')){ + $sql1 = 'INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) VALUES ('.$course_id.', \''.Database::escape_string($row['name']).'\',\''.Database::escape_string($row['description']).'\',\''.$new_survey_id.'\')'; - $res1 = Database::query($sql1); - $group_id[$row['id']] = Database::insert_id(); - } - - // Get questions - $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND survey_id='".$parent_survey."'"; - $res = Database::query($sql); - while($row = Database::fetch_array($res, 'ASSOC')){ - $sql2 = 'INSERT INTO '.$table_survey_question.' (c_id, survey_id,survey_question,survey_question_comment,type,display,sort,shared_question_id,max_value,survey_group_pri,survey_group_sec1,survey_group_sec2) VALUES '. - '('.$course_id.', \''.$new_survey_id.'\',\''.Database::escape_string($row['survey_question']).'\',\''.Database::escape_string($row['survey_comment']).'\',\''.$row['type'].'\',\''.$row['display'].'\',\''.$row['sort'].'\',\''.$row['shared_question_id'].'\',\''.$row['max_value']. - '\',\''.$group_id[$row['survey_group_pri']].'\',\''.$group_id[$row['survey_group_sec1']].'\',\''.$group_id[$row['survey_group_sec2']].'\')'; - $res2 = Database::query($sql2); - $question_id[$row['question_id']] = Database::insert_id(); - } + $res1 = Database::query($sql1); + $group_id[$row['id']] = Database::insert_id(); + } - // Get questions options - $sql = "SELECT * FROM $table_survey_options WHERE c_id = $course_id AND survey_id='".$parent_survey."'"; - $res = Database::query($sql); - while($row = Database::fetch_array($res ,'ASSOC')){ - $sql3 = 'INSERT INTO '.$table_survey_options.' (c_id, question_id,survey_id,option_text,sort,value) VALUES ('. - " $course_id , '".$question_id[$row['question_id']]."','".$new_survey_id."','".Database::escape_string($row['option_text'])."','".$row['sort']."','".$row['value']."')"; - $res3 = Database::query($sql3); - } - return true; - } + // Get questions + $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND survey_id='".$parent_survey."'"; + $res = Database::query($sql); + while($row = Database::fetch_array($res, 'ASSOC')){ + $sql2 = 'INSERT INTO '.$table_survey_question.' (c_id, survey_id,survey_question,survey_question_comment,type,display,sort,shared_question_id,max_value,survey_group_pri,survey_group_sec1,survey_group_sec2) VALUES '. + '('.$course_id.', \''.$new_survey_id.'\',\''.Database::escape_string($row['survey_question']).'\',\''.Database::escape_string($row['survey_comment']).'\',\''.$row['type'].'\',\''.$row['display'].'\',\''.$row['sort'].'\',\''.$row['shared_question_id'].'\',\''.$row['max_value']. + '\',\''.$group_id[$row['survey_group_pri']].'\',\''.$group_id[$row['survey_group_sec1']].'\',\''.$group_id[$row['survey_group_sec2']].'\')'; + $res2 = Database::query($sql2); + $question_id[$row['question_id']] = Database::insert_id(); + } - /** - * This function duplicates a survey (and also all the question in that survey - * - * @param $survey_id the id of the survey that has to be duplicated - * @return true - * - * @author Eric Marguin , Elixir Interactive - * @version October 2007 - */ - function empty_survey($survey_id) { - // Database table definitions - $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); - $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); - $table_survey = Database :: get_course_table(TABLE_SURVEY); + // Get questions options + $sql = "SELECT * FROM $table_survey_options WHERE c_id = $course_id AND survey_id='".$parent_survey."'"; + $res = Database::query($sql); + while($row = Database::fetch_array($res ,'ASSOC')){ + $sql3 = 'INSERT INTO '.$table_survey_options.' (c_id, question_id,survey_id,option_text,sort,value) VALUES ('. + " $course_id , '".$question_id[$row['question_id']]."','".$new_survey_id."','".Database::escape_string($row['option_text'])."','".$row['sort']."','".$row['value']."')"; + $res3 = Database::query($sql3); + } + return true; + } + + /** + * This function duplicates a survey (and also all the question in that survey + * + * @param $survey_id the id of the survey that has to be duplicated + * @return true + * + * @author Eric Marguin , Elixir Interactive + * @version October 2007 + */ + function empty_survey($survey_id) { + // Database table definitions + $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); + $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); + $table_survey = Database :: get_course_table(TABLE_SURVEY); $course_id = api_get_course_int_id(); - $datas = survey_manager::get_survey($survey_id); - $session_where = ''; - if (api_get_session_id() != 0) { - $session_where = ' AND session_id = "'.api_get_session_id().'" '; - } + $datas = survey_manager::get_survey($survey_id); + $session_where = ''; + if (api_get_session_id() != 0) { + $session_where = ' AND session_id = "'.api_get_session_id().'" '; + } - $sql = 'DELETE FROM '.$table_survey_invitation.' WHERE c_id = '.$course_id.' AND survey_code = "'.Database::escape_string($datas['code']).'" '.$session_where.' '; - Database::query($sql); + $sql = 'DELETE FROM '.$table_survey_invitation.' WHERE c_id = '.$course_id.' AND survey_code = "'.Database::escape_string($datas['code']).'" '.$session_where.' '; + Database::query($sql); - $sql = 'DELETE FROM '.$table_survey_answer.' WHERE c_id = '.$course_id.' AND survey_id='.intval($survey_id); - Database::query($sql); + $sql = 'DELETE FROM '.$table_survey_answer.' WHERE c_id = '.$course_id.' AND survey_id='.intval($survey_id); + Database::query($sql); - $sql = 'UPDATE '.$table_survey.' SET invited=0, answered=0 WHERE c_id = '.$course_id.' AND survey_id='.intval($survey_id); - Database::query($sql); + $sql = 'UPDATE '.$table_survey.' SET invited=0, answered=0 WHERE c_id = '.$course_id.' AND survey_id='.intval($survey_id); + Database::query($sql); - return true; - } + return true; + } - /** - * This function recalculates the number of people who have taken the survey (=filled at least one question) - * - * @param $survey_id the id of the survey somebody - * @return true - * - * @author Patrick Cool , Ghent University - * @version February 2007 - */ - static function update_survey_answered($survey_data, $user, $survey_code) { - // Database table definitions - $table_survey = Database :: get_course_table(TABLE_SURVEY); - $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); + /** + * This function recalculates the number of people who have taken the survey (=filled at least one question) + * + * @param $survey_id the id of the survey somebody + * @return true + * + * @author Patrick Cool , Ghent University + * @version February 2007 + */ + static function update_survey_answered($survey_data, $user, $survey_code) { + // Database table definitions + $table_survey = Database :: get_course_table(TABLE_SURVEY); + $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); $survey_id = $survey_data['survey_id']; $course_id = $survey_data['c_id']; $session_id = $survey_data['session_id']; - // Getting a list with all the people who have filled the survey - $people_filled = survey_manager::get_people_who_filled_survey($survey_id, false, $course_id); + // Getting a list with all the people who have filled the survey + $people_filled = survey_manager::get_people_who_filled_survey($survey_id, false, $course_id); - $number = intval(count($people_filled)); + $number = intval(count($people_filled)); - // Storing this value in the survey table - $sql = "UPDATE $table_survey SET answered = $number WHERE c_id = $course_id AND survey_id = ".Database::escape_string($survey_id); - Database::query($sql); + // Storing this value in the survey table + $sql = "UPDATE $table_survey SET answered = $number WHERE c_id = $course_id AND survey_id = ".Database::escape_string($survey_id); + Database::query($sql); - // Storing that the user has finished the survey. - $sql = "UPDATE $table_survey_invitation SET answered='1' + // Storing that the user has finished the survey. + $sql = "UPDATE $table_survey_invitation SET answered='1' WHERE c_id = $course_id AND session_id='".$session_id."' AND user='".Database::escape_string($user)."' AND survey_code='".Database::escape_string($survey_code)."'"; - Database::query($sql); - } - - /** - * This function gets a complete structure of a survey (all survey information, all question information - * of all the questions and all the options of all the questions. - * - * @param integer $survey_id the id of the survey - * @param boolean $shared this parameter determines if we have to get the information of a survey from the central (shared) database or from the - * course database - * - * @author Patrick Cool , Ghent University - * @version February 2007 - */ - static function get_complete_survey_structure($survey_id, $shared = 0) { - $structure = survey_manager::get_survey($survey_id, $shared); - $structure['questions'] = survey_manager::get_questions($survey_id); - } - - /*** - * SYRVEY QUESTION FUNCTIONS - */ - - /** - * This function return the "icon" of the question type - * - * @author Patrick Cool , Ghent University - * @version February 2007 - */ - static function icon_question($type) { - // the possible question types - $possible_types = array('personality', 'yesno', 'multiplechoice', 'multipleresponse', 'open', 'dropdown', 'comment', 'pagebreak', 'percentage', 'score'); - - // the images array - $icon_question = array( - 'yesno' => 'yesno.gif', - 'personality' => 'yesno.gif', - 'multiplechoice' => 'mcua.gif', - 'multipleresponse' => 'mcma.gif', - 'open' => 'open_answer.gif', - 'dropdown' => 'dropdown.gif', - 'percentage' => 'percentagequestion.gif', - 'score' => 'scorequestion.gif', - 'comment' => 'commentquestion.gif', - 'pagebreak' => 'page_end.gif', - ); - - if (in_array($type, $possible_types)) { - return $icon_question[$type]; - } else { - return false; - } - } - - /** - * This function retrieves all the information of a question - * - * @param integer $question_id the id of the question - * @return array - * - * @author Patrick Cool , Ghent University - * @version January 2007 - * - * @todo one sql call should do the trick - */ - static function get_question($question_id, $shared = false) { - // Table definitions - $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + Database::query($sql); + } + + /** + * This function gets a complete structure of a survey (all survey information, all question information + * of all the questions and all the options of all the questions. + * + * @param integer $survey_id the id of the survey + * @param boolean $shared this parameter determines if we have to get the information of a survey from the central (shared) database or from the + * course database + * + * @author Patrick Cool , Ghent University + * @version February 2007 + */ + static function get_complete_survey_structure($survey_id, $shared = 0) { + $structure = survey_manager::get_survey($survey_id, $shared); + $structure['questions'] = survey_manager::get_questions($survey_id); + } + + /*** + * SYRVEY QUESTION FUNCTIONS + */ + + /** + * This function return the "icon" of the question type + * + * @author Patrick Cool , Ghent University + * @version February 2007 + */ + static function icon_question($type) { + // the possible question types + $possible_types = array('personality', 'yesno', 'multiplechoice', 'multipleresponse', 'open', 'dropdown', 'comment', 'pagebreak', 'percentage', 'score'); + + // the images array + $icon_question = array( + 'yesno' => 'yesno.gif', + 'personality' => 'yesno.gif', + 'multiplechoice' => 'mcua.gif', + 'multipleresponse' => 'mcma.gif', + 'open' => 'open_answer.gif', + 'dropdown' => 'dropdown.gif', + 'percentage' => 'percentagequestion.gif', + 'score' => 'scorequestion.gif', + 'comment' => 'commentquestion.gif', + 'pagebreak' => 'page_end.gif', + ); + + if (in_array($type, $possible_types)) { + return $icon_question[$type]; + } else { + return false; + } + } + + /** + * This function retrieves all the information of a question + * + * @param integer $question_id the id of the question + * @return array + * + * @author Patrick Cool , Ghent University + * @version January 2007 + * + * @todo one sql call should do the trick + */ + static function get_question($question_id, $shared = false) { + // Table definitions + $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); $course_id = api_get_course_int_id(); $sql = "SELECT * FROM $tbl_survey_question WHERE c_id = $course_id AND question_id='".Database::escape_string($question_id)."' ORDER BY `sort` "; $sql_survey_question_option = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND question_id='".Database::escape_string($question_id)."' ORDER BY `sort` "; - if ($shared) { - $tbl_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); - $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); + if ($shared) { + $tbl_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); + $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); $sql = "SELECT * FROM $tbl_survey_question WHERE question_id='".Database::escape_string($question_id)."' ORDER BY `sort` "; $sql_survey_question_option = "SELECT * FROM $table_survey_question_option WHERE question_id='".Database::escape_string($question_id)."' ORDER BY `sort` "; - } - - // Getting the information of the question - - $result = Database::query($sql); - $row = Database::fetch_array($result,'ASSOC'); - $return['survey_id'] = $row['survey_id']; - $return['question_id'] = $row['question_id']; - $return['type'] = $row['type']; - $return['question'] = $row['survey_question']; - $return['horizontalvertical'] = $row['display']; - $return['shared_question_id'] = $row['shared_question_id']; - $return['maximum_score'] = $row['max_value']; - - if ($row['survey_group_pri'] != 0) { - $return['assigned'] = $row['survey_group_pri']; - $return['choose'] = 1; - } else { - $return['assigned1'] = $row['survey_group_sec1']; - $return['assigned2'] = $row['survey_group_sec2']; - $return['choose'] = 2; - } - - // Getting the information of the question options - - $result = Database::query($sql_survey_question_option); - while ($row = Database::fetch_array($result, 'ASSOC')) { - /** @todo this should be renamed to options instead of answers */ - $return['answers'][] = $row['option_text']; - $return['values'][] = $row['value']; - - /** @todo this can be done more elegantly (used in reporting) */ - $return['answersid'][] = $row['question_option_id']; - } - return $return; - } + } - /** - * This function gets all the question of any given survey - * - * @param integer $survey_id the id of the survey - * @return array containing all the questions of the survey - * - * @author Patrick Cool , Ghent University - * @version February 2007 - * - * @todo one sql call should do the trick - */ - static function get_questions($survey_id) { - // Table definitions - $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + // Getting the information of the question + + $result = Database::query($sql); + $row = Database::fetch_array($result,'ASSOC'); + $return['survey_id'] = $row['survey_id']; + $return['question_id'] = $row['question_id']; + $return['type'] = $row['type']; + $return['question'] = $row['survey_question']; + $return['horizontalvertical'] = $row['display']; + $return['shared_question_id'] = $row['shared_question_id']; + $return['maximum_score'] = $row['max_value']; + + if ($row['survey_group_pri'] != 0) { + $return['assigned'] = $row['survey_group_pri']; + $return['choose'] = 1; + } else { + $return['assigned1'] = $row['survey_group_sec1']; + $return['assigned2'] = $row['survey_group_sec2']; + $return['choose'] = 2; + } + + // Getting the information of the question options + + $result = Database::query($sql_survey_question_option); + while ($row = Database::fetch_array($result, 'ASSOC')) { + /** @todo this should be renamed to options instead of answers */ + $return['answers'][] = $row['option_text']; + $return['values'][] = $row['value']; + + /** @todo this can be done more elegantly (used in reporting) */ + $return['answersid'][] = $row['question_option_id']; + } + return $return; + } + + /** + * This function gets all the question of any given survey + * + * @param integer $survey_id the id of the survey + * @return array containing all the questions of the survey + * + * @author Patrick Cool , Ghent University + * @version February 2007 + * + * @todo one sql call should do the trick + */ + static function get_questions($survey_id) { + // Table definitions + $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); $course_id = api_get_course_int_id(); - // Getting the information of the question - $sql = "SELECT * FROM $tbl_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'"; - $result = Database::query($sql); - while ($row = Database::fetch_array($result, 'ASSOC')) { - $return[$row['question_id']]['survey_id'] = $row['survey_id']; - $return[$row['question_id']]['question_id'] = $row['question_id']; - $return[$row['question_id']]['type'] = $row['type']; - $return[$row['question_id']]['question'] = $row['survey_question']; - $return[$row['question_id']]['horizontalvertical'] = $row['display']; - $return[$row['question_id']]['maximum_score'] = $row['max_value']; - $return[$row['question_id']]['sort'] = $row['sort']; - - } - - // Getting the information of the question options - $sql = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'"; - $result = Database::query($sql); - while ($row = Database::fetch_array($result, 'ASSOC')) { - $return[$row['question_id']]['answers'][] = $row['option_text']; - } - - return $return; - } - - /** - * This function saves a question in the database. - * This can be either an update of an existing survey or storing a new survey - * - * @param array $form_content all the information of the form - * - * @author Patrick Cool , Ghent University - * @version January 2007 - */ - - function save_question($form_content) { - global $survey_data; + // Getting the information of the question + $sql = "SELECT * FROM $tbl_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'"; + $result = Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $return[$row['question_id']]['survey_id'] = $row['survey_id']; + $return[$row['question_id']]['question_id'] = $row['question_id']; + $return[$row['question_id']]['type'] = $row['type']; + $return[$row['question_id']]['question'] = $row['survey_question']; + $return[$row['question_id']]['horizontalvertical'] = $row['display']; + $return[$row['question_id']]['maximum_score'] = $row['max_value']; + $return[$row['question_id']]['sort'] = $row['sort']; - if (strlen($form_content['question']) > 1) { // Checks lenght of the question - $empty_answer = false; + } - if ($survey_data['survey_type'] == 1) { - if (empty($form_content['choose'])) { - $return_message = 'PleaseChooseACondition'; - return $return_message; - } + // Getting the information of the question options + $sql = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'"; + $result = Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $return[$row['question_id']]['answers'][] = $row['option_text']; + } - if (($form_content['choose']==2)&&($form_content['assigned1'] == $form_content['assigned2'])) { - $return_message = 'ChooseDifferentCategories'; - return $return_message; - } - } + return $return; + } + + /** + * This function saves a question in the database. + * This can be either an update of an existing survey or storing a new survey + * + * @param array $form_content all the information of the form + * + * @author Patrick Cool , Ghent University + * @version January 2007 + */ + + function save_question($form_content) { + global $survey_data; + + if (strlen($form_content['question']) > 1) { // Checks lenght of the question + $empty_answer = false; + + if ($survey_data['survey_type'] == 1) { + if (empty($form_content['choose'])) { + $return_message = 'PleaseChooseACondition'; + return $return_message; + } + + if (($form_content['choose']==2)&&($form_content['assigned1'] == $form_content['assigned2'])) { + $return_message = 'ChooseDifferentCategories'; + return $return_message; + } + } - if ($form_content['type'] != 'percentage') { - for ($i = 0; $i < count($form_content['answers']); $i++) { - if (strlen($form_content['answers'][$i]) < 1) { - $empty_answer = true; - break; - } - } - } + if ($form_content['type'] != 'percentage') { + for ($i = 0; $i < count($form_content['answers']); $i++) { + if (strlen($form_content['answers'][$i]) < 1) { + $empty_answer = true; + break; + } + } + } - if ($form_content['type'] == 'score') { - if (strlen($form_content['maximum_score']) < 1) { - $empty_answer = true; - } - } - $additional = array(); + if ($form_content['type'] == 'score') { + if (strlen($form_content['maximum_score']) < 1) { + $empty_answer = true; + } + } + $additional = array(); $course_id = api_get_course_int_id(); - if (!$empty_answer) { - // Table definitions - $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - - // Getting all the information of the survey - $survey_data = survey_manager::get_survey($form_content['survey_id']); - - // Storing the question in the shared database - if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { - $shared_question_id = survey_manager::save_shared_question($form_content, $survey_data); - $form_content['shared_question_id'] = $shared_question_id; - } - - // Storing a new question - if ($form_content['question_id'] == '' || !is_numeric($form_content['question_id'])) { - // Finding the max sort order of the questions in the given survey - $sql = "SELECT max(sort) AS max_sort FROM $tbl_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($form_content['survey_id'])."'"; - $result = Database::query($sql); - $row = Database::fetch_array($result,'ASSOC'); - $max_sort = $row['max_sort']; - - // Some variables defined for survey-test type - $additional['column'] = ''; - $additional['value'] = ''; - - if ($_POST['choose'] == 1) { - $additional['column'] = ',survey_group_pri'; - $additional['value'] = ",'".Database::escape_string($_POST['assigned'])."'"; - } elseif($_POST['choose'] == 2) { - $additional['column'] = ',survey_group_sec1, survey_group_sec2'; - $additional['value'] = ",'".Database::escape_string($_POST['assigned1'])."'".",'".Database::escape_string($_POST['assigned2'])."'"; - } + if (!$empty_answer) { + // Table definitions + $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + + // Getting all the information of the survey + $survey_data = survey_manager::get_survey($form_content['survey_id']); + + // Storing the question in the shared database + if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { + $shared_question_id = survey_manager::save_shared_question($form_content, $survey_data); + $form_content['shared_question_id'] = $shared_question_id; + } + + // Storing a new question + if ($form_content['question_id'] == '' || !is_numeric($form_content['question_id'])) { + // Finding the max sort order of the questions in the given survey + $sql = "SELECT max(sort) AS max_sort FROM $tbl_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($form_content['survey_id'])."'"; + $result = Database::query($sql); + $row = Database::fetch_array($result,'ASSOC'); + $max_sort = $row['max_sort']; + + // Some variables defined for survey-test type + $additional['column'] = ''; + $additional['value'] = ''; + + if ($_POST['choose'] == 1) { + $additional['column'] = ',survey_group_pri'; + $additional['value'] = ",'".Database::escape_string($_POST['assigned'])."'"; + } elseif($_POST['choose'] == 2) { + $additional['column'] = ',survey_group_sec1, survey_group_sec2'; + $additional['value'] = ",'".Database::escape_string($_POST['assigned1'])."'".",'".Database::escape_string($_POST['assigned2'])."'"; + } - // Adding the question to the survey_question table - $sql = "INSERT INTO $tbl_survey_question (c_id, survey_id,survey_question,survey_question_comment,type,display, sort, shared_question_id, max_value".$additional['column'].") VALUES ( + // Adding the question to the survey_question table + $sql = "INSERT INTO $tbl_survey_question (c_id, survey_id,survey_question,survey_question_comment,type,display, sort, shared_question_id, max_value".$additional['column'].") VALUES ( $course_id, '".Database::escape_string($form_content['survey_id'])."', '".Database::escape_string($form_content['question'])."', @@ -795,84 +808,84 @@ class survey_manager { '".Database::escape_string($max_sort+1)."', '".Database::escape_string($form_content['shared_question_id'])."', '".Database::escape_string($form_content['maximum_score'])."'". - $additional['value']." + $additional['value']." )"; - Database::query($sql); - $question_id = Database::insert_id(); - $form_content['question_id'] = $question_id; - $return_message = 'QuestionAdded'; + Database::query($sql); + $question_id = Database::insert_id(); + $form_content['question_id'] = $question_id; + $return_message = 'QuestionAdded'; - } else { + } else { // Updating an existing question - $additionalsets = ''; + $additionalsets = ''; - if ($_POST['choose'] == 1) { - $additionalsets = ',survey_group_pri = \''.Database::escape_string($_POST['assigned']).'\', survey_group_sec1 = \'0\', survey_group_sec2 = \'0\' '; - } - elseif ($_POST['choose'] == 2) { - $additionalsets = ',survey_group_pri = \'0\', survey_group_sec1 = \''.Database::escape_string($_POST['assigned1']).'\', survey_group_sec2 = \''.Database::escape_string($_POST['assigned2']).'\' '; - } + if ($_POST['choose'] == 1) { + $additionalsets = ',survey_group_pri = \''.Database::escape_string($_POST['assigned']).'\', survey_group_sec1 = \'0\', survey_group_sec2 = \'0\' '; + } + elseif ($_POST['choose'] == 2) { + $additionalsets = ',survey_group_pri = \'0\', survey_group_sec1 = \''.Database::escape_string($_POST['assigned1']).'\', survey_group_sec2 = \''.Database::escape_string($_POST['assigned2']).'\' '; + } - $setadditionals = $additional['set'][1].$additional['set'][2].$additional['set'][3]; + $setadditionals = $additional['set'][1].$additional['set'][2].$additional['set'][3]; - // Adding the question to the survey_question table - $sql = "UPDATE $tbl_survey_question SET + // Adding the question to the survey_question table + $sql = "UPDATE $tbl_survey_question SET survey_question = '".Database::escape_string($form_content['question'])."', survey_question_comment = '".Database::escape_string($form_content['question_comment'])."', display = '".Database::escape_string($form_content['horizontalvertical'])."', max_value = '".Database::escape_string($form_content['maximum_score'])."'" . - $additionalsets." + $additionalsets." WHERE c_id = $course_id AND question_id = '".Database::escape_string($form_content['question_id'])."'"; - $result = Database::query($sql); - $return_message = 'QuestionUpdated'; - } + $result = Database::query($sql); + $return_message = 'QuestionUpdated'; + } if (!empty($form_content['survey_id'])) { //Updating survey api_item_property_update(api_get_course_info(), TOOL_SURVEY, $form_content['survey_id'], 'SurveyUpdated', api_get_user_id()); } - // Storing the options of the question - $message_options=survey_manager::save_question_options($form_content, $survey_data); - } else { - $return_message = 'PleasFillAllAnswer'; - } - } else { - $return_message = 'PleaseEnterAQuestion'; - } - return $return_message; - } - - /** - * This function saves the question in the shared database - * - * @param array $form_content all the information of the form - * @param array $survey_data all the information of the survey - * - * @author Patrick Cool , Ghent University - * @version February 2007 - * - * @todo editing of a shared question - */ - function save_shared_question($form_content, $survey_data) { - global $_course; - - // Table definitions - $tbl_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); - - // Storing a new question - if ($form_content['shared_question_id'] == '' || !is_numeric($form_content['shared_question_id'])) { - // Finding the max sort order of the questions in the given survey - $sql = "SELECT max(sort) AS max_sort FROM $tbl_survey_question + // Storing the options of the question + $message_options=survey_manager::save_question_options($form_content, $survey_data); + } else { + $return_message = 'PleasFillAllAnswer'; + } + } else { + $return_message = 'PleaseEnterAQuestion'; + } + return $return_message; + } + + /** + * This function saves the question in the shared database + * + * @param array $form_content all the information of the form + * @param array $survey_data all the information of the survey + * + * @author Patrick Cool , Ghent University + * @version February 2007 + * + * @todo editing of a shared question + */ + function save_shared_question($form_content, $survey_data) { + global $_course; + + // Table definitions + $tbl_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); + + // Storing a new question + if ($form_content['shared_question_id'] == '' || !is_numeric($form_content['shared_question_id'])) { + // Finding the max sort order of the questions in the given survey + $sql = "SELECT max(sort) AS max_sort FROM $tbl_survey_question WHERE survey_id='".Database::escape_string($survey_data['survey_share'])."' AND code='".Database::escape_string($_course['id'])."'"; - $result = Database::query($sql); - $row = Database::fetch_array($result,'ASSOC'); - $max_sort = $row['max_sort']; + $result = Database::query($sql); + $row = Database::fetch_array($result,'ASSOC'); + $max_sort = $row['max_sort']; - // Adding the question to the survey_question table - $sql = "INSERT INTO $tbl_survey_question (survey_id, survey_question, survey_question_comment, type, display, sort, code) VALUES ( + // Adding the question to the survey_question table + $sql = "INSERT INTO $tbl_survey_question (survey_id, survey_question, survey_question_comment, type, display, sort, code) VALUES ( '".Database::escape_string($survey_data['survey_share'])."', '".Database::escape_string($form_content['question'])."', '".Database::escape_string($form_content['question_comment'])."', @@ -880,404 +893,404 @@ class survey_manager { '".Database::escape_string($form_content['horizontalvertical'])."', '".Database::escape_string($max_sort+1)."', '".Database::escape_string($_course['id'])."')"; - $result = Database::query($sql); - $shared_question_id = Database::insert_id(); - } - // Updating an existing question - else { - // adding the question to the survey_question table - $sql = "UPDATE $tbl_survey_question SET + $result = Database::query($sql); + $shared_question_id = Database::insert_id(); + } + // Updating an existing question + else { + // adding the question to the survey_question table + $sql = "UPDATE $tbl_survey_question SET survey_question = '".Database::escape_string($form_content['question'])."', survey_question_comment = '".Database::escape_string($form_content['question_comment'])."', display = '".Database::escape_string($form_content['horizontalvertical'])."' WHERE question_id = '".Database::escape_string($form_content['shared_question_id'])."' AND code='".Database::escape_string($_course['id'])."'"; - $result = Database::query($sql); - $shared_question_id = $form_content['shared_question_id']; - } + $result = Database::query($sql); + $shared_question_id = $form_content['shared_question_id']; + } - return $shared_question_id; - } + return $shared_question_id; + } + + /** + * This functions moves a question of a survey up or down + * + * @param string $direction + * @param integer $survey_question_id + * @param integer $survey_id + * + * @author Patrick Cool , Ghent University + * @version January 2007 + */ + static function move_survey_question($direction, $survey_question_id, $survey_id) { + // Table definition + $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + + $course_id = api_get_course_int_id(); + + if ($direction == 'moveup') { + $sort = 'DESC'; + } + if ($direction == 'movedown') { + $sort = 'ASC'; + } - /** - * This functions moves a question of a survey up or down - * - * @param string $direction - * @param integer $survey_question_id - * @param integer $survey_id - * - * @author Patrick Cool , Ghent University - * @version January 2007 - */ - static function move_survey_question($direction, $survey_question_id, $survey_id) { - // Table definition - $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + // Finding the two questions that needs to be swapped + $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."' ORDER BY sort $sort"; + $result = Database::query($sql); + $found = false; + while ($row = Database::fetch_array($result, 'ASSOC')) { + if ($found) { + $question_id_two = $row['question_id']; + $question_sort_two = $row['sort']; + $found = false; + } + if ($row['question_id'] == $survey_question_id) { + $found = true; + $question_id_one = $row['question_id']; + $question_sort_one = $row['sort']; + } + } - $course_id = api_get_course_int_id(); + $sql1 = "UPDATE $table_survey_question SET sort = '".Database::escape_string($question_sort_two)."' WHERE c_id = $course_id AND question_id='".Database::escape_string($question_id_one)."'"; + $result = Database::query($sql1); + $sql2 = "UPDATE $table_survey_question SET sort = '".Database::escape_string($question_sort_one)."' WHERE c_id = $course_id AND question_id='".Database::escape_string($question_id_two)."'"; + $result = Database::query($sql2); + } + + + /** + * This function deletes all the questions of a given survey + * This function is normally only called when a survey is deleted + * + * @param $survey_id the id of the survey that has to be deleted + * @return true + * + * @author Patrick Cool , Ghent University + * @version January 2007 + */ + static function delete_all_survey_questions($survey_id, $shared = false) { + $course_id = api_get_course_int_id(); + + // Table definitions + $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $course_condition = " c_id = $course_id AND "; + if ($shared) { + $course_condition = ""; + $table_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); + } - if ($direction == 'moveup') { - $sort = 'DESC'; - } - if ($direction == 'movedown') { - $sort = 'ASC'; - } + $sql = "DELETE FROM $table_survey_question WHERE $course_condition survey_id='".Database::escape_string($survey_id)."'"; - // Finding the two questions that needs to be swapped - $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."' ORDER BY sort $sort"; - $result = Database::query($sql); - $found = false; - while ($row = Database::fetch_array($result, 'ASSOC')) { - if ($found) { - $question_id_two = $row['question_id']; - $question_sort_two = $row['sort']; - $found = false; - } - if ($row['question_id'] == $survey_question_id) { - $found = true; - $question_id_one = $row['question_id']; - $question_sort_one = $row['sort']; - } - } + // Deleting the survey questions - $sql1 = "UPDATE $table_survey_question SET sort = '".Database::escape_string($question_sort_two)."' WHERE c_id = $course_id AND question_id='".Database::escape_string($question_id_one)."'"; - $result = Database::query($sql1); - $sql2 = "UPDATE $table_survey_question SET sort = '".Database::escape_string($question_sort_one)."' WHERE c_id = $course_id AND question_id='".Database::escape_string($question_id_two)."'"; - $result = Database::query($sql2); - } + Database::query($sql); + // Deleting all the options of the questions of the survey + survey_manager::delete_all_survey_questions_options($survey_id, $shared); - /** - * This function deletes all the questions of a given survey - * This function is normally only called when a survey is deleted - * - * @param $survey_id the id of the survey that has to be deleted - * @return true - * - * @author Patrick Cool , Ghent University - * @version January 2007 - */ - static function delete_all_survey_questions($survey_id, $shared = false) { + // Deleting all the answers on this survey + survey_manager::delete_all_survey_answers($survey_id); + } + + /** + * This function deletes a survey question and all its options + * + * @param integer $survey_id the id of the survey + * @param integer $question_id the id of the question + * @param integer $shared + * + * @todo also delete the answers to this question + * + * @author Patrick Cool , Ghent University + * @version March 2007 + */ + static function delete_survey_question($survey_id, $question_id, $shared = false) { $course_id = api_get_course_int_id(); + // Table definitions + $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + if ($shared) { + survey_manager::delete_shared_survey_question($survey_id, $question_id); + } - // Table definitions - $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - $course_condition = " c_id = $course_id AND "; - if ($shared) { - $course_condition = ""; - $table_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); - } - - $sql = "DELETE FROM $table_survey_question WHERE $course_condition survey_id='".Database::escape_string($survey_id)."'"; - - // Deleting the survey questions - - Database::query($sql); - - // Deleting all the options of the questions of the survey - survey_manager::delete_all_survey_questions_options($survey_id, $shared); - - // Deleting all the answers on this survey - survey_manager::delete_all_survey_answers($survey_id); - } - - /** - * This function deletes a survey question and all its options - * - * @param integer $survey_id the id of the survey - * @param integer $question_id the id of the question - * @param integer $shared - * - * @todo also delete the answers to this question - * - * @author Patrick Cool , Ghent University - * @version March 2007 - */ - static function delete_survey_question($survey_id, $question_id, $shared = false) { - $course_id = api_get_course_int_id(); - // Table definitions - $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - if ($shared) { - survey_manager::delete_shared_survey_question($survey_id, $question_id); - } - - // Deleting the survey questions - $sql = "DELETE FROM $table_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."' AND question_id='".Database::escape_string($question_id)."'"; - $res = Database::query($sql); - - // Deleting the options of the question of the survey - survey_manager::delete_survey_question_option($survey_id, $question_id, $shared); - } - - /** - * This function deletes a shared survey question from the main database and all its options - * - * @param integer $question_id the id of the question - * @param integer $shared - * - * @todo delete all the options of this question - * - * @author Patrick Cool , Ghent University - * @version March 2007 - */ - static function delete_shared_survey_question($survey_id, $question_id) { - // Table definitions - $table_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); - $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); - - // First we have to get the shared_question_id - $question_data = survey_manager::get_question($question_id); - - // Deleting the survey questions - $sql = "DELETE FROM $table_survey_question WHERE question_id='".Database::escape_string($question_data['shared_question_id'])."'"; - $res = Database::query($sql); - - // Deleting the options of the question of the survey question - $sql = "DELETE FROM $table_survey_question_option WHERE question_id='".Database::escape_string($question_data['shared_question_id'])."'"; - $res = Database::query($sql); - } + // Deleting the survey questions + $sql = "DELETE FROM $table_survey_question WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."' AND question_id='".Database::escape_string($question_id)."'"; + $res = Database::query($sql); - /** - * SURVEY QUESTION OPTIONS FUNCTIONS - */ + // Deleting the options of the question of the survey + survey_manager::delete_survey_question_option($survey_id, $question_id, $shared); + } + + /** + * This function deletes a shared survey question from the main database and all its options + * + * @param integer $question_id the id of the question + * @param integer $shared + * + * @todo delete all the options of this question + * + * @author Patrick Cool , Ghent University + * @version March 2007 + */ + static function delete_shared_survey_question($survey_id, $question_id) { + // Table definitions + $table_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION); + $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); + + // First we have to get the shared_question_id + $question_data = survey_manager::get_question($question_id); + + // Deleting the survey questions + $sql = "DELETE FROM $table_survey_question WHERE question_id='".Database::escape_string($question_data['shared_question_id'])."'"; + $res = Database::query($sql); - /** - * This function stores the options of the questions in the table - * - * @param array $form_content - * @author Patrick Cool , Ghent University - * @version January 2007 - * - * @todo writing the update statement when editing a question - */ - function save_question_options($form_content, $survey_data) { - $course_id = api_get_course_int_id(); - // A percentage question type has options 1 -> 100 - if ($form_content['type'] == 'percentage') { - for($i = 1; $i < 101; $i++) { - $form_content['answers'][] = $i; - } - } + // Deleting the options of the question of the survey question + $sql = "DELETE FROM $table_survey_question_option WHERE question_id='".Database::escape_string($question_data['shared_question_id'])."'"; + $res = Database::query($sql); + } + + /** + * SURVEY QUESTION OPTIONS FUNCTIONS + */ + + /** + * This function stores the options of the questions in the table + * + * @param array $form_content + * @author Patrick Cool , Ghent University + * @version January 2007 + * + * @todo writing the update statement when editing a question + */ + function save_question_options($form_content, $survey_data) { + $course_id = api_get_course_int_id(); + // A percentage question type has options 1 -> 100 + if ($form_content['type'] == 'percentage') { + for($i = 1; $i < 101; $i++) { + $form_content['answers'][] = $i; + } + } - if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { - survey_manager::save_shared_question_options($form_content, $survey_data); - } + if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { + survey_manager::save_shared_question_options($form_content, $survey_data); + } - // Table defintion - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + // Table defintion + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); - // We are editing a question so we first have to remove all the existing options from the database - if (is_numeric($form_content['question_id'])) { - $sql = "DELETE FROM $table_survey_question_option WHERE c_id = $course_id AND question_id = '".Database::escape_string($form_content['question_id'])."'"; - $result = Database::query($sql); - } + // We are editing a question so we first have to remove all the existing options from the database + if (is_numeric($form_content['question_id'])) { + $sql = "DELETE FROM $table_survey_question_option WHERE c_id = $course_id AND question_id = '".Database::escape_string($form_content['question_id'])."'"; + $result = Database::query($sql); + } - $counter = 1; - if (is_array($form_content['answers'])) { - //foreach ($form_content['answers'] as $key => $answer) { - for ($i = 0; $i < count($form_content['answers']); $i++) { - $sql = "INSERT INTO $table_survey_question_option (c_id, question_id, survey_id, option_text, value,sort) VALUES ( + $counter = 1; + if (is_array($form_content['answers'])) { + //foreach ($form_content['answers'] as $key => $answer) { + for ($i = 0; $i < count($form_content['answers']); $i++) { + $sql = "INSERT INTO $table_survey_question_option (c_id, question_id, survey_id, option_text, value,sort) VALUES ( $course_id, '".Database::escape_string($form_content['question_id'])."', '".Database::escape_string($form_content['survey_id'])."', '".Database::escape_string($form_content['answers'][$i])."', '".Database::escape_string($form_content['values'][$i])."', '".Database::escape_string($counter)."')"; - $result = Database::query($sql); - $counter++; - } - } - } - - /** - * This function stores the options of the questions in the shared table - * - * @param array $form_content - * - * @author Patrick Cool , Ghent University - * @version February 2007 - * - * @todo writing the update statement when editing a question - */ - function save_shared_question_options($form_content, $survey_data) { - if (is_array($form_content) && is_array($form_content['answers'])) { - // Table defintion - $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); - - // We are editing a question so we first have to remove all the existing options from the database - $sql = "DELETE FROM $table_survey_question_option WHERE question_id = '".Database::escape_string($form_content['shared_question_id'])."'"; - $result = Database::query($sql); - - $counter = 1; - - foreach ($form_content['answers'] as $key => & $answer) { - $sql = "INSERT INTO $table_survey_question_option (question_id, survey_id, option_text, sort) VALUES ( + $result = Database::query($sql); + $counter++; + } + } + } + + /** + * This function stores the options of the questions in the shared table + * + * @param array $form_content + * + * @author Patrick Cool , Ghent University + * @version February 2007 + * + * @todo writing the update statement when editing a question + */ + function save_shared_question_options($form_content, $survey_data) { + if (is_array($form_content) && is_array($form_content['answers'])) { + // Table defintion + $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); + + // We are editing a question so we first have to remove all the existing options from the database + $sql = "DELETE FROM $table_survey_question_option WHERE question_id = '".Database::escape_string($form_content['shared_question_id'])."'"; + $result = Database::query($sql); + + $counter = 1; + + foreach ($form_content['answers'] as $key => & $answer) { + $sql = "INSERT INTO $table_survey_question_option (question_id, survey_id, option_text, sort) VALUES ( '".Database::escape_string($form_content['shared_question_id'])."', '".Database::escape_string($survey_data['is_shared'])."', '".Database::escape_string($answer)."', '".Database::escape_string($counter)."')"; - $result = Database::query($sql); - $counter++; - } - } - } + $result = Database::query($sql); + $counter++; + } + } + } - /* + /* if (is_numeric($survey_data['survey_share']) AND $survey_data['survey_share'] != 0) { $form_content = survey_manager::save_shared_question($form_content, $survey_data); } */ - /** - * This function deletes all the options of the questions of a given survey - * This function is normally only called when a survey is deleted - * - * @param $survey_id the id of the survey that has to be deleted - * @return true - * - * @author Patrick Cool , Ghent University - * @version January 2007 - */ - static function delete_all_survey_questions_options($survey_id, $shared = false) { - - // Table definitions - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + /** + * This function deletes all the options of the questions of a given survey + * This function is normally only called when a survey is deleted + * + * @param $survey_id the id of the survey that has to be deleted + * @return true + * + * @author Patrick Cool , Ghent University + * @version January 2007 + */ + static function delete_all_survey_questions_options($survey_id, $shared = false) { + + // Table definitions + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); $course_id = api_get_course_int_id(); $course_condition = " c_id = $course_id AND "; - if ($shared) { - $course_condition = ""; - $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); - } + if ($shared) { + $course_condition = ""; + $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); + } $sql = "DELETE FROM $table_survey_question_option WHERE $course_condition survey_id='".Database::escape_string($survey_id)."'"; - // Deleting the options of the survey questions - - $res = Database::query($sql); - return true; - } + // Deleting the options of the survey questions - /** - * This function deletes the options of a given question - * - * @param unknown_type $survey_id - * @param unknown_type $question_id - * @param unknown_type $shared - * @return unknown - * - * @author Patrick Cool , Ghent University - * @version March 2007 - */ - static function delete_survey_question_option($survey_id, $question_id, $shared = false) { - $course_id = api_get_course_int_id(); + $res = Database::query($sql); + return true; + } + + /** + * This function deletes the options of a given question + * + * @param unknown_type $survey_id + * @param unknown_type $question_id + * @param unknown_type $shared + * @return unknown + * + * @author Patrick Cool , Ghent University + * @version March 2007 + */ + static function delete_survey_question_option($survey_id, $question_id, $shared = false) { + $course_id = api_get_course_int_id(); $course_condition = " c_id = $course_id AND "; - // Table definitions - $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); - if ($shared) { - $course_condition = ""; - $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); - } - - // Deleting the options of the survey questions - $sql = "DELETE from $table_survey_question_option WHERE $course_condition survey_id='".Database::escape_string($survey_id)."' AND question_id='".Database::escape_string($question_id)."'"; - $res = Database::query($sql); - return true; - } - - /** - * SURVEY ANSWERS FUNCTIONS - */ + // Table definitions + $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + if ($shared) { + $course_condition = ""; + $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION); + } - /** - * This function deletes all the answers anyone has given on this survey - * This function is normally only called when a survey is deleted - * - * @param $survey_id the id of the survey that has to be deleted - * @return true - * - * @todo write the function - * - * @author Patrick Cool , Ghent University - * @version January 2007,december 2008 - */ - static function delete_all_survey_answers($survey_id) { + // Deleting the options of the survey questions + $sql = "DELETE from $table_survey_question_option WHERE $course_condition survey_id='".Database::escape_string($survey_id)."' AND question_id='".Database::escape_string($question_id)."'"; + $res = Database::query($sql); + return true; + } + + /** + * SURVEY ANSWERS FUNCTIONS + */ + + /** + * This function deletes all the answers anyone has given on this survey + * This function is normally only called when a survey is deleted + * + * @param $survey_id the id of the survey that has to be deleted + * @return true + * + * @todo write the function + * + * @author Patrick Cool , Ghent University + * @version January 2007,december 2008 + */ + static function delete_all_survey_answers($survey_id) { $course_id = api_get_course_int_id(); - $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); - $survey_id = intval($survey_id); - Database::query("DELETE FROM $table_survey_answer WHERE c_id = $course_id AND survey_id=$survey_id"); - return true; - } + $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); + $survey_id = intval($survey_id); + Database::query("DELETE FROM $table_survey_answer WHERE c_id = $course_id AND survey_id=$survey_id"); + return true; + } - static function is_user_filled_survey($user_id, $survey_id, $course_id) { - $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); + static function is_user_filled_survey($user_id, $survey_id, $course_id) { + $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); - $user_id = intval($user_id); - $course_id = intval($course_id); - $survey_id = intval($survey_id); + $user_id = intval($user_id); + $course_id = intval($course_id); + $survey_id = intval($survey_id); - $sql = "SELECT DISTINCT user FROM $table_survey_answer + $sql = "SELECT DISTINCT user FROM $table_survey_answer WHERE c_id = $course_id AND user = $user_id AND survey_id = $survey_id"; - $result = Database::query($sql); - if (Database::num_rows($result)) { - return true; - } - return false; + $result = Database::query($sql); + if (Database::num_rows($result)) { + return true; + } + return false; - } + } - /** - * This function gets all the persons who have filled the survey - * - * @param integer $survey_id - * @return array - * - * @author Patrick Cool , Ghent University - * @version February 2007 - */ - static function get_people_who_filled_survey($survey_id, $all_user_info = false, $course_id = null) { + /** + * This function gets all the persons who have filled the survey + * + * @param integer $survey_id + * @return array + * + * @author Patrick Cool , Ghent University + * @version February 2007 + */ + static function get_people_who_filled_survey($survey_id, $all_user_info = false, $course_id = null) { - // Database table definition - $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); - $table_user = Database :: get_main_table(TABLE_MAIN_USER); + // Database table definition + $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); + $table_user = Database :: get_main_table(TABLE_MAIN_USER); - // Variable initialisation - $return = array(); + // Variable initialisation + $return = array(); - // Getting the survey information - $survey_data = survey_manager::get_survey($survey_id); + // Getting the survey information + $survey_data = survey_manager::get_survey($survey_id); - if (empty($course_id)) { + if (empty($course_id)) { $course_id = api_get_course_int_id(); } else { $course_id = intval($course_id); } - if ($all_user_info) { - $order_clause = api_sort_by_first_name() ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; - $sql = "SELECT DISTINCT answered_user.user as invited_user, user.firstname, user.lastname, user.user_id + if ($all_user_info) { + $order_clause = api_sort_by_first_name() ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; + $sql = "SELECT DISTINCT answered_user.user as invited_user, user.firstname, user.lastname, user.user_id FROM $table_survey_answer answered_user LEFT JOIN $table_user as user ON answered_user.user = user.user_id WHERE answered_user.c_id = $course_id AND survey_id= '".Database::escape_string($survey_data['survey_id'])."' ". - $order_clause; - } else { - $sql = "SELECT DISTINCT user FROM $table_survey_answer + $order_clause; + } else { + $sql = "SELECT DISTINCT user FROM $table_survey_answer WHERE c_id = $course_id AND survey_id= '".Database::escape_string($survey_data['survey_id'])."' "; - } + } - $res = Database::query($sql); - while ($row = Database::fetch_array($res, 'ASSOC')) { - if ($all_user_info) { - $return[] = $row; - } else { - $return[] = $row['user']; - } - } - return $return; - } + $res = Database::query($sql); + while ($row = Database::fetch_array($res, 'ASSOC')) { + if ($all_user_info) { + $return[] = $row; + } else { + $return[] = $row['user']; + } + } + return $return; + } static function survey_generation_hash_available() { if (extension_loaded('mcrypt')) { @@ -1308,57 +1321,57 @@ class survey_manager { class survey_question { - // The html code of the form - public $html; - - /** - * This function does the generic part of any survey question: the question field - * - * @author Patrick Cool , Ghent University - * @version January 2007 - * - * @todo the form_text has to become a wysiwyg editor or adding a question_comment field - * @todo consider adding a question_comment form element - */ - function create_form($form_content) { - - global $survey_data; - - //$tool_name = ''.get_lang(ucfirst($_GET['type'])).''; - $tool_name = Display::return_icon(survey_manager::icon_question(Security::remove_XSS($_GET['type'])), get_lang(ucfirst(Security::remove_XSS($_GET['type']))), array('align' => 'middle', 'height' => '22px')).' '; - if ($_GET['action'] == 'add') { - $tool_name .= get_lang('AddQuestion'); - } - if ($_GET['action'] == 'edit') { - $tool_name .= get_lang('EditQuestion'); - } + // The html code of the form + public $html; + + /** + * This function does the generic part of any survey question: the question field + * + * @author Patrick Cool , Ghent University + * @version January 2007 + * + * @todo the form_text has to become a wysiwyg editor or adding a question_comment field + * @todo consider adding a question_comment form element + */ + function create_form($form_content) { + + global $survey_data; + + //$tool_name = ''.get_lang(ucfirst($_GET['type'])).''; + $tool_name = Display::return_icon(survey_manager::icon_question(Security::remove_XSS($_GET['type'])), get_lang(ucfirst(Security::remove_XSS($_GET['type']))), array('align' => 'middle', 'height' => '22px')).' '; + if ($_GET['action'] == 'add') { + $tool_name .= get_lang('AddQuestion'); + } + if ($_GET['action'] == 'edit') { + $tool_name .= get_lang('EditQuestion'); + } - if ($_GET['type'] == 'yesno') { - $tool_name .= ': '.get_lang('YesNo'); - } else if ($_GET['type'] == 'multiplechoice') { - $tool_name .= ': '.get_lang('UniqueSelect'); - } else { - $tool_name .= ': '.get_lang(api_ucfirst(Security::remove_XSS($_GET['type']))); - } + if ($_GET['type'] == 'yesno') { + $tool_name .= ': '.get_lang('YesNo'); + } else if ($_GET['type'] == 'multiplechoice') { + $tool_name .= ': '.get_lang('UniqueSelect'); + } else { + $tool_name .= ': '.get_lang(api_ucfirst(Security::remove_XSS($_GET['type']))); + } - $this->html .= '
    '; + $this->html .= ''; $this->html .= ''.$tool_name.''; - $this->html .= ' '; - $this->html .= ' '; - $this->html .= ' '; - $this->html .= ' '; - - // question field - $this->html .= '
    '; - $this->html .= ' '; - $this->html .= '
    '; - $this->html .= api_return_html_area('question', Security::remove_XSS(stripslashes($form_content['question']), STUDENT), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')); - $this->html .= '
    '; - $this->html .= '
    '; - - /* + $this->html .= ' '; + $this->html .= ' '; + $this->html .= ' '; + $this->html .= ' '; + + // question field + $this->html .= '
    '; + $this->html .= ' '; + $this->html .= '
    '; + $this->html .= api_return_html_area('question', Security::remove_XSS(stripslashes($form_content['question']), STUDENT), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')); + $this->html .= '
    '; + $this->html .= '
    '; + + /* $this->html .= ' '; $this->html .= ' '; $this->html .= ' '; @@ -1367,856 +1380,852 @@ class survey_question { */ - if ($survey_data['survey_type'] == 1) { - $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); - $sql = 'SELECT id,name FROM '.$table_survey_question_group.' WHERE survey_id = '.(int)$_GET['survey_id'].' ORDER BY name'; - $rs = Database::query($sql); + if ($survey_data['survey_type'] == 1) { + $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); + $sql = 'SELECT id,name FROM '.$table_survey_question_group.' WHERE survey_id = '.(int)$_GET['survey_id'].' ORDER BY name'; + $rs = Database::query($sql); - while ($row = Database::fetch_array($rs, 'NUM')) { - $glist .= ''; - } + while ($row = Database::fetch_array($rs, 'NUM')) { + $glist .= ''; + } - $grouplist = $grouplist1 = $grouplist2 = $glist; + $grouplist = $grouplist1 = $grouplist2 = $glist; - if (!empty($form_content['assigned'])) { - $grouplist = str_replace('

@@ -541,7 +454,6 @@ Luego (para actualización desde versiones anteriores a la 1.8.7):

4. Solución de problemas

-

Si usted tiene problemas, vaya al Sitio Web de Chamilo y haga una pregunta en el foro de soporte. Por favor, primero lea los mensajes previos para ver si existe ya una respuesta a su pregunta. Nosotros también mantenemos una lista de @@ -557,7 +469,7 @@ una respuesta a su pregunta. Nosotros también mantenemos una lista de

Para acceder a la sección de administración de Chamilo, abra el navegador, diríjase a su dirección de Chamilo y acceda a el con el usuario admin. -Luego usted verá un enlace a la "Seccion de administracion de la plataforma" en la parte superior +Luego usted verá un enlace a la "Sección de administración de la plataforma" en la parte superior de la página web. En ese lugar usted puede administrar usuarios, cursos, secciones, apariencia del portal contenido de la página principal, categorías de cursos, entre otros.

@@ -568,54 +480,40 @@ contenido de la página principal, categorías de cursos, entre otros.

Esta parte es opcional, solamente organizaciones con un servidor LDAP necesitan leer esto.
- -Un modulo LDAP está ya implementado en Chamilo, pero debe ser configurado para que tenga un correcto funcionamiento. +Un módulo LDAP está ya implementado en Chamilo, pero debe ser configurado para que tenga un correcto funcionamiento.

Compilar

-Servidores Linux: Es posible que se requiera recompilar php con soporte ldap. +Servidores Linux: Es posible que se requiera recompilar PHP con soporte para LDAP. Distribuciones nuevas también permiten descargar rpms para los paquetes adicionales.

Activar LDAP en Chamilo

- +

Nota:El mecanismo de LDAP ha cambiado en 1,9. Como resultado, parte de la información siguiente puede no ser correcta. Por favor, compruebe los ajustes de configuración dentro de Chamilo para conocer los detalles.

En (la carpeta de Chamilo)/main/inc/conf/configuration.php, aproximadamente en la line 90, se puede ver
- //for new login module
- //uncomment these to activate ldap
- //$extAuthSource['ldap']['login'] = "./main/auth/ldap/login.php";
- //$extAuthSource['ldap']['newUser'] = "./main/auth/ldap/newUser.php";
-
- eliminar // de las dos últimas líneas para activar LDAP.
-

Configuraciones

-

Solicitar al administrador del servidor LDAP los siguientes datos:

-
    -
  • nombre del servidor ldap
  • -
  • puerto del servidor ldap (usualmente 389)
  • -
  • dc del ldap
  • -
Desde 1.8.5, usted tiene que cambiar las configuraciones de LDAP dentro del panel "Administración del Portal", bajo "Opciones de configuración de Chamilo", sección @@ -752,6 +650,8 @@ Usted puede habilitar la escritura de ecuaciones matemáticas dentro del editor

Este procedimiento creará un nuevo icono en su editor en línea de Chamilo, el cual hará posible la inserción de fórmulas matemáticas en sus documentos.

+ +

8. Fórmulas matemáticas con ASCIIMathML

@@ -795,10 +695,79 @@ Podría necesitar modificar el ejemplo para tener algo como:

  • ... o algo similar
  • Para formas de probar como la variable AMTcgiloc tiene que ser configurada, existen unos ejemplos (en comentario) dentro del script.

    +

    9. Fórmulas matemáticas con WIRIS

    Instalando este plugin obtendrá WIRIS editor y WIRIS CAS.
    La activación no se realiza completamente si previamente no ha descargado el PHP plugin for FCKeditor de WIRIS y descomprimido su contenido en el directorio de Chamilo main/inc/lib/fckeditor/editor/plugins/fckeditor_wiris/
    Esto es necesario debido a que Wiris es un software propietario y los servicios de Wiris son comerciales. Para realizar ajustes en el plugin edite el archivo configuration.ini o sustituya su contenido por el de configuration.ini.default que acompaña a Chamilo.

    + +
    +

    10. Indexación de texto completo con Xapian

    + +

    +Nota: Este paso requiere de un servidor dedicado o servidor virtual privado (VPS) porque los paquetes involucrados no están disponibles en la mayoría de soluciones de hosting compartido. +

    +

    +En Debian o Ubuntu 10.04 o superior, usted simplemente puede instalar el paquete php5-xapian y reiniciar su servidor web: +

    +sudo apt-get install php5-xapian
    +sudo /etc/init.d/apache2 restart
    +
    +

    +

    +A continuación, vaya a la página de administración -> Ajustes de configuración -> Buscar y habilitar la herramienta de búsqueda. Siga las recomendaciones de la página para obtener la suite completa de indexación instalada. Una vez que haya terminado, todos los documentos importados en su portal Chamilo en un formato reconocido serán indexados y buscados. En formación de administradores de Chamilo ( el cual puede preguntar a cualquier Proveedor Oficial de Chamilo) incluyen una revisión completa de la función de búsqueda de texto completo. +

    + +
    +

    11. Chamilo Rapid - sistema conversion PPT

    +

    +Nota: Este paso requiere un servidor dedicado o un servidor dedicado virtual ya que los paquetes involucrados no están disponibles en la mayoría de soluciones de hosting compartido. (Consulte con su proveedor): +

    +

    +En Debian o Ubuntu 11.10 y superior, instale LibreOffice.org v3 e iniciarlo como un servidor en segundo plano: +

    +sudo apt-get install libreoffice
    +sudo soffice "--accept=socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;" --headless --nodefault --nofirststartwizard --nolockcheck --nologo --norestore
    +
    +

    +

    +A continuación, vaya a la página de administración -> Chamilo Rapid y establecer el host a "localhost" y el puerto a "2002". Guarde los cambios. Vaya a su curso, en la pantalla de herramientas de aprendizaje y verá que apareció un nuevo icono. Importar tu PPT. Esto debería funcionar. +

    +

    +Nota: A veces, esto no se resuelve tan fácilmente. Usted probablemente tenga que solicitar la asistencia de algún administrador de sistemas con un poco de experiencia en Java y PHP, o siempre podrá preguntar a uno de los proveedores oficiales de Chamilo para asistirle (pregunte por un contrato comercial garantizado). +

    + +
    +

    12. Configuración de tareas programadas

    +

    +Desde Chamilo 1.8.8, algunas tareas necesitan ejecutarse con regularidad con el fin de obtener lo mejor de los recursos del servidor. Una de las tareas de este tipo (y el único en todo en el momento de Chamilo 1.8.8) es el envío de notificaciones de mensajería interna por e-mail, es decir, cuando usted recibe un correo electrónico de otra persona o de un grupo dentro de la mensajería interna del sistema de Chamilo, si se envían todos los e-mails inmediatamente, puede que no llegue a recibir el correo a su ritmo, una vez al día o una vez a la semana. Para casos como este, como administrador de Chamilo, debe configurar un proceso cron en el servidor para comprobar la cola de mensajes de correo electrónico y enviarlo puntualmente. +

    +

    +Configurar una tarea de cron es fácil y hay varias maneras de hacerlo. Le recomendamos echar un vistazo a la documentación de Drupal para configurar el cron y definir su propio proceso de cron como: +

    +35 * * * * wget -O - -q -t 1 http://campus.example.com/main/cron/run.php
    +
    +

    +

    +Asegúrese de revisar el run.php tal vez desee cambiar algunas algunas opciones de configuración. +

    + +
    +

    13. Cambiando el orden del nombre/apellido en el idioma

    +

    +Como Chamilo se hace más popular y atraviesa muchas fronteras ahora, es frecuente que los administradores quieran pedir cambiar el orden del nombre y apellido en los campos de las tablas, y también en qué campo se pondrá en primer lugar. +

    +

    +Esto fácilmente se puede modificar editando el archivo main/inc/lib/internationalization_database/name_order_conventions.php, buscando nuestro idioma y cambiando los campos. Es tan simple que se explica por sí mismo y se ve así: +

    +'simpl_chinese' => array( 'format' => 'title last_name first_name', 'sort_by' => 'last_name' ), // Eastern order
    +
    +Siéntase libre de cambiar esto a +
    +'simpl_chinese' => array( 'format' => 'title first_name lastname', 'sort_by' => 'last_name' ), // Eastern order
    +
    +por ejemplo. El efecto debería ser inmediato. +



    From 2de2e547386bc254624c2d99071dc97535e5eb9a Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Mar 2013 19:00:04 -0500 Subject: [PATCH 17/38] Minor - Partially updated Chamilo logo - refs #6060 --- .../template_thumb/coursetitle.gif | Bin 392 -> 710 bytes .../images/logo_chamilo.png | Bin 0 -> 2986 bytes .../images/logo_dokeos.png | Bin 5136 -> 2986 bytes main/install/db_main.sql | 4 ++-- main/install/update-db-1.8.5-1.8.6.inc.php | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 main/default_course_document/images/logo_chamilo.png mode change 100755 => 100644 main/default_course_document/images/logo_dokeos.png diff --git a/home/default_platform_document/template_thumb/coursetitle.gif b/home/default_platform_document/template_thumb/coursetitle.gif index fed4d9ec00645098f829903fc1492ad4374824a4..986dd9df70bc822b041f39a0e8d2fc62b243c50a 100644 GIT binary patch literal 710 zcmZ?wbhEHbOkr?iSZc)Z&d&Osi>prA;*TLAPK|5+rZEI`Z~l~%`@2FhVfyZZ`3L^= zyVR{b_Gfnd+VyKb&71RQW%0tpHy7PeUUbLc_m2LJ54?6f4Ec2Q#DS}icRWdZcc06g9d?!Wwg%08EVuS7Z_tD?$8cQ0QT60_4 zI zH_kMWmXhAJWvixUxUSUxgHBt+L|9ps!}gxsaA=Jd$9e8>V8EO{BXFKoAZ(xPDZVpd z+>hl9HDonj)~L9v{4o5XV#xRBSB#WR_4Y$8q5|b*wHw)&&flf0uh0{5(4oPVjfdw9 z)AV(n&f5BRDFTH`;XR@(I;(tECiETB|JQP(xZ{YTy|}Q7$Bcl7&To2Hw3?$_emq+$ zKS#L8>w$pdiU4NquBgSE*T1sU4&C^#yU>ZHokz@%A$I4bhNcyz%g+5gem?8=8iuWV z7!*yMnpoHz7EC?0F)q5{=Z&nhhZec?bg}tJ9GIZc#w5TNyXtMoqk{|#iX0|pjfwBK zx37$dVG~%;!nnIK)c4$xM-C0lIx^ZDIvh*mgBA5+0(}%V=3aQsRkdup-j!F6j!YCc zS{1|d`B_z;^YqU(RnuQxQ};Z7j?KDU=idJKUApu1KYV(2G2dqWzTe-zT|9Z%UO2Ai l@B8mNpP%1%zv})?#Gn9}NpYRwLz+O7xdm4d_0FB#aKBCsI%NEjdh2olQK3d_3WccV%H zVE8dx>PQGXm3vds8}K`u$lAGr8uDtOn#_<)%mFM|8tiG@#=N=t3=KZh+^L?u!Ob}? zYI=GuLu{+4_=xE4E?I8wE66Z?1NF6%h0ou=CjtL7tF@4!vP12JJ;c?J;;?jCIp{g0 z6RS(DE4iZdS`vfUv1H4dJ&RUC0RTIALB44K diff --git a/main/default_course_document/images/logo_chamilo.png b/main/default_course_document/images/logo_chamilo.png new file mode 100644 index 0000000000000000000000000000000000000000..b2404dc6b2722124f93f5c4029884ec4a2300735 GIT binary patch literal 2986 zcmV;b3sv-qP)000McNliru-2)yMG#yk|)%E}Y3pYtb zK~#9!?VNjXl+_i$f9HOi@Cc6tgi%E0mCC~e7#IbWrxe99Ez=5$WI?Myec+QIGK#CM zgAhCWiA>X$~|g|91rVOoS&=&iiq>2==rB zR1RkY(68Qim8Z_=^y4kD{tm{=fDW9|Vp1e<07SU?z?aSYpH_gxO7Ex|SS~rO0AbLm zToP$~S^-j}Fv?$3bXoy2ME8TEeLoWM#cZ^1WPloOSGX7`2G*D&X2?p8oq*b+IKLl% zKsp-7rtqkRDIsCQSwJ^8h5kB)p|XI|2D_L<^}e@UO#LKjD_#X|3l~!fTx?63bpmrx zR6p2SE%Xc^{S$3%Q`W08vYuD(D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zjjHC3f_dXMdj*gIXr7puf$FFe&~s2!rvq$WG$|Mw{Z@zrKU7-I;Z9=|odquF zu`AQ3W+!tl0yedkO%UzG9L0Qpjb+ez=}ktr1Ul5ipW~%i}_jpj7V~=pWVgcA=?6D zj^$@%T&d`-;eyBNB@j2M@%3JU6L$-$Voi6hXk`*gM+l5Wxv(OcRpC>k@=RXRo;Bf4 g%l{(3$f+&=2VZwF3M`xwMgRZ+07*qoM6N<$f}EtGNB{r; literal 0 HcmV?d00001 diff --git a/main/default_course_document/images/logo_dokeos.png b/main/default_course_document/images/logo_dokeos.png old mode 100755 new mode 100644 index b5a87206dc29c873288121e7bf53ebd12c5ddc1c..b2404dc6b2722124f93f5c4029884ec4a2300735 GIT binary patch delta 2958 zcmV;93vu+2D5@8bB#|*0e*=U700V>p0|mL^00007bV*G`2i*f67c?DISJn0a01G!s zL_t(|+U=ZsaFo>*z<=j{oA3ya1cXsU<(10A1Q-|vm8TTNGA+{ziey2nKz-noATo-p zt%DFyDZW6(5`r>NtAazZRt17D6d{SoQ+$BdT1kQsBxJvP`Ugp7f0JyI-LNYkgJ*_6 zvfp>l-TmEj?mg$+dx2l1P7$wvLH(G7!qzQrK^Z27^HpgMG%5dg1o%vZCsNM)ak&Wg zv;tHPX9Li$-glL!&gk^xEwTO%#>;>XoY7)ZBya#kxcR`B&HJBLfW%7gs2W%1vzPDUV{Um8CUIlIo7gGsbY)hGS z0&`GQKiFC=^b8>V6K!o%)~hnIo>%WEo6N5p)Q2xRK#i?>f5U?GIvTr{RVaNT31^J5 zL~o&WwEZMRIj1x`c(~XTfNTN*fs3MOa+a3yT+{<$C32S$4ohFkPC6h3LAb5~?M4MB zGBKJq$sLLhLWBuu946=n0TNK4WrI=&;W3@aucCNgfrAkafj0n^L)y^5{*qi_nNA`h z*0GIZJOoIYe-in~)_~jB3J*rnpfJK8;vqoKvdh3o;HQSg2;8F+85GO8MZE+FKo+r4 zl|Mj(Rt{r@Y`u=;n57S@-U0;RdzOEyGCty!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X4YqaXs_6_S%6we9sz7=m(UAbBU{nr>$_;yDwGm%bFr$^~F9hm>vJ%DP zg?2vH$&?2uw^^+%!jOG{JM1hmnJK`nUlzXsv7 z7=?`F!AU-U)hN-~5vDRSoG#UG*!0hiQjMXt9+p>o_1dhtT)!TGl5Nd<;CsC9WICj& z6D;i~^b8`WWh9U54-)Aq`8{c9YNh<1#P>-9k>0y4jO!A;Z{-yQ^+o`cJp7c8XRh@b z#}?VI8YIr;suEgmFl^^9VyVz>65r;ME8fb4-i&uvt&gxD z^(5H&u2@2#O9;qtE=l@?zMAVYq%+G3Nte_`w|sQk@?F~MWZuk|dRJ+`Kyo}49$fZ6 zgqTo&A>)O1nyuY{-k*`p?B%&{cHVV>ti5_wei;BtbJLSv{gQ0u93n_5j~fUQ6`Q7e zZ=>6S3aO5`Q2XcU)Z#>*C%2kyl7P2nTk{~z`lMW03Aj=&@qdyxf8q>MO{aHthLj{E z9;Yl_)M5RS@6D}p&qk*QZ{6lRH|0RA6byE4vXDs64(}kgI#xVu^3Bv<_5Mz)!{WVB zo4l0(C0m3AyMF)~2%+6nHR7#UV!ayvxRP=LTN&p1O - dokeos logo + Chamilo logo @@ -3024,4 +3024,4 @@ CREATE TABLE usergroup_rel_question ( question_id int unsigned not null, usergroup_id int unsigned not null, coefficient float(6,2) -); \ No newline at end of file +); 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 e027156c7a..bdb88ba682 100644 --- 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 @@ -201,7 +201,7 @@ if (defined('SYSTEM_INSTALLATION')) { - Chamilo logo + Chamilo logo From 3287dd96676178807aa4d0c92e30b951913d398d Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Mar 2013 20:36:26 -0500 Subject: [PATCH 18/38] Minor - Code conventions - refs BT#6003 --- .../gradebook/lib/fe/gradebooktable.class.php | 456 +++++++++--------- 1 file changed, 228 insertions(+), 228 deletions(-) diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index 563c384c8d..b9ce2c7166 100644 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -101,57 +101,57 @@ class GradebookTable extends SortableTable { return $this->datagen->get_total_items_count(); } - /** - * Function used by SortableTable to generate the data to display - */ - function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { - + /** + * Function used by SortableTable to generate the data to display + */ + function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { + //variables load in index.php global $my_score_in_gradebook, $certificate_min_score; $scoretotal = 0; - // determine sorting type - $col_adjust = (api_is_allowed_to_edit() ? 1 : 0); + // determine sorting type + $col_adjust = (api_is_allowed_to_edit() ? 1 : 0); // By id $this->column = 5; - switch ($this->column) { - // Type - case (0 + $col_adjust) : - $sorting = GradebookDataGenerator :: GDG_SORT_TYPE; - break; - case (1 + $col_adjust) : - $sorting = GradebookDataGenerator :: GDG_SORT_NAME; - break; - case (2 + $col_adjust) : - $sorting = GradebookDataGenerator :: GDG_SORT_DESCRIPTION; - break; - case (3 + $col_adjust) : - $sorting = GradebookDataGenerator :: GDG_SORT_WEIGHT; - break; - case (4 + $col_adjust) : - $sorting = GradebookDataGenerator :: GDG_SORT_DATE; + switch ($this->column) { + // Type + case (0 + $col_adjust) : + $sorting = GradebookDataGenerator :: GDG_SORT_TYPE; + break; + case (1 + $col_adjust) : + $sorting = GradebookDataGenerator :: GDG_SORT_NAME; + break; + case (2 + $col_adjust) : + $sorting = GradebookDataGenerator :: GDG_SORT_DESCRIPTION; + break; + case (3 + $col_adjust) : + $sorting = GradebookDataGenerator :: GDG_SORT_WEIGHT; + break; + case (4 + $col_adjust) : + $sorting = GradebookDataGenerator :: GDG_SORT_DATE; case (5 + $col_adjust) : $sorting = GradebookDataGenerator :: GDG_SORT_ID; - break; - } - - if ($this->direction == 'DESC') { - $sorting |= GradebookDataGenerator :: GDG_SORT_DESC; - } else { - $sorting |= GradebookDataGenerator :: GDG_SORT_ASC; - } - - //status of user in course - $user_id = api_get_user_id(); - $course_code = api_get_course_id(); + break; + } + + if ($this->direction == 'DESC') { + $sorting |= GradebookDataGenerator :: GDG_SORT_DESC; + } else { + $sorting |= GradebookDataGenerator :: GDG_SORT_ASC; + } + + //status of user in course + $user_id = api_get_user_id(); + $course_code = api_get_course_id(); $session_id = api_get_session_id(); - $status_user = api_get_status_of_user_in_course($user_id, $course_code); + $status_user = api_get_status_of_user_in_course($user_id, $course_code); - $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); + $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); - // generate the data to display - $sortable_data = array(); - $weight_total_links = 0; + // generate the data to display + $sortable_data = array(); + $weight_total_links = 0; $main_categories = array(); $main_cat = Category :: load(null, null, $course_code, null, null, $session_id, false); @@ -161,83 +161,83 @@ class GradebookTable extends SortableTable { //Categories - foreach ($data_array as $data) { - + foreach ($data_array as $data) { + // list of items inside the gradebook (exercises, lps, forums, etc) - $row = array(); - $item = $item_category = $data[0]; - - $id = $item->get_id(); - - //if the item is invisible, wrap it in a span with class invisible - $invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '' : ''; + $row = array(); + $item = $item_category = $data[0]; + + $id = $item->get_id(); + + //if the item is invisible, wrap it in a span with class invisible + $invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '' : ''; - if (api_is_allowed_to_edit(null, true)) { + if (api_is_allowed_to_edit(null, true)) { //id - $row[] = $this->build_id_column($item); - } + $row[] = $this->build_id_column($item); + } //Type - $row[] = $this->build_type_column($item); - - //Name - if (get_class($item) == 'Category') { - $row[] = $invisibility_span_open.'

    '.$item->get_name().'

    '.$invisibility_span_close; + $row[] = $this->build_type_column($item); + + //Name + if (get_class($item) == 'Category') { + $row[] = $invisibility_span_open.'

    '.$item->get_name().'

    '.$invisibility_span_close; $main_categories[$item->get_id()]['name'] = $item->get_name(); - } else { - $row[] = $invisibility_span_open.$this->build_name_link($item) . $invisibility_span_close; + } else { + $row[] = $invisibility_span_open.$this->build_name_link($item) . $invisibility_span_close; $main_categories[$item->get_id()]['name'] = $this->build_name_link($item); - } + } $main_categories[$item->get_id()]['weight']= $item->get_weight(); $total_categories_weight += $item->get_weight(); - //Description - $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; - - //Weight - //$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close; + //Description + $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; + + //Weight + //$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close; //$average = $data['3']/$this->currentcat->get_weight()*100; $average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_SIMPLE, SCORE_BOTH, true); if (api_is_allowed_to_edit(null, true)) { - $row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close; + $row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close; } else { - $row[] = $invisibility_span_open .$average.$invisibility_span_close; + $row[] = $invisibility_span_open .$average.$invisibility_span_close; } $category_weight = $item->get_weight(); - - if (api_is_allowed_to_edit(null, true)) { - $weight_total_links += $data[3]; - } else { - $cattotal = Category :: load($_GET['selectcat']); + + if (api_is_allowed_to_edit(null, true)) { + $weight_total_links += $data[3]; + } else { + $cattotal = Category :: load($_GET['selectcat']); $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); - } - - //Date - //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; + } + + //Date + //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; - //Edit (for admins) - if (api_is_allowed_to_edit(null, true)) { - $cat = new Category(); - $show_message = $cat->show_message_resource_delete($item->get_course_code()); - if ($show_message === false) { - $row[] = $this->build_edit_column($item); - } - } else { - //students get the results and certificates columns - if (count($this->evals_links) > 0 && $status_user != 1) { - $value_data = isset($data[4]) ? $data[4] : null; - if (!is_null($value_data)) { - $row[] = Display::tag('h4', $value_data); - } else { + //Edit (for admins) + if (api_is_allowed_to_edit(null, true)) { + $cat = new Category(); + $show_message = $cat->show_message_resource_delete($item->get_course_code()); + if ($show_message === false) { + $row[] = $this->build_edit_column($item); + } + } else { + //students get the results and certificates columns + if (count($this->evals_links) > 0 && $status_user != 1) { + $value_data = isset($data[4]) ? $data[4] : null; + if (!is_null($value_data)) { + $row[] = Display::tag('h4', $value_data); + } else { $row[] = $this->build_edit_column($item); } - } else { + } else { $score = $item->calc_score(api_get_user_id()); if (!empty($score[1])) { $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); @@ -252,58 +252,58 @@ class GradebookTable extends SortableTable { $row[] = $this->build_edit_column($item); } } - } + } //Category added - $sortable_data[] = $row; - - // Loading childrens - - if (get_class($item) == 'Category') { - - $stud_id = api_get_user_id(); - $course_code = api_get_course_id(); - $session_id = api_get_session_id(); - $parent_id = $item->get_id(); + $sortable_data[] = $row; + + // Loading childrens + + if (get_class($item) == 'Category') { - $cats = Category :: load ($parent_id, null, null, null, null, null); - - $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id); - $alleval = $cats[0]->get_evaluations($stud_id); - $alllink = $cats[0]->get_links($stud_id); - - $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); - $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page); + $stud_id = api_get_user_id(); + $course_code = api_get_course_id(); + $session_id = api_get_session_id(); + $parent_id = $item->get_id(); + + $cats = Category :: load ($parent_id, null, null, null, null, null); + + $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id); + $alleval = $cats[0]->get_evaluations($stud_id); + $alllink = $cats[0]->get_links($stud_id); - $total_weight = 0; + $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); + $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page); + + $total_weight = 0; //Links - foreach ($data_array as $data) { - $row = array(); - $item = $data[0]; - $id = $item->get_id(); - - //if the item is invisible, wrap it in a span with class invisible - $invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '' : ''; + foreach ($data_array as $data) { + $row = array(); + $item = $data[0]; + $id = $item->get_id(); + + //if the item is invisible, wrap it in a span with class invisible + $invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '' : ''; $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name(); $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight(); - if (api_is_allowed_to_edit(null, true)) { - $row[] = $this->build_id_column($item); - } + if (api_is_allowed_to_edit(null, true)) { + $row[] = $this->build_id_column($item); + } + + $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); + + //Name + $row[] = $invisibility_span_open."    ".$this->build_name_link($item) . $invisibility_span_close; - $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); - - //Name - $row[] = $invisibility_span_open."    ".$this->build_name_link($item) . $invisibility_span_close; - - //Description - $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; - - //Weight + //Description + $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; + + //Weight //$weight = $data[3]/$category_weight*$main_cat[0]->get_weight(); /*$weight = $category_weight * $data[3] / $main_cat[0]->get_weight(); $weight = $main_cat[0]->get_weight()*$weight/$category_weight;*/ @@ -315,45 +315,45 @@ class GradebookTable extends SortableTable { $total_weight += $weight; $row[] = $invisibility_span_open.$weight.$extra.$invisibility_span_close; - - if (api_is_allowed_to_edit(null, true)) { - //$weight_total_links += intval($data[3]); - } else { - $cattotal = Category :: load($_GET['selectcat']); - $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); - $item_value = $scoretotal[0]; - } - - //Date - //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; - - //Admins get an edit column - if (api_is_allowed_to_edit(null, true)) { - $cat = new Category(); - $show_message = $cat->show_message_resource_delete($item->get_course_code()); - if ($show_message === false) { - $row[] = $this->build_edit_column($item); - } - } else { - //students get the results and certificates columns - $eval_n_links = array_merge($alleval, $alllink); - - if (count($eval_n_links)> 0 && $status_user!=1 ) { - $value_data = isset($data[4]) ? $data[4] : null; - if (!is_null($value_data)) { + + if (api_is_allowed_to_edit(null, true)) { + //$weight_total_links += intval($data[3]); + } else { + $cattotal = Category :: load($_GET['selectcat']); + $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); + $item_value = $scoretotal[0]; + } + + //Date + //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; + + //Admins get an edit column + if (api_is_allowed_to_edit(null, true)) { + $cat = new Category(); + $show_message = $cat->show_message_resource_delete($item->get_course_code()); + if ($show_message === false) { + $row[] = $this->build_edit_column($item); + } + } else { + //students get the results and certificates columns + $eval_n_links = array_merge($alleval, $alllink); + + if (count($eval_n_links)> 0 && $status_user!=1 ) { + $value_data = isset($data[4]) ? $data[4] : null; + if (!is_null($value_data)) { $score = $item->calc_score(api_get_user_id()); $new_score = $data[3]* $score[0] / $score[1]; $row[] = Display::tip($new_score, $data[4]); - } - } + } + } if (!empty($cats)) { $row[] = null; } - } + } $row['child_of'] = $parent_id; - $sortable_data[] = $row; - } + $sortable_data[] = $row; + } //"Warning row" if (!empty($data_array)) { @@ -369,9 +369,9 @@ class GradebookTable extends SortableTable { $row = array(null, null, "     
    ".get_lang('SubTotal').'
    ',null, $total.' '.$label, 'child_of' =>$parent_id); $sortable_data[] = $row; } - } - } - } //end looping categories + } + } + } //end looping categories if (api_is_allowed_to_edit()) { if (count($main_cat) > 1) { @@ -386,86 +386,86 @@ class GradebookTable extends SortableTable { } } - // warning messages + // warning messages $view = isset($_GET['view']) ? $_GET['view']: null; - if (api_is_allowed_to_edit()) { - - if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view <> 'presence') { - $id_cat = intval($_GET['selectcat']); - $category = Category :: load($id_cat); - //$weight_category = intval($this->build_weight($category[0])); - $weight_category = intval($this->build_weight($category[0])); - $course_code = $this->build_course_code($category[0]); + if (api_is_allowed_to_edit()) { + + if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view <> 'presence') { + $id_cat = intval($_GET['selectcat']); + $category = Category :: load($id_cat); + //$weight_category = intval($this->build_weight($category[0])); + $weight_category = intval($this->build_weight($category[0])); + $course_code = $this->build_course_code($category[0]); $weight_total_links = round($weight_total_links); - if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) { - $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); - $modify_icons = ''.Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).''; - $warning_message .= $modify_icons; - Display::display_warning_message($warning_message,false); - } + if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) { + $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); + $modify_icons = ''.Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).''; + $warning_message .= $modify_icons; + Display::display_warning_message($warning_message,false); + } - $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code); - if (!empty($content_html)) { - $new_content = explode('',$content_html['content']); + $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code); + if (!empty($content_html)) { + $new_content = explode('',$content_html['content']); } - if (empty($new_content[0])) { - $warning_message = get_lang('ThereIsNotACertificateAvailableByDefault'); - $cert_icon = ''.Display::return_icon('certificate.png', get_lang('AttachCertificate'), array(), ICON_SIZE_SMALL).''; + if (empty($new_content[0])) { + $warning_message = get_lang('ThereIsNotACertificateAvailableByDefault'); + $cert_icon = ''.Display::return_icon('certificate.png', get_lang('AttachCertificate'), array(), ICON_SIZE_SMALL).''; - Display::display_warning_message($warning_message.$cert_icon,false); - } - } + Display::display_warning_message($warning_message.$cert_icon,false); + } + } - if (empty($_GET['selectcat'])) { - $categories = Category :: load(); - $weight_categories = $certificate_min_scores = $course_codes = array(); - foreach ($categories as $category) { - $course_code_category = $this->build_course_code($category); - if (!empty($course_code)) { - if ($course_code_category == $course_code) { - $weight_categories[] = intval($this->build_weight($category)); - $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); - $course_codes[] = $course_code; - break; - } - } else { - $weight_categories[] = intval($this->build_weight($category)); - $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); - $course_codes[] = $course_code_category; - } - } + if (empty($_GET['selectcat'])) { + $categories = Category :: load(); + $weight_categories = $certificate_min_scores = $course_codes = array(); + foreach ($categories as $category) { + $course_code_category = $this->build_course_code($category); + if (!empty($course_code)) { + if ($course_code_category == $course_code) { + $weight_categories[] = intval($this->build_weight($category)); + $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); + $course_codes[] = $course_code; + break; + } + } else { + $weight_categories[] = intval($this->build_weight($category)); + $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); + $course_codes[] = $course_code_category; + } + } - if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) { - $warning_message = ''; - for ($x = 0; $x $weight_category)) { - $warning_message .= $course_code .' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'
    '; - } - } + if (empty($certificate_min_score) || ($certificate_min_score > $weight_category)) { + $warning_message .= $course_code .' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'
    '; + } + } - if (!empty($warning_message)) { - Display::display_warning_message($warning_message,false); - } - } - } - } - return $sortable_data; - } + if (!empty($warning_message)) { + Display::display_warning_message($warning_message,false); + } + } + } + } + return $sortable_data; + } // Other functions private function build_certificate_min_score ($item) { - return $item->get_certificate_min_score(); + return $item->get_certificate_min_score(); } private function build_weight ($item) { - return $item->get_weight(); + return $item->get_weight(); } private function build_course_code ($item) { From d92d55f13037c6e97197e3bcc5b1f18fa893b3f7 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Mar 2013 20:44:34 -0500 Subject: [PATCH 19/38] Added lines to 1.9.6 changelog - refs #6060 --- documentation/changelog.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/changelog.html b/documentation/changelog.html index 9d591bf00a..ffcde9592b 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -55,6 +55,8 @@
  • New "Impress" visualization for learning paths (#4595)
  • Show weight of current teacher's documents in session (#5298)
  • Show user data in admin tracking (#5723)
  • +
  • User import through CSV now accepts language (#5746)
  • +
  • Written assignments can be downloaded by teacher (#5805)
  • Improvements

      From 0f4cd082b7fe219655357261279fe1491d18e427 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Mar 2013 20:55:17 -0500 Subject: [PATCH 20/38] Fixed issue in gradebook categories not showing the right sub-total weight for comparisons - refs BT#6003 --- main/gradebook/lib/fe/gradebooktable.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index b9ce2c7166..2efcbf053f 100644 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -358,13 +358,13 @@ class GradebookTable extends SortableTable { //"Warning row" if (!empty($data_array)) { if (api_is_allowed_to_edit()) { - $main_weight = intval($main_cat[0]->get_weight()); - if (intval($total_weight) == $main_weight) { + // Compare the category weight to the sum of all weights inside the category + if (intval($total_weight) == $category_weight) { $label = null; - $total = score_badges(array($total_weight.' / '.$main_weight, '100')); + $total = score_badges(array($total_weight.' / '.$category_weight, '100')); } else { - $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $main_weight) ); - $total = Display::badge($total_weight.' / '.$main_weight, 'warning'); + $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight) ); + $total = Display::badge($total_weight.' / '.$category_weight, 'warning'); } $row = array(null, null, "     
      ".get_lang('SubTotal').'
      ',null, $total.' '.$label, 'child_of' =>$parent_id); $sortable_data[] = $row; From 88a25aa9778bcee4653f6804d8a968c370221207 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Mar 2013 20:58:22 -0500 Subject: [PATCH 21/38] Minor - Code conventions spacing --- .../gradebook/lib/fe/gradebooktable.class.php | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/main/gradebook/lib/fe/gradebooktable.class.php b/main/gradebook/lib/fe/gradebooktable.class.php index 2efcbf053f..268dd0cb3b 100644 --- a/main/gradebook/lib/fe/gradebooktable.class.php +++ b/main/gradebook/lib/fe/gradebooktable.class.php @@ -323,26 +323,26 @@ class GradebookTable extends SortableTable { $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $item_value = $scoretotal[0]; } - + //Date //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; - + //Admins get an edit column if (api_is_allowed_to_edit(null, true)) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); if ($show_message === false) { - $row[] = $this->build_edit_column($item); + $row[] = $this->build_edit_column($item); } } else { //students get the results and certificates columns $eval_n_links = array_merge($alleval, $alllink); - + if (count($eval_n_links)> 0 && $status_user!=1 ) { - $value_data = isset($data[4]) ? $data[4] : null; - if (!is_null($value_data)) { - $score = $item->calc_score(api_get_user_id()); - $new_score = $data[3]* $score[0] / $score[1]; + $value_data = isset($data[4]) ? $data[4] : null; + if (!is_null($value_data)) { + $score = $item->calc_score(api_get_user_id()); + $new_score = $data[3]* $score[0] / $score[1]; $row[] = Display::tip($new_score, $data[4]); } } @@ -351,35 +351,35 @@ class GradebookTable extends SortableTable { } } $row['child_of'] = $parent_id; - + $sortable_data[] = $row; } - + //"Warning row" if (!empty($data_array)) { if (api_is_allowed_to_edit()) { // Compare the category weight to the sum of all weights inside the category - if (intval($total_weight) == $category_weight) { + if (intval($total_weight) == $category_weight) { $label = null; $total = score_badges(array($total_weight.' / '.$category_weight, '100')); - } else { - $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight) ); - $total = Display::badge($total_weight.' / '.$category_weight, 'warning'); + } else { + $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight) ); + $total = Display::badge($total_weight.' / '.$category_weight, 'warning'); } $row = array(null, null, "     
      ".get_lang('SubTotal').'
      ',null, $total.' '.$label, 'child_of' =>$parent_id); $sortable_data[] = $row; } - } - } + } + } } //end looping categories - - if (api_is_allowed_to_edit()) { + + if (api_is_allowed_to_edit()) { if (count($main_cat) > 1) { - $main_weight = intval($main_cat[0]->get_weight()); - if (intval($total_categories_weight) == $main_weight) { + $main_weight = intval($main_cat[0]->get_weight()); + if (intval($total_categories_weight) == $main_weight) { $total = score_badges(array($total_categories_weight.' / '.$main_weight, '100')); - } else { - $total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning'); + } else { + $total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning'); } $row = array(null, null, '

      '.get_lang('Total').'

      ', null, $total); $sortable_data[] = $row; @@ -387,9 +387,9 @@ class GradebookTable extends SortableTable { } // warning messages - $view = isset($_GET['view']) ? $_GET['view']: null; + $view = isset($_GET['view']) ? $_GET['view']: null; if (api_is_allowed_to_edit()) { - + if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view <> 'presence') { $id_cat = intval($_GET['selectcat']); $category = Category :: load($id_cat); From 7eeb6ccbb4c82ac368f9ec35c2432add0c30f6ff Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Mar 2013 21:01:38 -0500 Subject: [PATCH 22/38] Minor - Code conventions spacing --- main/gradebook/lib/fe/evalform.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main/gradebook/lib/fe/evalform.class.php b/main/gradebook/lib/fe/evalform.class.php index f27a72ce26..1103e54f43 100644 --- a/main/gradebook/lib/fe/evalform.class.php +++ b/main/gradebook/lib/fe/evalform.class.php @@ -468,17 +468,17 @@ class EvalForm extends FormValidator } } - $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array ( - 'size' => '4', - 'maxlength' => '5', + $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array ( + 'size' => '4', + 'maxlength' => '5', 'class' => 'span1' - )); + )); /*$this->add_textfield('weight', array(null, null, '/ '.$default_weight.''), true, array ( - 'size' => '4', - 'maxlength' => '5', + 'size' => '4', + 'maxlength' => '5', 'class' => 'span1' - ));*/ + ));*/ if ($edit) { From 9298186f13afdc558980fd725d77f822e1ac23a1 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sun, 31 Mar 2013 09:57:05 -0500 Subject: [PATCH 23/38] Minor - Coding conventions spacing --- main/inc/lib/sortable_table.class.php | 1740 ++++++++++++------------- 1 file changed, 870 insertions(+), 870 deletions(-) diff --git a/main/inc/lib/sortable_table.class.php b/main/inc/lib/sortable_table.class.php index 72c132dbbf..8c7da2f8a2 100644 --- a/main/inc/lib/sortable_table.class.php +++ b/main/inc/lib/sortable_table.class.php @@ -22,76 +22,76 @@ require_once 'pear/Pager/Pager.php'; * @package chamilo.library */ class SortableTable extends HTML_Table { - /** - * A name for this table - */ - public $table_name; - /** - * The page to display - */ - public $page_nr; - /** - * The column to sort the data - */ - public $column; - /** - * The sorting direction (ASC or DESC) - */ - public $direction; - /** - * Number of items to display per page - */ - public $per_page; - /** - * The default number of items to display per page - */ - public $default_items_per_page; - /** - * A prefix for the URL-parameters, can be used on pages with multiple - * SortableTables - */ - public $param_prefix; - /** - * The pager object to split the data in several pages - */ - public $pager; - /** - * The total number of items in the table - */ - public $total_number_of_items; - /** - * The function to get the total number of items - */ - public $get_total_number_function; - /** - * The function to the the data to display - */ - public $get_data_function; - /** - * An array with defined column-filters - */ - public $column_filters; - /** - * A list of actions which will be available through a select list - */ - public $form_actions; - /** - * Additional parameters to pass in the URL - */ - public $additional_parameters; - /** - * Additional attributes for the th-tags - */ - public $th_attributes; - /** - * Additional attributes for the td-tags - */ - public $td_attributes; - /** - * Array with names of the other tables defined on the same page of this - * table - */ - public $other_tables; + /** + * A name for this table + */ + public $table_name; + /** + * The page to display + */ + public $page_nr; + /** + * The column to sort the data + */ + public $column; + /** + * The sorting direction (ASC or DESC) + */ + public $direction; + /** + * Number of items to display per page + */ + public $per_page; + /** + * The default number of items to display per page + */ + public $default_items_per_page; + /** + * A prefix for the URL-parameters, can be used on pages with multiple + * SortableTables + */ + public $param_prefix; + /** + * The pager object to split the data in several pages + */ + public $pager; + /** + * The total number of items in the table + */ + public $total_number_of_items; + /** + * The function to get the total number of items + */ + public $get_total_number_function; + /** + * The function to the the data to display + */ + public $get_data_function; + /** + * An array with defined column-filters + */ + public $column_filters; + /** + * A list of actions which will be available through a select list + */ + public $form_actions; + /** + * Additional parameters to pass in the URL + */ + public $additional_parameters; + /** + * Additional attributes for the th-tags + */ + public $th_attributes; + /** + * Additional attributes for the td-tags + */ + public $td_attributes; + /** + * Array with names of the other tables defined on the same page of this + * table + */ + public $other_tables; /** * Activates the odd even rows * **/ @@ -100,35 +100,35 @@ class SortableTable extends HTML_Table { public $table_id = null; public $headers = array(); - /** - * Create a new SortableTable - * @param string $table_name A name for the table (default = 'table') - * @param string $get_total_number_function A user defined function to get - * the total number of items in the table - * @param string $get_data_function A function to get the data to display on - * the current page - * @param int $default_column The default column on which the data should be - * sorted - * @param int $default_items_per_page The default number of items to show - * on one page - * @param string $default_order_direction The default order direction; - * either the constant 'ASC' or 'DESC' - */ - public function __construct($table_name = 'table', $get_total_number_function = null, $get_data_function = null, $default_column = 1, $default_items_per_page = 20, $default_order_direction = 'ASC', $table_id = null) { + /** + * Create a new SortableTable + * @param string $table_name A name for the table (default = 'table') + * @param string $get_total_number_function A user defined function to get + * the total number of items in the table + * @param string $get_data_function A function to get the data to display on + * the current page + * @param int $default_column The default column on which the data should be + * sorted + * @param int $default_items_per_page The default number of items to show + * on one page + * @param string $default_order_direction The default order direction; + * either the constant 'ASC' or 'DESC' + */ + public function __construct($table_name = 'table', $get_total_number_function = null, $get_data_function = null, $default_column = 1, $default_items_per_page = 20, $default_order_direction = 'ASC', $table_id = null) { if (empty($table_id)) { $table_id = $table_name.uniqid(); } $this->table_id = $table_id; - parent :: __construct (array ('class' => 'data_table', 'id' => $table_id)); - $this->table_name = $table_name; - $this->additional_parameters = array (); - $this->param_prefix = $table_name.'_'; + parent :: __construct (array ('class' => 'data_table', 'id' => $table_id)); + $this->table_name = $table_name; + $this->additional_parameters = array (); + $this->param_prefix = $table_name.'_'; - $this->page_nr = isset ($_SESSION[$this->param_prefix.'page_nr']) ? intval($_SESSION[$this->param_prefix.'page_nr']) : 1; - $this->page_nr = isset ($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr; - $this->column = isset ($_SESSION[$this->param_prefix.'column']) ? intval($_SESSION[$this->param_prefix.'column']) : $default_column; - $this->column = isset ($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column; + $this->page_nr = isset ($_SESSION[$this->param_prefix.'page_nr']) ? intval($_SESSION[$this->param_prefix.'page_nr']) : 1; + $this->page_nr = isset ($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr; + $this->column = isset ($_SESSION[$this->param_prefix.'column']) ? intval($_SESSION[$this->param_prefix.'column']) : $default_column; + $this->column = isset ($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column; //Default direction @@ -136,154 +136,154 @@ class SortableTable extends HTML_Table { $this->direction = $default_order_direction; } - if (isset($_SESSION[$this->param_prefix.'direction'])) { - $my_session_direction = $_SESSION[$this->param_prefix.'direction']; - if (!in_array($my_session_direction, array('ASC', 'DESC'))) { - $this->direction = 'ASC'; - } else { - if ($my_session_direction == 'ASC') { - $this->direction = 'ASC'; - } elseif ($my_session_direction == 'DESC') { - $this->direction = 'DESC'; - } - } - } - - if (isset($_GET[$this->param_prefix.'direction'])) { - $my_get_direction = $_GET[$this->param_prefix.'direction']; - if (!in_array($my_get_direction, array('ASC', 'DESC'))){ - $this->direction = 'ASC'; - } else { - if ($my_get_direction == 'ASC') { - $this->direction = 'ASC'; - } elseif ($my_get_direction == 'DESC') { - $this->direction = 'DESC'; - } - } - } - - - // Allow to change paginate in multiples tabs - unset($_SESSION[$this->param_prefix.'per_page']); - - $this->per_page = isset ($_SESSION[$this->param_prefix.'per_page']) ? intval($_SESSION[$this->param_prefix.'per_page']) : $default_items_per_page; - $this->per_page = isset ($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page; - - $_SESSION[$this->param_prefix.'per_page'] = $this->per_page; - $_SESSION[$this->param_prefix.'direction'] = $this->direction ; - $_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr; - $_SESSION[$this->param_prefix.'column'] = $this->column; - $this->pager = null; - $this->default_items_per_page = $default_items_per_page; - $this->total_number_of_items = -1; - $this->get_total_number_function = $get_total_number_function; - $this->get_data_function = $get_data_function; - $this->column_filters = array(); - $this->form_actions = array(); - $this->checkbox_name = null; - $this->td_attributes = array(); - $this->th_attributes = array(); - $this->other_tables = array(); - } - - /** - * Get the Pager object to split the showed data in several pages - */ - public function get_pager() { - if (is_null($this->pager)) { - $total_number_of_items = $this->get_total_number_of_items(); - $params['mode'] = 'Sliding'; - $params['perPage'] = $this->per_page; - $params['totalItems'] = $total_number_of_items; - $params['urlVar'] = $this->param_prefix.'page_nr'; - $params['currentPage'] = $this->page_nr; - $icon_attributes = array('style' => 'vertical-align: middle;'); - $params['prevImg'] = Display :: return_icon('action_prev.png', get_lang('PreviousPage'), $icon_attributes); - $params['nextImg'] = Display :: return_icon('action_next.png', get_lang('NextPage'), $icon_attributes); - $params['firstPageText'] = Display :: return_icon('action_first.png', get_lang('FirstPage'), $icon_attributes); - $params['lastPageText'] = Display :: return_icon('action_last.png', get_lang('LastPage'), $icon_attributes); - $params['firstPagePre'] = ''; - $params['lastPagePre'] = ''; - $params['firstPagePost'] = ''; - $params['lastPagePost'] = ''; - $params['spacesBeforeSeparator'] = ''; - $params['spacesAfterSeparator'] = ''; - $query_vars = array_keys($_GET); - $query_vars_needed = array ($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page'); - if (count($this->additional_parameters) > 0) { - $query_vars_needed = array_merge($query_vars_needed, array_keys($this->additional_parameters)); - } - $query_vars_exclude = array_diff($query_vars, $query_vars_needed); - $params['excludeVars'] = $query_vars_exclude; - $this->pager = & Pager::factory($params); - } - return $this->pager; - } - - public function display() { - echo $this->return_table(); - } - /** - * Displays the table, complete with navigation buttons to browse through - * the data-pages. - */ - public function return_table() { - $empty_table = false; - $content = $this->get_table_html(); - - if ($this->get_total_number_of_items() == 0) { - $cols = $this->getColCount(); - $this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols); - $message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty')); - $this->setCellContents(1, 0, $message_empty); - $empty_table = true; - } - $html = ''; - if (!$empty_table) { + if (isset($_SESSION[$this->param_prefix.'direction'])) { + $my_session_direction = $_SESSION[$this->param_prefix.'direction']; + if (!in_array($my_session_direction, array('ASC', 'DESC'))) { + $this->direction = 'ASC'; + } else { + if ($my_session_direction == 'ASC') { + $this->direction = 'ASC'; + } elseif ($my_session_direction == 'DESC') { + $this->direction = 'DESC'; + } + } + } + + if (isset($_GET[$this->param_prefix.'direction'])) { + $my_get_direction = $_GET[$this->param_prefix.'direction']; + if (!in_array($my_get_direction, array('ASC', 'DESC'))){ + $this->direction = 'ASC'; + } else { + if ($my_get_direction == 'ASC') { + $this->direction = 'ASC'; + } elseif ($my_get_direction == 'DESC') { + $this->direction = 'DESC'; + } + } + } + + + // Allow to change paginate in multiples tabs + unset($_SESSION[$this->param_prefix.'per_page']); + + $this->per_page = isset ($_SESSION[$this->param_prefix.'per_page']) ? intval($_SESSION[$this->param_prefix.'per_page']) : $default_items_per_page; + $this->per_page = isset ($_GET[$this->param_prefix.'per_page']) ? intval($_GET[$this->param_prefix.'per_page']) : $this->per_page; + + $_SESSION[$this->param_prefix.'per_page'] = $this->per_page; + $_SESSION[$this->param_prefix.'direction'] = $this->direction ; + $_SESSION[$this->param_prefix.'page_nr'] = $this->page_nr; + $_SESSION[$this->param_prefix.'column'] = $this->column; + $this->pager = null; + $this->default_items_per_page = $default_items_per_page; + $this->total_number_of_items = -1; + $this->get_total_number_function = $get_total_number_function; + $this->get_data_function = $get_data_function; + $this->column_filters = array(); + $this->form_actions = array(); + $this->checkbox_name = null; + $this->td_attributes = array(); + $this->th_attributes = array(); + $this->other_tables = array(); + } + + /** + * Get the Pager object to split the showed data in several pages + */ + public function get_pager() { + if (is_null($this->pager)) { + $total_number_of_items = $this->get_total_number_of_items(); + $params['mode'] = 'Sliding'; + $params['perPage'] = $this->per_page; + $params['totalItems'] = $total_number_of_items; + $params['urlVar'] = $this->param_prefix.'page_nr'; + $params['currentPage'] = $this->page_nr; + $icon_attributes = array('style' => 'vertical-align: middle;'); + $params['prevImg'] = Display :: return_icon('action_prev.png', get_lang('PreviousPage'), $icon_attributes); + $params['nextImg'] = Display :: return_icon('action_next.png', get_lang('NextPage'), $icon_attributes); + $params['firstPageText'] = Display :: return_icon('action_first.png', get_lang('FirstPage'), $icon_attributes); + $params['lastPageText'] = Display :: return_icon('action_last.png', get_lang('LastPage'), $icon_attributes); + $params['firstPagePre'] = ''; + $params['lastPagePre'] = ''; + $params['firstPagePost'] = ''; + $params['lastPagePost'] = ''; + $params['spacesBeforeSeparator'] = ''; + $params['spacesAfterSeparator'] = ''; + $query_vars = array_keys($_GET); + $query_vars_needed = array ($this->param_prefix.'column', $this->param_prefix.'direction', $this->param_prefix.'per_page'); + if (count($this->additional_parameters) > 0) { + $query_vars_needed = array_merge($query_vars_needed, array_keys($this->additional_parameters)); + } + $query_vars_exclude = array_diff($query_vars, $query_vars_needed); + $params['excludeVars'] = $query_vars_exclude; + $this->pager = & Pager::factory($params); + } + return $this->pager; + } + + public function display() { + echo $this->return_table(); + } + /** + * Displays the table, complete with navigation buttons to browse through + * the data-pages. + */ + public function return_table() { + $empty_table = false; + $content = $this->get_table_html(); + + if ($this->get_total_number_of_items() == 0) { + $cols = $this->getColCount(); + $this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols); + $message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty')); + $this->setCellContents(1, 0, $message_empty); + $empty_table = true; + } + $html = ''; + if (!$empty_table) { $table_id = 'form_'.$this->table_name.'_id'; - $form = $this->get_page_select_form(); - $nav = $this->get_navigation_html(); + $form = $this->get_page_select_form(); + $nav = $this->get_navigation_html(); - //Only show pagination info when there are items to paginate + //Only show pagination info when there are items to paginate if ($this->get_total_number_of_items() > $this->default_items_per_page) { - $html = ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= '
      '; - $html .= $form; - $html .= ''; - $html .= $this->get_table_title(); - $html .= ''; - $html .= $nav; - $html .= '
      '; + $html = ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= '
      '; + $html .= $form; + $html .= ''; + $html .= $this->get_table_title(); + $html .= ''; + $html .= $nav; + $html .= '
      '; } - if (count($this->form_actions) > 0) { - $params = $this->get_sortable_table_param_string().'&'.$this->get_additional_url_paramstring(); - $html .= '