From ebfd778ae34de89cb10392eeb62c9cc0f4177b62 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 25 Sep 2012 00:32:37 -0500 Subject: [PATCH 001/124] Fixing grey icon for audio_question in exercise - fixes #5516 --- main/exercice/question.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index f163f66787..78963a4f64 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1311,8 +1311,8 @@ abstract class Question //echo ''.$explanation.''; } else { $img = pathinfo($img); - $img = $img['filename']; - echo ''.Display::return_icon($img.'_na.gif',$explanation).''; + $img = $img['filename'].'_na.'.$img['extension']; + echo ''.Display::return_icon($img,$explanation).''; //echo '
'; //echo ''.$explanation.''; } From 7b060d11a025feb73eafb1aa57b5bec211f101e2 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 25 Sep 2012 00:55:14 -0500 Subject: [PATCH 002/124] Added permission to get the AJAX classes list for the teacher - fixes #5514 --- main/inc/ajax/model.ajax.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index b53bbb842a..eb9c0c83fb 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -26,7 +26,8 @@ if (!in_array($action, array( 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', - 'get_user_skill_ranking')) + 'get_user_skill_ranking', + 'get_usergroups_teacher')) ) { api_protect_admin_script(true); } From 7f21a26525bce2ec4a4aa79ec1d8b23c3f390c93 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 25 Sep 2012 09:46:19 +0200 Subject: [PATCH 003/124] Copying the forum_image see #5462 --- main/coursecopy/classes/Course.class.php | 2 +- .../classes/CourseRestorer.class.php | 18 ++++++++++++------ main/forum/index.php | 5 ++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/main/coursecopy/classes/Course.class.php b/main/coursecopy/classes/Course.class.php index bba526c04c..c4e63efe60 100644 --- a/main/coursecopy/classes/Course.class.php +++ b/main/coursecopy/classes/Course.class.php @@ -23,7 +23,7 @@ class Course * Create a new Course-object */ function __construct() { - $this->resources = array (); + $this->resources = array(); $this->code = ''; $this->path = ''; $this->backup_path = ''; diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index 7be71a8d2d..c34081979f 100644 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -56,7 +56,6 @@ class CourseRestorer var $file_option; var $set_tools_invisible_by_default; var $skip_content; - var $tools_to_restore = array( 'announcements', 'attendance', @@ -715,11 +714,10 @@ class CourseRestorer */ function restore_forums() { if ($this->course->has_resources(RESOURCE_FORUM)) { - $table_forum = Database::get_course_table(TABLE_FORUM); - - $resources = $this->course->resources; + $table_forum = Database::get_course_table(TABLE_FORUM); + $resources = $this->course->resources; foreach ($resources[RESOURCE_FORUM] as $id => $forum) { - $params = (array)$forum->obj; + $params = (array)$forum->obj; if ($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']]->destination_id == -1) { $cat_id = $this->restore_forum_category($params['forum_category']); } else { @@ -731,7 +729,15 @@ class CourseRestorer $params['forum_category'] = $cat_id; unset($params['forum_id']); - $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['forum_comment'], $this->course->code, $this->course->destination_path); + $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['forum_comment'], $this->course->code, $this->course->destination_path); + + if (!empty($params['forum_image'])) { + $original_forum_image = $this->course->path.'upload/forum/images/'.$params['forum_image']; + if (file_exists($original_forum_image)) { + $new_forum_image = api_get_path(SYS_COURSE_PATH).$this->destination_course_info['path'].'/upload/forum/images/'.$params['forum_image']; + @copy($original_forum_image, $new_forum_image); + } + } $new_id = Database::insert($table_forum, $params); diff --git a/main/forum/index.php b/main/forum/index.php index 321167e6a1..84a4dba4dd 100644 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -291,7 +291,7 @@ if (is_array($forum_categories_list)) { $forum_image = ''; - echo ''; + echo ''; // Showing the image if (!empty($forum['forum_image'])) { @@ -303,14 +303,13 @@ if (is_array($forum_categories_list)) { if (!empty($image_size)) { if ($image_size['width'] > 100 || $image_size['height'] > 100) { //limit display width and height to 100px - $img_attributes = 'width="100" height="100"'; + $img_attributes = ' style="width:100px" width="100px" height="100px"'; } $forum_image = ""; } else { $forum_image = ''; } echo $forum_image; - } else { if ($forum['forum_of_group'] !== '0') { if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) { From abbc85c9d311177733e9a7ebbdbb366de2d39db3 Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Tue, 25 Sep 2012 10:26:51 +0200 Subject: [PATCH 004/124] Add teacher in group list - ref #5526 --- main/inc/lib/groupmanager.lib.php | 159 +++++++++++++++--------------- 1 file changed, 79 insertions(+), 80 deletions(-) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 531ac04822..96da1694d5 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -12,6 +12,47 @@ require_once 'fileManage.lib.php'; require_once 'fileUpload.lib.php'; require_once 'document.lib.php'; +/** + * infinite + */ +define("INFINITE", "99999"); +/** + * No limit on the number of users in a group + */ +define("MEMBER_PER_GROUP_NO_LIMIT", "0"); +/** + * No limit on the number of groups per user + */ +define("GROUP_PER_MEMBER_NO_LIMIT", "0"); +/** + * The tools of a group can have 3 states + * - not available + * - public + * - private + */ +define("TOOL_NOT_AVAILABLE", "0"); +define("TOOL_PUBLIC", "1"); +define("TOOL_PRIVATE", "2"); +/** + * Constants for the available group tools + */ +define("GROUP_TOOL_FORUM", "0"); +define("GROUP_TOOL_DOCUMENTS", "1"); +define("GROUP_TOOL_CALENDAR","2"); +define("GROUP_TOOL_ANNOUNCEMENT","3"); +define("GROUP_TOOL_WORK","4"); +define("GROUP_TOOL_WIKI", "5"); +define("GROUP_TOOL_CHAT", "6"); + +/** + * Fixed id's for group categories + * - VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the + * virtual course of a course + * - DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform- + * setting), all groups are created in this 'dummy'-category + */ +define("VIRTUAL_COURSE_CATEGORY", 1); +define("DEFAULT_GROUP_CATEGORY", 2); /** * This library contains some functions for group-management. * @author Bart Mollet @@ -20,49 +61,6 @@ require_once 'document.lib.php'; * be used outside a session. */ class GroupManager { - //- VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the virtual course of a course - CONST VIRTUAL_COURSE_CATEGORY = 1; - - //DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform-setting), all groups are created in this 'dummy'-category - CONST DEFAULT_GROUP_CATEGORY = 2; - - /** - * infinite - */ - CONST INFINITE = 99999; - /** - * No limit on the number of users in a group - */ - CONST MEMBER_PER_GROUP_NO_LIMIT = 0; - /** - * No limit on the number of groups per user - */ - CONST GROUP_PER_MEMBER_NO_LIMIT = 0; - /** - * The tools of a group can have 3 states - * - not available - * - public - * - private - */ - CONST TOOL_NOT_AVAILABLE = 0; - CONST TOOL_PUBLIC = 1; - CONST TOOL_PRIVATE = 2; - /** - * Constants for the available group tools - */ - CONST GROUP_TOOL_FORUM = 0; - CONST GROUP_TOOL_DOCUMENTS = 1; - CONST GROUP_TOOL_CALENDAR = 2; - CONST GROUP_TOOL_ANNOUNCEMENT = 3; - CONST GROUP_TOOL_WORK = 4; - CONST GROUP_TOOL_WIKI = 5; - CONST GROUP_TOOL_CHAT = 6; - - - - - - //GROUP FUNCTIONS private function __construct() { } @@ -175,7 +173,7 @@ class GroupManager { $groups = array (); $thisGroup= array(); while ($thisGroup = Database::fetch_array($groupList)) { - if ($thisGroup['category_id'] == self::VIRTUAL_COURSE_CATEGORY) { + if ($thisGroup['category_id'] == VIRTUAL_COURSE_CATEGORY) { $sql = "SELECT title FROM $table_course WHERE code = '".$thisGroup['name']."'"; $obj = Database::fetch_object(Database::query($sql)); $thisGroup['name'] = $obj->title; @@ -290,7 +288,7 @@ class GroupManager { public static function create_subgroups ($group_id, $number_of_groups) { $course_id = api_get_course_int_id(); $table_group = Database :: get_course_table(TABLE_GROUP); - $category_id = self :: create_category('Subgroups', '', GroupManager::TOOL_PRIVATE, GroupManager::TOOL_PRIVATE, 0, 0, 1, 1); + $category_id = self :: create_category('Subgroups', '', TOOL_PRIVATE, TOOL_PRIVATE, 0, 0, 1, 1); $users = self :: get_users($group_id); $group_ids = array (); @@ -312,12 +310,12 @@ class GroupManager { * Create groups from all virtual courses in the given course. */ public static function create_groups_from_virtual_courses() { - self :: delete_category(self::VIRTUAL_COURSE_CATEGORY); - $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', GroupManager::TOOL_NOT_AVAILABLE, GroupManager::TOOL_NOT_AVAILABLE, 0, 0, 1, 1); + self :: delete_category(VIRTUAL_COURSE_CATEGORY); + $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', TOOL_NOT_AVAILABLE, TOOL_NOT_AVAILABLE, 0, 0, 1, 1); $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); $course_id = api_get_course_int_id(); - $sql = "UPDATE ".$table_group_cat." SET id=".self::VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; + $sql = "UPDATE ".$table_group_cat." SET id=".VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; Database::query($sql); $course = api_get_course_info(); $course['code'] = $course['sysCode']; @@ -334,7 +332,7 @@ class GroupManager { $members[] = $user['user_id']; } } - $id = self :: create_group($group_course['code'], self::VIRTUAL_COURSE_CATEGORY, 0, count($members)); + $id = self :: create_group($group_course['code'], VIRTUAL_COURSE_CATEGORY, 0, count($members)); self :: subscribe_users($members, $id); $ids[] = $id; } @@ -670,7 +668,7 @@ class GroupManager { max_student = '".Database::escape_string($maximum_number_of_students)."' "; Database::query($sql); $id = Database::insert_id(); - if ($id == self::VIRTUAL_COURSE_CATEGORY) { + if ($id == VIRTUAL_COURSE_CATEGORY) { $sql = "UPDATE ".$table_group_category." SET id = ". ($id +1)." WHERE c_id = $course_id AND id = $id"; Database::query($sql); return $id +1; @@ -850,10 +848,8 @@ class GroupManager { * @return void */ public static function fill_groups ($group_ids) { - global $_course; - $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids); - $group_ids = array_map('intval', $group_ids); + $group_ids = array_map('intval',$group_ids); if (api_is_course_coach()) { for ($i=0 ; $i< count($group_ids) ; $i++) { @@ -866,7 +862,8 @@ class GroupManager { return false; } } - + + global $_course; $category = self::get_category_from_group($group_ids[0]); $groups_per_user = $category['groups_per_user']; @@ -874,23 +871,25 @@ class GroupManager { $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $session_id = api_get_session_id(); - $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); - $number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); + $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); + $number_groups_per_user = ($groups_per_user == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $groups_per_user); /* * Retrieve all the groups where enrollment is still allowed * (reverse) ordered by the number of place available */ - $course_id = api_get_course_int_id(); + $course_id = api_get_course_int_id(); + $sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student FROM ".$group_table." g - LEFT JOIN ".$group_user_table." ug ON - g.c_id = $course_id AND ug.c_id = $course_id AND g.id = ug.group_id - WHERE + LEFT JOIN ".$group_user_table." ug + ON g.id = ug.group_id + WHERE + g.c_id = $course_id AND g.id IN (".implode(',', $group_ids).") GROUP BY (g.id) - HAVING (nbPlaces > 0 OR g.max_student = ".GroupManager::MEMBER_PER_GROUP_NO_LIMIT.") + HAVING (nbPlaces > 0 OR g.max_student = ".MEMBER_PER_GROUP_NO_LIMIT.") ORDER BY nbPlaces DESC"; $sql_result = Database::query($sql); $group_available_place = array (); @@ -977,7 +976,7 @@ class GroupManager { $db_result = Database::query("SELECT max_student FROM $table_group WHERE c_id = $course_id AND id = $group_id"); $db_object = Database::fetch_object($db_result); if ($db_object->max_student == 0) { - return self::INFINITE; + return INFINITE; } return $db_object->max_student; } @@ -1073,8 +1072,8 @@ class GroupManager { $result = CourseManager :: is_user_subscribed_in_real_or_linked_course($user_id, $course_code); $result = !self :: is_subscribed($user_id, $group_id); $result &= (self :: number_of_students($group_id) < self :: maximum_number_of_students($group_id)); - if ($category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT) { - $category['groups_per_user'] = self::INFINITE; + if ($category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT) { + $category['groups_per_user'] = INFINITE; } $result &= (self :: user_in_number_of_groups($user_id, $category['id']) < $category['groups_per_user']); $result &= !self :: is_tutor_of_group($user_id, $group_id); @@ -1412,7 +1411,7 @@ class GroupManager { public static function get_complete_list_of_users_that_can_be_added_to_group ($course_code, $group_id) { global $_course, $_user; $category = self :: get_category_from_group($group_id, $course_code); - $number_of_groups_limit = $category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $category['groups_per_user']; + $number_of_groups_limit = $category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $category['groups_per_user']; $real_course_code = $_course['sysCode']; $real_course_info = Database :: get_course_info($real_course_code); $real_course_user_list = CourseManager :: get_user_list_from_course_code($real_course_code); @@ -1536,25 +1535,25 @@ class GroupManager { } switch ($tool) { - case self::GROUP_TOOL_FORUM : + case GROUP_TOOL_FORUM : $state_key = 'forum_state'; break; - case self::GROUP_TOOL_DOCUMENTS : + case GROUP_TOOL_DOCUMENTS : $state_key = 'doc_state'; break; - case self::GROUP_TOOL_CALENDAR : + case GROUP_TOOL_CALENDAR : $state_key = 'calendar_state'; break; - case self::GROUP_TOOL_ANNOUNCEMENT : + case GROUP_TOOL_ANNOUNCEMENT : $state_key = 'announcements_state'; break; - case self::GROUP_TOOL_WORK : + case GROUP_TOOL_WORK : $state_key = 'work_state'; break; - case self::GROUP_TOOL_WIKI : + case GROUP_TOOL_WIKI : $state_key = 'wiki_state'; break; - case self::GROUP_TOOL_CHAT : + case GROUP_TOOL_CHAT : $state_key = 'chat_state'; break; default: @@ -1571,24 +1570,24 @@ class GroupManager { if (!empty($category_group_info)) { //if exists check the category group status first - if ($category_group_info[$state_key] == GroupManager::TOOL_NOT_AVAILABLE) { + if ($category_group_info[$state_key] == TOOL_NOT_AVAILABLE) { return false; - } elseif($category_group_info[$state_key] == GroupManager::TOOL_PRIVATE && !$user_is_in_group) { + } elseif($category_group_info[$state_key] == TOOL_PRIVATE && !$user_is_in_group) { return false; } } //is_user_in_group() is more complete that the is_subscribed() function - if ($group_info[$state_key] == GroupManager::TOOL_NOT_AVAILABLE) { + if ($group_info[$state_key] == TOOL_NOT_AVAILABLE) { return false; - } elseif ($group_info[$state_key] == self::TOOL_PUBLIC) { + } elseif ($group_info[$state_key] == TOOL_PUBLIC) { return true; } elseif (api_is_allowed_to_edit(false,true)) { return true; } elseif($group_info['tutor_id'] == $user_id) { //this tutor implementation was dropped return true; - } elseif($group_info[$state_key] == GroupManager::TOOL_PRIVATE && !$user_is_in_group) { + } elseif($group_info[$state_key] == TOOL_PRIVATE && !$user_is_in_group) { return false; } else { return $user_is_in_group; @@ -1648,7 +1647,7 @@ class GroupManager { $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $session_id = api_get_session_id(); $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['sysCode'], true, $session_id); - $number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); + $number_groups_per_user = ($groups_per_user == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $groups_per_user); $course_id = api_get_course_int_id(); /* * Retrieve all the groups where enrollment is still allowed @@ -1662,7 +1661,7 @@ class GroupManager { ug.c_id = $course_id AND g.id IN (".implode(',', $group_ids).") GROUP BY (g.id) - HAVING (nbPlaces > 0 OR g.max_student = ".GroupManager::MEMBER_PER_GROUP_NO_LIMIT.") + HAVING (nbPlaces > 0 OR g.max_student = ".MEMBER_PER_GROUP_NO_LIMIT.") ORDER BY nbPlaces DESC"; $sql_result = Database::query($sql); $group_available_place = array (); @@ -1684,7 +1683,7 @@ class GroupManager { //first sort by user_id to filter out duplicates $complete_user_list = TableSort :: sort_table($complete_user_list, 'user_id'); $complete_user_list = self :: filter_duplicates($complete_user_list, 'user_id'); - $complete_user_list = self :: filter_only_students($complete_user_list); + // $complete_user_list = self :: filter_only_students($complete_user_list); // #5526 //now sort by # of group left $complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC); return $complete_user_list; From 26b731bd6d858c2d1669a7e5199141cf0c592fc9 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 25 Sep 2012 13:45:54 -0500 Subject: [PATCH 005/124] Fixed possible issue with http_request function naming, reported by Ghislain Fabre --- main/admin/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/admin/index.php b/main/admin/index.php index 97dbd33684..cecf646581 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -397,7 +397,7 @@ function check_system_version() { 'adminname' => api_get_setting('administratorName').' '.api_get_setting('administratorSurname'), ); - $res = http_request('version.chamilo.org', 80, '/version.php', $data); + $res = _http_request('version.chamilo.org', 80, '/version.php', $data); if ($res !== false) { $version_info = $res; @@ -427,7 +427,7 @@ function check_system_version() { * @param bool Include HTTP Request headers? * @param bool Include HTTP Response headers? */ -function http_request($ip, $port = 80, $uri = '/', $getdata = array(), $timeout = 1, $req_hdr = false, $res_hdr = false) { +function _http_request($ip, $port = 80, $uri = '/', $getdata = array(), $timeout = 1, $req_hdr = false, $res_hdr = false) { $verb = 'GET'; $ret = ''; $getdata_str = count($getdata) ? '?' : ''; From b77abb1f907645d35cad378e36aae31b0eb907f7 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 26 Sep 2012 18:24:33 -0500 Subject: [PATCH 006/124] Minor - code style change --- main/auth/profile.php | 706 +++++++++++++++++++++--------------------- 1 file changed, 353 insertions(+), 353 deletions(-) diff --git a/main/auth/profile.php b/main/auth/profile.php index 37361d18ab..365335da5b 100644 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -18,9 +18,9 @@ $cidReset = true; require_once '../inc/global.inc.php'; if (api_get_setting('allow_social_tool') == 'true') { - $this_section = SECTION_SOCIAL; + $this_section = SECTION_SOCIAL; } else { - $this_section = SECTION_MYPROFILE; + $this_section = SECTION_MYPROFILE; } $_SESSION['this_section'] = $this_section; @@ -34,30 +34,30 @@ $htmlHeadXtra[] = ' '../auth/profile.php', 'name' => get_lang('ModifyProfile')); if (!empty ($_GET['coursePath'])) { - $course_url = api_get_path(WEB_COURSE_PATH).htmlentities(strip_tags($_GET['coursePath'])).'/index.php'; - $interbreadcrumb[] = array('url' => $course_url, 'name' => Security::remove_XSS($_GET['courseCode'])); + $course_url = api_get_path(WEB_COURSE_PATH).htmlentities(strip_tags($_GET['coursePath'])).'/index.php'; + $interbreadcrumb[] = array('url' => $course_url, 'name' => Security::remove_XSS($_GET['courseCode'])); } $warning_msg = ''; if (!empty($_GET['fe'])) { - $warning_msg .= get_lang('UplUnableToSaveFileFilteredExtension'); - $_GET['fe'] = null; + $warning_msg .= get_lang('UplUnableToSaveFileFilteredExtension'); + $_GET['fe'] = null; } $jquery_ready_content = ''; if (api_get_setting('allow_message_tool') == 'true') { - $jquery_ready_content = <<addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"', array('style' => 'visibility:hidden;')); +// $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"', array('style' => 'visibility:hidden;')); //} -// SUBMIT (visible) +// SUBMIT (visible) /*if (is_profile_editable()) { - $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"'); + $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"'); } else { - $form->freeze(); + $form->freeze(); }*/ //THEME if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') { $form->addElement('select_theme', 'theme', get_lang('Theme')); - if (api_get_setting('profile', 'theme') !== 'true') - $form->freeze('theme'); - $form->applyFilter('theme', 'trim'); + if (api_get_setting('profile', 'theme') !== 'true') + $form->freeze('theme'); + $form->applyFilter('theme', 'trim'); } if (api_is_western_name_order()) { - // FIRST NAME and LAST NAME - $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); - $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); + // FIRST NAME and LAST NAME + $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); + $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); } else { - // LAST NAME and FIRST NAME - $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); - $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); + // LAST NAME and FIRST NAME + $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); + $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); } if (api_get_setting('profile', 'name') !== 'true') { - $form->freeze(array('lastname', 'firstname')); + $form->freeze(array('lastname', 'firstname')); } $form->applyFilter(array('lastname', 'firstname'), 'stripslashes'); $form->applyFilter(array('lastname', 'firstname'), 'trim'); $form->addRule('lastname' , get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); -// USERNAME +// USERNAME $form->addElement('text', 'username', get_lang('UserName'), array('maxlength' => USERNAME_MAX_LENGTH, 'size' => USERNAME_MAX_LENGTH)); if (api_get_setting('profile', 'login') !== 'true') { - $form->freeze('username'); + $form->freeze('username'); } $form->applyFilter('username', 'stripslashes'); $form->applyFilter('username', 'trim'); @@ -174,23 +174,23 @@ $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('username', get_lang('UsernameWrong'), 'username'); $form->addRule('username', get_lang('UserTaken'), 'username_available', $user_data['username']); -// OFFICIAL CODE +// OFFICIAL CODE if (CONFVAL_ASK_FOR_OFFICIAL_CODE) { - $form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40)); - if (api_get_setting('profile', 'officialcode') !== 'true') { - $form->freeze('official_code'); - } - $form->applyFilter('official_code', 'stripslashes'); - $form->applyFilter('official_code', 'trim'); - if (api_get_setting('registration', 'officialcode') == 'true' && api_get_setting('profile', 'officialcode') == 'true') { - $form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required'); - } -} - -// EMAIL + $form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40)); + if (api_get_setting('profile', 'officialcode') !== 'true') { + $form->freeze('official_code'); + } + $form->applyFilter('official_code', 'stripslashes'); + $form->applyFilter('official_code', 'trim'); + if (api_get_setting('registration', 'officialcode') == 'true' && api_get_setting('profile', 'officialcode') == 'true') { + $form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required'); + } +} + +// EMAIL $form->addElement('email', 'email', get_lang('Email'), array('size' => 40)); if (api_get_setting('profile', 'email') !== 'true') { - $form->freeze('email'); + $form->freeze('email'); } if (api_get_setting('registration', 'email') == 'true' && api_get_setting('profile', 'email') == 'true') { @@ -202,80 +202,80 @@ if (api_get_setting('registration', 'email') == 'true' && api_get_setting('prof // OPENID URL if (is_profile_editable() && api_get_setting('openid_authentication') == 'true') { - $form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40)); - if (api_get_setting('profile', 'openid') !== 'true') { - $form->freeze('openid'); - } - $form->applyFilter('openid', 'trim'); - //if (api_get_setting('registration', 'openid') == 'true') { - // $form->addRule('openid', get_lang('ThisFieldIsRequired'), 'required'); - //} + $form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40)); + if (api_get_setting('profile', 'openid') !== 'true') { + $form->freeze('openid'); + } + $form->applyFilter('openid', 'trim'); + //if (api_get_setting('registration', 'openid') == 'true') { + // $form->addRule('openid', get_lang('ThisFieldIsRequired'), 'required'); + //} } -// PHONE +// PHONE $form->addElement('text', 'phone', get_lang('phone'), array('size' => 20)); if (api_get_setting('profile', 'phone') !== 'true') { - $form->freeze('phone'); + $form->freeze('phone'); } $form->applyFilter('phone', 'stripslashes'); $form->applyFilter('phone', 'trim'); /*if (api_get_setting('registration', 'phone') == 'true') { - $form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required'); } $form->addRule('phone', get_lang('EmailWrong'), 'email');*/ -// PICTURE +// PICTURE if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') { - $form->addElement('file', 'picture', ($user_data['picture_uri'] != '' ? get_lang('UpdateImage') : get_lang('AddImage'))); - $form->add_progress_bar(); - if (!empty($user_data['picture_uri'])) { - $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); - } - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); - $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); + $form->addElement('file', 'picture', ($user_data['picture_uri'] != '' ? get_lang('UpdateImage') : get_lang('AddImage'))); + $form->add_progress_bar(); + if (!empty($user_data['picture_uri'])) { + $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); + } + $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); + $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); } -// LANGUAGE +// LANGUAGE $form->addElement('select_language', 'language', get_lang('Language')); if (api_get_setting('profile', 'language') !== 'true') { - $form->freeze('language'); + $form->freeze('language'); } -// EXTENDED PROFILE this make the page very slow! +// EXTENDED PROFILE this make the page very slow! if (api_get_setting('extended_profile') == 'true') { - if (!isset($_GET['type']) || (isset($_GET['type']) && $_GET['type'] == 'extended')) { - $width_extended_profile = 500; - //$form->addElement('html', ' show_extend_profile'); - //$form->addElement('static', null, ''.get_lang('OptionalTextFields').''); - // MY COMPETENCES - $form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130')); - // MY DIPLOMAS - $form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130')); - // WHAT I AM ABLE TO TEACH - $form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130')); - - // MY PRODUCTIONS - $form->addElement('file', 'production', get_lang('MyProductions')); - if ($production_list = UserManager::build_production_list(api_get_user_id(), '', true)) { - $form->addElement('static', 'productions_list', null, $production_list); - } - // MY PERSONAL OPEN AREA - $form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '350')); - $form->applyFilter(array('competences', 'diplomas', 'teach', 'openarea'), 'stripslashes'); - $form->applyFilter(array('competences', 'diplomas', 'teach'), 'trim'); // openarea is untrimmed for maximum openness - } -} - -// PASSWORD, if auth_source is platform + if (!isset($_GET['type']) || (isset($_GET['type']) && $_GET['type'] == 'extended')) { + $width_extended_profile = 500; + //$form->addElement('html', ' show_extend_profile'); + //$form->addElement('static', null, ''.get_lang('OptionalTextFields').''); + // MY COMPETENCES + $form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130')); + // MY DIPLOMAS + $form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130')); + // WHAT I AM ABLE TO TEACH + $form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '130')); + + // MY PRODUCTIONS + $form->addElement('file', 'production', get_lang('MyProductions')); + if ($production_list = UserManager::build_production_list(api_get_user_id(), '', true)) { + $form->addElement('static', 'productions_list', null, $production_list); + } + // MY PERSONAL OPEN AREA + $form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => $width_extended_profile, 'Height' => '350')); + $form->applyFilter(array('competences', 'diplomas', 'teach', 'openarea'), 'stripslashes'); + $form->applyFilter(array('competences', 'diplomas', 'teach'), 'trim'); // openarea is untrimmed for maximum openness + } +} + +// PASSWORD, if auth_source is platform if (is_platform_authentication() && is_profile_editable() && api_get_setting('profile', 'password') == 'true') { - $form->addElement('password', 'password0', array(get_lang('Pass'), get_lang('Enter2passToChange')), array('size' => 40)); - $form->addElement('password', 'password1', get_lang('NewPass'), array('size' => 40)); - $form->addElement('password', 'password2', get_lang('Confirmation'), array('size' => 40)); - // user must enter identical password twice so we can prevent some user errors - $form->addRule(array('password1', 'password2'), get_lang('PassTwo'), 'compare'); - if (CHECK_PASS_EASY_TO_FIND) { - $form->addRule('password1', get_lang('CurrentPasswordEmptyOrIncorrect'), 'callback', 'api_check_password'); - } + $form->addElement('password', 'password0', array(get_lang('Pass'), get_lang('Enter2passToChange')), array('size' => 40)); + $form->addElement('password', 'password1', get_lang('NewPass'), array('size' => 40)); + $form->addElement('password', 'password2', get_lang('Confirmation'), array('size' => 40)); + // user must enter identical password twice so we can prevent some user errors + $form->addRule(array('password1', 'password2'), get_lang('PassTwo'), 'compare'); + if (CHECK_PASS_EASY_TO_FIND) { + $form->addRule('password1', get_lang('CurrentPasswordEmptyOrIncorrect'), 'callback', 'api_check_password'); + } } // EXTRA FIELDS @@ -286,27 +286,27 @@ $jquery_ready_content = $return_params['jquery_ready_content']; // the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function $htmlHeadXtra[] =''; if (api_get_setting('profile', 'apikeys') == 'true') { - $form->addElement('html', '
'); - $form->addElement('text', 'api_key_generate', get_lang('MyApiKey'), array('size' => 40, 'id' => 'id_api_key_generate')); - $form->addElement('html', '
'); - $form->addElement('button', 'generate_api_key', get_lang('GenerateApiKey'), array('id' => 'id_generate_api_key', 'onclick' => 'generate_open_id_form()')); //generate_open_id_form() + $form->addElement('html', '
'); + $form->addElement('text', 'api_key_generate', get_lang('MyApiKey'), array('size' => 40, 'id' => 'id_api_key_generate')); + $form->addElement('html', '
'); + $form->addElement('button', 'generate_api_key', get_lang('GenerateApiKey'), array('id' => 'id_generate_api_key', 'onclick' => 'generate_open_id_form()')); //generate_open_id_form() } -// SUBMIT +// SUBMIT if (is_profile_editable()) { - $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"'); + $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"'); } else { - $form->freeze(); + $form->freeze(); } $user_data = array_merge($user_data, $extra_data); $form->setDefaults($user_data); -/* FUNCTIONS */ +/* FUNCTIONS */ /** @@ -322,74 +322,74 @@ function is_platform_authentication() { /** * Can a user edit his/her profile? * - * @return boolean Editability of the profile + * @return boolean Editability of the profile */ function is_profile_editable() { - return $GLOBALS['profileIsEditable']; + return $GLOBALS['profileIsEditable']; } /* - PRODUCTIONS FUNCTIONS + PRODUCTIONS FUNCTIONS */ /** * Upload a submitted user production. * - * @param $user_id User id - * @return The filename of the new production or FALSE if the upload has failed + * @param $user_id User id + * @return The filename of the new production or FALSE if the upload has failed */ function upload_user_production($user_id) { - $image_path = UserManager::get_user_picture_path_by_id($user_id, 'system', true); + $image_path = UserManager::get_user_picture_path_by_id($user_id, 'system', true); - $production_repository = $image_path['dir'].$user_id.'/'; + $production_repository = $image_path['dir'].$user_id.'/'; - if (!file_exists($production_repository)) { - @mkdir($production_repository, api_get_permissions_for_new_directories(), true); - } - $filename = replace_dangerous_char($_FILES['production']['name']); - $filename = disable_dangerous_file($filename); + if (!file_exists($production_repository)) { + @mkdir($production_repository, api_get_permissions_for_new_directories(), true); + } + $filename = replace_dangerous_char($_FILES['production']['name']); + $filename = disable_dangerous_file($filename); - if (filter_extension($filename)) { - if (@move_uploaded_file($_FILES['production']['tmp_name'], $production_repository.$filename)) { - return $filename; - } - } - return false; // this should be returned if anything went wrong with the upload + if (filter_extension($filename)) { + if (@move_uploaded_file($_FILES['production']['tmp_name'], $production_repository.$filename)) { + return $filename; + } + } + return false; // this should be returned if anything went wrong with the upload } /** * Check current user's current password - * @param char password - * @return bool true o false + * @param char password + * @return bool true o false * @uses Gets user ID from global variable */ function check_user_password($password){ - global $_user; - $user_id = api_get_user_id(); - if ($user_id != strval(intval($user_id)) || empty($password)) { return false; } - $table_user = Database :: get_main_table(TABLE_MAIN_USER); - $password = api_get_encrypted_password($password); - $sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND password='".$password."'"; - $result = Database::query($sql_password); - return Database::num_rows($result) != 0; + global $_user; + $user_id = api_get_user_id(); + if ($user_id != strval(intval($user_id)) || empty($password)) { return false; } + $table_user = Database :: get_main_table(TABLE_MAIN_USER); + $password = api_get_encrypted_password($password); + $sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND password='".$password."'"; + $result = Database::query($sql_password); + return Database::num_rows($result) != 0; } /** * Check current user's current password - * @param char email - * @return bool true o false + * @param char email + * @return bool true o false * @uses Gets user ID from global variable */ function check_user_email($email) { - $user_id = api_get_user_id(); - if ($user_id != strval(intval($user_id)) || empty($email)) { return false; } - $table_user = Database :: get_main_table(TABLE_MAIN_USER); + $user_id = api_get_user_id(); + if ($user_id != strval(intval($user_id)) || empty($email)) { return false; } + $table_user = Database :: get_main_table(TABLE_MAIN_USER); $email = Database::escape_string($email); - $sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND email='".$email."'"; - $result = Database::query($sql_password); - return Database::num_rows($result) != 0; + $sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND email='".$email."'"; + $result = Database::query($sql_password); + return Database::num_rows($result) != 0; } -/* MAIN CODE */ +/* MAIN CODE */ $filtered_extension = false; $update_success = false; $upload_picture_success = false; @@ -399,44 +399,44 @@ $msg_is_not_password = false; if (is_platform_authentication()) { if (!empty($_SESSION['change_email'])) { - $msg_fail_changue_email= ($_SESSION['change_email'] == 'success'); - unset($_SESSION['change_email']); + $msg_fail_changue_email= ($_SESSION['change_email'] == 'success'); + unset($_SESSION['change_email']); } elseif (!empty($_SESSION['is_not_password'])) { - $msg_is_not_password = ($_SESSION['is_not_password'] == 'success'); - unset($_SESSION['is_not_password']); + $msg_is_not_password = ($_SESSION['is_not_password'] == 'success'); + unset($_SESSION['is_not_password']); } elseif (!empty($_SESSION['profile_update'])) { - $update_success = ($_SESSION['profile_update'] == 'success'); - unset($_SESSION['profile_update']); + $update_success = ($_SESSION['profile_update'] == 'success'); + unset($_SESSION['profile_update']); } elseif (!empty($_SESSION['image_uploaded'])) { - $upload_picture_success = ($_SESSION['image_uploaded'] == 'success'); - unset($_SESSION['image_uploaded']); + $upload_picture_success = ($_SESSION['image_uploaded'] == 'success'); + unset($_SESSION['image_uploaded']); } elseif (!empty($_SESSION['production_uploaded'])) { - $upload_production_success = ($_SESSION['production_uploaded'] == 'success'); - unset($_SESSION['production_uploaded']); + $upload_production_success = ($_SESSION['production_uploaded'] == 'success'); + unset($_SESSION['production_uploaded']); } } if ($form->validate()) { - $wrong_current_password = false; -// $user_data = $form->exportValues(); - $user_data = $form->getSubmitValues(); - - // set password if a new one was provided - if (!empty($user_data['password0'])) { - if (check_user_password($user_data['password0'])) { - if (!empty($user_data['password1'])) { - $password = $user_data['password1']; - } - } else { - $wrong_current_password = true; - $_SESSION['is_not_password'] = 'success'; - } - } - if (empty($user_data['password0']) && !empty($user_data['password1'])) { - $wrong_current_password = true; - $_SESSION['is_not_password'] = 'success'; - } + $wrong_current_password = false; +// $user_data = $form->exportValues(); + $user_data = $form->getSubmitValues(); + + // set password if a new one was provided + if (!empty($user_data['password0'])) { + if (check_user_password($user_data['password0'])) { + if (!empty($user_data['password1'])) { + $password = $user_data['password1']; + } + } else { + $wrong_current_password = true; + $_SESSION['is_not_password'] = 'success'; + } + } + if (empty($user_data['password0']) && !empty($user_data['password1'])) { + $wrong_current_password = true; + $_SESSION['is_not_password'] = 'success'; + } $allow_users_to_change_email_with_no_password = true; if (is_platform_authentication() && api_get_setting('allow_users_to_change_email_with_no_password') == 'false') { @@ -467,67 +467,67 @@ if ($form->validate()) { } - // Upload picture if a new one is provided - if ($_FILES['picture']['size']) { - if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) { - $user_data['picture_uri'] = $new_picture; - $_SESSION['image_uploaded'] = 'success'; - } - } elseif (!empty($user_data['remove_picture'])) { - // remove existing picture if asked - UserManager::delete_user_picture(api_get_user_id()); - $user_data['picture_uri'] = ''; - } - - //Remove production - if (is_array($user_data['remove_production'])) { - foreach (array_keys($user_data['remove_production']) as $production) { - UserManager::remove_user_production(api_get_user_id(), urldecode($production)); - } - if ($production_list = UserManager::build_production_list(api_get_user_id(), true, true)) { - $form->insertElementBefore($form->createElement('static', null, null, $production_list), 'productions_list'); - } - $form->removeElement('productions_list'); - $file_deleted = true; - } - - // upload production if a new one is provided - if ($_FILES['production']['size']) { - $res = upload_user_production(api_get_user_id()); - if (!$res) { - //it's a bit excessive to assume the extension is the reason why upload_user_production() returned false, but it's true in most cases - $filtered_extension = true; - } else { - $_SESSION['production_uploaded'] = 'success'; - } - } - - // remove values that shouldn't go in the database - unset($user_data['password0'],$user_data['password1'], $user_data['password2'], $user_data['MAX_FILE_SIZE'], - $user_data['remove_picture'], $user_data['apply_change'],$user_data['email'] ); - - // Following RFC2396 (http://www.faqs.org/rfcs/rfc2396.html), a URI uses ':' as a reserved character - // we can thus ensure the URL doesn't contain any scheme name by searching for ':' in the string - $my_user_openid = isset($user_data['openid']) ? $user_data['openid'] : ''; - if (!preg_match('/^[^:]*:\/\/.*$/', $my_user_openid)) { - //ensure there is at least a http:// scheme in the URI provided - $user_data['openid'] = 'http://'.$my_user_openid; - } - $extras = array(); - - //Checking the user language - $languages = api_get_languages(); + // Upload picture if a new one is provided + if ($_FILES['picture']['size']) { + if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) { + $user_data['picture_uri'] = $new_picture; + $_SESSION['image_uploaded'] = 'success'; + } + } elseif (!empty($user_data['remove_picture'])) { + // remove existing picture if asked + UserManager::delete_user_picture(api_get_user_id()); + $user_data['picture_uri'] = ''; + } + + //Remove production + if (is_array($user_data['remove_production'])) { + foreach (array_keys($user_data['remove_production']) as $production) { + UserManager::remove_user_production(api_get_user_id(), urldecode($production)); + } + if ($production_list = UserManager::build_production_list(api_get_user_id(), true, true)) { + $form->insertElementBefore($form->createElement('static', null, null, $production_list), 'productions_list'); + } + $form->removeElement('productions_list'); + $file_deleted = true; + } + + // upload production if a new one is provided + if ($_FILES['production']['size']) { + $res = upload_user_production(api_get_user_id()); + if (!$res) { + //it's a bit excessive to assume the extension is the reason why upload_user_production() returned false, but it's true in most cases + $filtered_extension = true; + } else { + $_SESSION['production_uploaded'] = 'success'; + } + } + + // remove values that shouldn't go in the database + unset($user_data['password0'],$user_data['password1'], $user_data['password2'], $user_data['MAX_FILE_SIZE'], + $user_data['remove_picture'], $user_data['apply_change'],$user_data['email'] ); + + // Following RFC2396 (http://www.faqs.org/rfcs/rfc2396.html), a URI uses ':' as a reserved character + // we can thus ensure the URL doesn't contain any scheme name by searching for ':' in the string + $my_user_openid = isset($user_data['openid']) ? $user_data['openid'] : ''; + if (!preg_match('/^[^:]*:\/\/.*$/', $my_user_openid)) { + //ensure there is at least a http:// scheme in the URI provided + $user_data['openid'] = 'http://'.$my_user_openid; + } + $extras = array(); + + //Checking the user language + $languages = api_get_languages(); if (!in_array($user_data['language'], $languages['folder'])) { $user_data['language'] = api_get_setting('platformLanguage'); } - //Only update values that are request by the "profile" setting - $profile_list = api_get_setting('profile'); - //Adding missing variables - - $available_values_to_modify = array(); - foreach($profile_list as $key => $status) { - if ($status == 'true') { + //Only update values that are request by the "profile" setting + $profile_list = api_get_setting('profile'); + //Adding missing variables + + $available_values_to_modify = array(); + foreach($profile_list as $key => $status) { + if ($status == 'true') { switch($key) { case 'login': $available_values_to_modify[] = 'username'; @@ -543,41 +543,41 @@ if ($form->validate()) { $available_values_to_modify[] = $key; break; } - } - } + } + } - //Fixing missing variables + //Fixing missing variables $available_values_to_modify = array_merge($available_values_to_modify, array('competences', 'diplomas', 'openarea', 'teach', 'openid')); - // build SQL query - $sql = "UPDATE $table_user SET"; - unset($user_data['api_key_generate']); - foreach ($user_data as $key => $value) { - if (substr($key, 0, 6) == 'extra_') { //an extra field - $new_key = substr($key, 6); - // format array date to 'Y-m-d' or date time to 'Y-m-d H:i:s' - if (is_array($value) && isset($value['Y']) && isset($value['F']) && isset($value['d'])) { - if (isset($value['H']) && isset($value['i'])) { - // extra field date time - $time = mktime($value['H'],$value['i'],0,$value['F'],$value['d'],$value['Y']); - $extras[$new_key] = date('Y-m-d H:i:s',$time); - } else { - // extra field date - $time = mktime(0,0,0,$value['F'],$value['d'],$value['Y']); - $extras[$new_key] = date('Y-m-d',$time); - } - } else { - $extras[$new_key] = $value; - } - } else { - if (in_array($key, $available_values_to_modify)) { + // build SQL query + $sql = "UPDATE $table_user SET"; + unset($user_data['api_key_generate']); + foreach ($user_data as $key => $value) { + if (substr($key, 0, 6) == 'extra_') { //an extra field + $new_key = substr($key, 6); + // format array date to 'Y-m-d' or date time to 'Y-m-d H:i:s' + if (is_array($value) && isset($value['Y']) && isset($value['F']) && isset($value['d'])) { + if (isset($value['H']) && isset($value['i'])) { + // extra field date time + $time = mktime($value['H'],$value['i'],0,$value['F'],$value['d'],$value['Y']); + $extras[$new_key] = date('Y-m-d H:i:s',$time); + } else { + // extra field date + $time = mktime(0,0,0,$value['F'],$value['d'],$value['Y']); + $extras[$new_key] = date('Y-m-d',$time); + } + } else { + $extras[$new_key] = $value; + } + } else { + if (in_array($key, $available_values_to_modify)) { $sql .= " $key = '".Database::escape_string($value)."',"; - } - } - } + } + } + } - //change email - if ($allow_users_to_change_email_with_no_password) { + //change email + if ($allow_users_to_change_email_with_no_password) { if (!empty($changeemail) && in_array('email', $available_values_to_modify)) { $sql .= " email = '".Database::escape_string($changeemail)."',"; } @@ -587,7 +587,7 @@ if ($form->validate()) { } else { // remove trailing , from the query we have so far $sql = rtrim($sql, ','); - } + } } else { //normal behaviour if (!empty($changeemail) && !isset($password) && in_array('email', $available_values_to_modify)) { @@ -606,28 +606,28 @@ if ($form->validate()) { $sql = rtrim($sql, ','); } } - $sql .= " WHERE user_id = '".api_get_user_id()."'"; - Database::query($sql); + $sql .= " WHERE user_id = '".api_get_user_id()."'"; + Database::query($sql); - // User tag process - //1. Deleting all user tags - $list_extra_field_type_tag = UserManager::get_all_extra_field_by_type(UserManager::USER_FIELD_TYPE_TAG); + // User tag process + //1. Deleting all user tags + $list_extra_field_type_tag = UserManager::get_all_extra_field_by_type(UserManager::USER_FIELD_TYPE_TAG); - if (is_array($list_extra_field_type_tag) && count($list_extra_field_type_tag)>0) { - foreach ($list_extra_field_type_tag as $id) { - UserManager::delete_user_tags(api_get_user_id(), $id); - } - } + if (is_array($list_extra_field_type_tag) && count($list_extra_field_type_tag)>0) { + foreach ($list_extra_field_type_tag as $id) { + UserManager::delete_user_tags(api_get_user_id(), $id); + } + } - //2. Update the extra fields and user tags if available + //2. Update the extra fields and user tags if available - if (is_array($extras) && count($extras)> 0) { - foreach ($extras as $key => $value) { - //3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function - UserManager::update_extra_field_value(api_get_user_id(), $key, $value); - } - } + if (is_array($extras) && count($extras)> 0) { + foreach ($extras as $key => $value) { + //3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function + UserManager::update_extra_field_value(api_get_user_id(), $key, $value); + } + } // re-init the system to take new settings into account $_SESSION['_user']['uidReset'] = true; @@ -639,56 +639,56 @@ if ($form->validate()) { } -/* MAIN DISPLAY SECTION */ +/* MAIN DISPLAY SECTION */ // the header Display::display_header(get_lang('ModifyProfile')); if (api_get_setting('allow_social_tool') != 'true') { - if (api_get_setting('extended_profile') == 'true') { - echo '
'; + if (api_get_setting('extended_profile') == 'true') { + echo '
'; - if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { - echo ''.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).''; - } - if (api_get_setting('allow_message_tool') == 'true') { - echo ''.Display::return_icon('inbox.png', get_lang('Messages')).''; - } - $show = isset($_GET['show']) ? '&show='.Security::remove_XSS($_GET['show']) : ''; + if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { + echo ''.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).''; + } + if (api_get_setting('allow_message_tool') == 'true') { + echo ''.Display::return_icon('inbox.png', get_lang('Messages')).''; + } + $show = isset($_GET['show']) ? '&show='.Security::remove_XSS($_GET['show']) : ''; - if (isset($_GET['type']) && $_GET['type'] == 'extended') { - echo ''.Display::return_icon('edit.png', get_lang('EditNormalProfile'),'',16).''; - } else { - echo ''.Display::return_icon('edit.png', get_lang('EditExtendProfile'),'',16).''; - } - echo '
'; - } + if (isset($_GET['type']) && $_GET['type'] == 'extended') { + echo ''.Display::return_icon('edit.png', get_lang('EditNormalProfile'),'',16).''; + } else { + echo ''.Display::return_icon('edit.png', get_lang('EditExtendProfile'),'',16).''; + } + echo '
'; + } } if (!empty($file_deleted)) { - Display :: display_confirmation_message(get_lang('FileDeleted'), false); + Display :: display_confirmation_message(get_lang('FileDeleted'), false); } elseif (!empty($update_success)) { - $message = get_lang('ProfileReg'); + $message = get_lang('ProfileReg'); - if ($upload_picture_success) { - $message .= '
'.get_lang('PictureUploaded'); - } + if ($upload_picture_success) { + $message .= '
'.get_lang('PictureUploaded'); + } - if ($upload_production_success) { - $message.='
'.get_lang('ProductionUploaded'); - } - Display :: display_confirmation_message($message, false); + if ($upload_production_success) { + $message.='
'.get_lang('ProductionUploaded'); + } + Display :: display_confirmation_message($message, false); } if (!empty($msg_fail_changue_email)){ - $errormail=get_lang('ToChangeYourEmailMustTypeYourPassword'); - Display :: display_error_message($errormail, false); + $errormail=get_lang('ToChangeYourEmailMustTypeYourPassword'); + Display :: display_error_message($errormail, false); } if (!empty($msg_is_not_password)){ - $warning_msg = get_lang('CurrentPasswordEmptyOrIncorrect'); - Display :: display_warning_message($warning_msg, false); + $warning_msg = get_lang('CurrentPasswordEmptyOrIncorrect'); + Display :: display_warning_message($warning_msg, false); } //User picture size is calculated from SYSTEM path @@ -703,11 +703,11 @@ $image_dir = $image_path['dir']; $image = $image_path['file']; $image_file = $image_dir.$image; $img_attributes = 'src="'.$image_file.'?rand='.time().'" ' - .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" ' - .'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" '; + .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" ' + .'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" '; if ($image_size['width'] > 300) { - //limit display width to 300px - $img_attributes .= 'width="300" '; + //limit display width to 300px + $img_attributes .= 'width="300" '; } // get the path,width and height from original picture @@ -721,24 +721,24 @@ $url_big_image = $big_image.'?rnd='.time(); $show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false; if (api_get_setting('allow_social_tool') == 'true') { - echo '
'; - echo '
'; - echo SocialManager::show_social_menu('home', null, api_get_user_id(), false, $show_delete_account_button); - echo '
'; - echo '
'; - $form->display(); - echo '
'; + echo '
'; + echo '
'; + echo SocialManager::show_social_menu('home', null, api_get_user_id(), false, $show_delete_account_button); + echo '
'; + echo '
'; + $form->display(); + echo '
'; } else { - // Style position:absolute has been removed for Opera-compatibility. - //echo '
'; - echo '
'; - - if ($image == 'unknown.jpg') { - echo ''; - } else { - echo ''; - } - echo '
'; - $form->display(); -} -Display :: display_footer(); \ No newline at end of file + // Style position:absolute has been removed for Opera-compatibility. + //echo '
'; + echo '
'; + + if ($image == 'unknown.jpg') { + echo ''; + } else { + echo ''; + } + echo '
'; + $form->display(); +} +Display :: display_footer(); From cbbf0752bd17345b4eeb6b23e9e9202ece7a80c1 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 26 Sep 2012 18:27:51 -0500 Subject: [PATCH 007/124] Fixed missing official-code field update code - refs #5538 --- main/auth/profile.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main/auth/profile.php b/main/auth/profile.php index 365335da5b..30e8ebac03 100644 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -606,6 +606,9 @@ if ($form->validate()) { $sql = rtrim($sql, ','); } } + if (api_get_setting('profile', 'officialcode') == 'true' && isset($user_data['official_code'])) { + $sql .= ", official_code = '".Database::escape_string($user_data['official_code'])."'"; + } $sql .= " WHERE user_id = '".api_get_user_id()."'"; Database::query($sql); From f2679f40a736b64bc34df62196ee49d43f695fcc Mon Sep 17 00:00:00 2001 From: Yoselyn Castillo Date: Wed, 26 Sep 2012 18:31:45 -0500 Subject: [PATCH 008/124] Added missing constants in groupmanager class - refs #5537 --- main/inc/lib/groupmanager.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 96da1694d5..6cb6c45a8d 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -61,6 +61,10 @@ define("DEFAULT_GROUP_CATEGORY", 2); * be used outside a session. */ class GroupManager { + //CLASS CONSTANTS + const TOOL_NOT_AVAILABLE = 0; + const DEFAULT_GROUP_CATEGORY = 2; + const MEMBER_PER_GROUP_NO_LIMIT = 0; //GROUP FUNCTIONS private function __construct() { } From 96c0909ae9f71cad20004406f959dc3fb8d290d5 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 26 Sep 2012 18:34:15 -0500 Subject: [PATCH 009/124] Minor: Changed code indentation --- main/survey/fillsurvey.php | 1732 ++++++++++++++++++------------------ 1 file changed, 866 insertions(+), 866 deletions(-) diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index cbb45ac7d2..bd07bff6c5 100644 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -2,25 +2,25 @@ /* For licensing terms, see /license.txt */ /** - * @package chamilo.survey - * @author unknown, the initial survey that did not make it in 1.8 because of bad code - * @author Patrick Cool , Ghent University: cleanup, refactoring and rewriting large parts of the code - * @author Julio Montoya Armas , Chamilo: Personality Test modification and rewriting large parts of the code as well - * @version $Id: survey_list.php 10680 2007-01-11 21:26:23Z pcool $ + * @package chamilo.survey + * @author unknown, the initial survey that did not make it in 1.8 because of bad code + * @author Patrick Cool , Ghent University: cleanup, refactoring and rewriting large parts of the code + * @author Julio Montoya Armas , Chamilo: Personality Test modification and rewriting large parts of the code as well + * @version $Id: survey_list.php 10680 2007-01-11 21:26:23Z pcool $ * - * @todo use quickforms for the forms - * @todo check if the user already filled the survey and if this is the case then the answers have to be updated and not stored again. - * alterantively we could not allow people from filling the survey twice. - * @todo performance could be improved if not the survey_id was stored with the invitation but the survey_code + * @todo use quickforms for the forms + * @todo check if the user already filled the survey and if this is the case then the answers have to be updated and not stored again. + * alterantively we could not allow people from filling the survey twice. + * @todo performance could be improved if not the survey_id was stored with the invitation but the survey_code */ // Language file that needs to be included $language_file = 'survey'; // Unsetting the course id (because it is in the URL) if (!isset($_GET['cidReq'])) { - $cidReset = true; + $cidReset = true; } else { - $_cid = $_GET['cidReq']; + $_cid = $_GET['cidReq']; } // Including the global initialization file @@ -32,7 +32,7 @@ require_once 'survey.lib.php'; // Breadcrumbs if (!empty($_user)) { - $interbreadcrumb[] = array('url' => 'survey_list.php?cidReq='.Security::remove_XSS($_GET['course']), 'name' => get_lang('SurveyList')); + $interbreadcrumb[] = array('url' => 'survey_list.php?cidReq='.Security::remove_XSS($_GET['course']), 'name' => get_lang('SurveyList')); } // Header @@ -52,20 +52,20 @@ if (empty($course_info)) { $course_id = $course_info['real_id']; // Database table definitions -$table_survey = Database :: get_course_table(TABLE_SURVEY); -$table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); -$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); -$table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); +$table_survey = Database :: get_course_table(TABLE_SURVEY); +$table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER); +$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); +$table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); -$table_user = Database :: get_main_table(TABLE_MAIN_USER); +$table_user = Database :: get_main_table(TABLE_MAIN_USER); // First we check if the needed parameters are present if ((!isset($_GET['course']) || !isset($_GET['invitationcode'])) && !isset($_GET['user_id'])) { - Display :: display_error_message(get_lang('SurveyParametersMissingUseCopyPaste'), false); - Display :: display_footer(); - exit; + Display :: display_error_message(get_lang('SurveyParametersMissingUseCopyPaste'), false); + Display :: display_footer(); + exit; } $invitationcode = $_GET['invitationcode']; @@ -74,7 +74,7 @@ $invitationcode = $_GET['invitationcode']; if ($invitationcode == 'auto' && isset($_GET['scode'])) { // Not intended for anonymous users if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user['user_id'],true)) { - api_not_allowed(); + api_not_allowed(); } $userid = $_user['user_id']; $scode = Database::escape_string($_GET['scode']); // Survey_code of the survey @@ -105,18 +105,18 @@ if ($invitationcode == 'auto' && isset($_GET['scode'])) { $sql = "SELECT * FROM $table_survey_invitation WHERE c_id = $course_id AND invitation_code = '" . Database :: escape_string($invitationcode) . "'"; $result = Database::query($sql); // false = suppress errors if (Database::num_rows($result) < 1) { - Display :: display_error_message(get_lang('WrongInvitationCode'), false); - Display :: display_footer(); - exit; + Display :: display_error_message(get_lang('WrongInvitationCode'), false); + Display :: display_footer(); + exit; } $survey_invitation = Database::fetch_array($result, 'ASSOC'); // Now we check if the user already filled the survey if ($survey_invitation['answered'] == 1 && !isset($_GET['user_id'])) { - Display :: display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false); - Display :: display_footer(); - exit; + Display :: display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false); + Display :: display_footer(); + exit; } // Checking if there is another survey with this code. @@ -125,24 +125,24 @@ $sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database $result = Database::query($sql); if (Database::num_rows($result) > 1) { - if ($_POST['language']) { - $survey_invitation['survey_id'] = $_POST['language']; - } else { - echo '
'; - echo ' '; - //echo ' '; - echo ''; - echo '
'; - Display::display_footer(); - exit(); - } + if ($_POST['language']) { + $survey_invitation['survey_id'] = $_POST['language']; + } else { + echo '
'; + echo ' '; + //echo ' '; + echo ''; + echo '
'; + Display::display_footer(); + exit(); + } } else { - $row = Database::fetch_array($result, 'ASSOC'); - $survey_invitation['survey_id'] = $row['survey_id']; + $row = Database::fetch_array($result, 'ASSOC'); + $survey_invitation['survey_id'] = $row['survey_id']; } // Getting the survey information @@ -152,96 +152,96 @@ $survey_data['survey_id'] = $survey_invitation['survey_id']; // Storing the answers if (count($_POST) > 0) { if ($survey_data['survey_type'] === '0') { - // Getting all the types of the question (because of the special treatment of the score question type - $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."'"; - $result = Database::query($sql); - - while ($row = Database::fetch_array($result, 'ASSOC')) { - $types[$row['question_id']] = $row['type']; - } - - - // Looping through all the post values - foreach ($_POST as $key => & $value) { - // If the post value key contains the string 'question' then it is an answer on a question - if (strpos($key, 'question') !== false) { - // Finding the question id by removing 'question' - $survey_question_id = str_replace('question', '', $key); - - // If the post value is an array then we have a multiple response question or a scoring question type - // remark: when it is a multiple response then the value of the array is the option_id - // when it is a scoring question then the key of the array is the option_id and the value is the value - if (is_array($value)) { - SurveyUtil::remove_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id); - foreach ($value as $answer_key => & $answer_value) { - if ($types[$survey_question_id] == 'score') { - $option_id = $answer_key; - $option_value = $answer_value; - } else { - $option_id = $answer_value; - $option_value = ''; - } - SurveyUtil::store_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id, $option_id, $option_value, $survey_data); - } - } - // All the other question types (open question, multiple choice, percentage, ...) - else { - if ($types[$survey_question_id] == 'percentage') { - $sql = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND question_option_id='".Database::escape_string($value)."'"; - $result = Database::query($sql); - $row = Database::fetch_array($result, 'ASSOC'); - $option_value = $row['option_text']; - } else { - $option_value = 0; - if ($types[$survey_question_id] == 'open') { - $option_value = $value; - //$value = 0; - } - } - - $survey_question_answer = $value; - SurveyUtil::remove_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id); - SurveyUtil::store_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id, $value, $option_value, $survey_data); - //SurveyUtil::store_answer($user,$survey_id,$question_id, $option_id, $option_value, $survey_data); - } - } - } - } elseif ($survey_data['survey_type'] === '1') { //conditional/personality-test type surveys - // Getting all the types of the question (because of the special treatment of the score question type - $shuffle=''; - if ($survey_data['shuffle'] == '1') { - $shuffle= ' ORDER BY RAND() '; - } - $sql = "SELECT * FROM $table_survey_question - WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' - AND survey_group_pri='0' $shuffle"; - $result = Database::query($sql); + // Getting all the types of the question (because of the special treatment of the score question type + $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."'"; + $result = Database::query($sql); + + while ($row = Database::fetch_array($result, 'ASSOC')) { + $types[$row['question_id']] = $row['type']; + } + + + // Looping through all the post values + foreach ($_POST as $key => & $value) { + // If the post value key contains the string 'question' then it is an answer on a question + if (strpos($key, 'question') !== false) { + // Finding the question id by removing 'question' + $survey_question_id = str_replace('question', '', $key); + + // If the post value is an array then we have a multiple response question or a scoring question type + // remark: when it is a multiple response then the value of the array is the option_id + // when it is a scoring question then the key of the array is the option_id and the value is the value + if (is_array($value)) { + SurveyUtil::remove_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id); + foreach ($value as $answer_key => & $answer_value) { + if ($types[$survey_question_id] == 'score') { + $option_id = $answer_key; + $option_value = $answer_value; + } else { + $option_id = $answer_value; + $option_value = ''; + } + SurveyUtil::store_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id, $option_id, $option_value, $survey_data); + } + } + // All the other question types (open question, multiple choice, percentage, ...) + else { + if ($types[$survey_question_id] == 'percentage') { + $sql = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND question_option_id='".Database::escape_string($value)."'"; + $result = Database::query($sql); + $row = Database::fetch_array($result, 'ASSOC'); + $option_value = $row['option_text']; + } else { + $option_value = 0; + if ($types[$survey_question_id] == 'open') { + $option_value = $value; + //$value = 0; + } + } + + $survey_question_answer = $value; + SurveyUtil::remove_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id); + SurveyUtil::store_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id, $value, $option_value, $survey_data); + //SurveyUtil::store_answer($user,$survey_id,$question_id, $option_id, $option_value, $survey_data); + } + } + } + } elseif ($survey_data['survey_type'] === '1') { //conditional/personality-test type surveys + // Getting all the types of the question (because of the special treatment of the score question type + $shuffle=''; + if ($survey_data['shuffle'] == '1') { + $shuffle= ' ORDER BY RAND() '; + } + $sql = "SELECT * FROM $table_survey_question + WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' + AND survey_group_pri='0' $shuffle"; + $result = Database::query($sql); // There is only one question type for conditional surveys - while ($row = Database::fetch_array($result, 'ASSOC')) { - $types[$row['question_id']] = $row['type']; - } - - // Looping through all the post values - foreach ($_POST as $key => & $value) { - // If the post value key contains the string 'question' then it is an answer to a question - if (strpos($key, 'question') !== false) { - // Finding the question id by removing 'question' - $survey_question_id = str_replace('question', '', $key); - // We select the correct answer and the puntuacion - $sql = "SELECT value FROM $table_survey_question_option WHERE c_id = $course_id AND question_option_id='".Database::escape_string($value)."'"; - $result = Database::query($sql); - $row = Database::fetch_array($result, 'ASSOC'); - $option_value = $row['value']; - //$option_value = 0; - $survey_question_answer = $value; + while ($row = Database::fetch_array($result, 'ASSOC')) { + $types[$row['question_id']] = $row['type']; + } + + // Looping through all the post values + foreach ($_POST as $key => & $value) { + // If the post value key contains the string 'question' then it is an answer to a question + if (strpos($key, 'question') !== false) { + // Finding the question id by removing 'question' + $survey_question_id = str_replace('question', '', $key); + // We select the correct answer and the puntuacion + $sql = "SELECT value FROM $table_survey_question_option WHERE c_id = $course_id AND question_option_id='".Database::escape_string($value)."'"; + $result = Database::query($sql); + $row = Database::fetch_array($result, 'ASSOC'); + $option_value = $row['value']; + //$option_value = 0; + $survey_question_answer = $value; // We save the answer after making sure that a possible previous attempt is deleted - SurveyUtil::remove_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id); - SurveyUtil::store_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id, $value, $option_value, $survey_data); - //SurveyUtil::store_answer($user,$survey_id,$question_id, $option_id, $option_value, $survey_data); - } - } - } else { // In case it's another type than 0 or 1 - die(get_lang('ErrorSurveyTypeUnknown')); + SurveyUtil::remove_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id); + SurveyUtil::store_answer($survey_invitation['user'], $survey_invitation['survey_id'], $survey_question_id, $value, $option_value, $survey_data); + //SurveyUtil::store_answer($user,$survey_id,$question_id, $option_id, $option_value, $survey_data); + } + } + } else { // In case it's another type than 0 or 1 + die(get_lang('ErrorSurveyTypeUnknown')); } } @@ -254,690 +254,690 @@ check_time_availability($survey_data); // Displaying the survey introduction if (!isset($_GET['show'])) { - // The first thing we do is delete the session - unset($_SESSION['paged_questions']); - unset($_SESSION['page_questions_sec']); - $paged_questions_sec=array(); + // The first thing we do is delete the session + unset($_SESSION['paged_questions']); + unset($_SESSION['page_questions_sec']); + $paged_questions_sec=array(); if (!empty($survey_data['survey_introduction'])) { echo '
'.$survey_data['survey_introduction'].'
'; } - $limit = 0; + $limit = 0; } $user_id = api_get_user_id(); if ($user_id == 0) { - $user_id = $survey_invitation['user']; + $user_id = $survey_invitation['user']; } $user_data = UserManager :: get_user_info_by_id($user_id); if ($survey_data['form_fields']!='' && $survey_data['anonymous'] == 0 && is_array($user_data)) { - //echo '
'; print_r($survey_invitation);
-	$form_fields = explode('@', $survey_data['form_fields']);
-	$list = array();
-	foreach ($form_fields as $field) {
-		$field_value = explode(':', $field);
-		if ($field_value[1] == 1) {
-			if ($field_value[0] != '') {
-				$val = api_substr($field_value[0], 8, api_strlen($field_value[0]));
-				$list[$val] = 1;
-			}
-		}
-	}
-
-	// We use the same form as in auth/profile.php	
-	$form = new FormValidator('profile', 'post', api_get_self() . "?" . str_replace('&show_form=1', '&show_form=1', $_SERVER['QUERY_STRING']), null,
-		array('style' => 'width: 75%; float: ' . ($text_dir == 'rtl' ? 'right;' : 'left;'))
-	);
-
-	if (api_is_western_name_order()) {
-		if ($list['firstname'] == 1 ) {
-			//FIRST NAME
-			$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
-			if (api_get_setting('profile', 'name') !== 'true') {
-				$form->freeze(array('firstname'));
-			}
-			$form->applyFilter(array('firstname'), 'stripslashes');
-			$form->applyFilter(array('firstname'), 'trim');
-			$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
-		}
-		if ($list['lastname'] == 1) {
-			//	LAST NAME
-			$form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
-			if (api_get_setting('profile', 'name') !== 'true') {
-				$form->freeze(array('lastname'));
-			}
-			$form->applyFilter(array('lastname'), 'stripslashes');
-			$form->applyFilter(array('lastname'), 'trim');
-			$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
-		}
-	} else {
-		if ($list['lastname'] == 1) {
-			//	LAST NAME
-			$form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
-			if (api_get_setting('profile', 'name') !== 'true') {
-				$form->freeze(array('lastname'));
-			}
-			$form->applyFilter(array('lastname'), 'stripslashes');
-			$form->applyFilter(array('lastname'), 'trim');
-			$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
-		}
-		if ($list['firstname'] == 1 ) {
-			//FIRST NAME
-			$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
-			if (api_get_setting('profile', 'name') !== 'true') {
-				$form->freeze(array('firstname'));
-			}
-			$form->applyFilter(array('firstname'), 'stripslashes');
-			$form->applyFilter(array('firstname'), 'trim');
-			$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
-		}
-	}
-
-	if ($list['official_code'] == 1) {
-		//	OFFICIAL CODE
-		if (CONFVAL_ASK_FOR_OFFICIAL_CODE) {
-			$form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40));
-			if (api_get_setting('profile', 'officialcode') !== 'true') {
-				$form->freeze('official_code');
-			}
-			$form->applyFilter('official_code', 'stripslashes');
-			$form->applyFilter('official_code', 'trim');
-			if (api_get_setting('registration', 'officialcode') == 'true' && api_get_setting('profile', 'officialcode') == 'true') {
-				$form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
-			}
-		}
-	}
-	if ($list['email'] == 1) {
-		//	EMAIL
-		$form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
-		if (api_get_setting('profile', 'email') !== 'true') {
-			$form->freeze('email');
-		}
-		$form->applyFilter('email', 'stripslashes');
-		$form->applyFilter('email', 'trim');
-		if (api_get_setting('registration', 'email') == 'true') {
-			$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
-		}
-		$form->addRule('email', get_lang('EmailWrong'), 'email');
-	}
-
-	if ($list['phone'] == 1) {
-		//	PHONE
-		$form->addElement('text', 'phone', get_lang('phone'), array('size' => 20));
-		if (api_get_setting('profile', 'phone') !== 'true') {
-			$form->freeze('phone');
-		}
-		$form->applyFilter('phone', 'stripslashes');
-		$form->applyFilter('phone', 'trim');
-		if (api_get_setting('profile', 'phone') == 'true') {
-			$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
-		}
-	}
-
-	if ($list['language'] == 1) {
-		//	LANGUAGE
-		$form->addElement('select_language', 'language', get_lang('Language'));
-		if (api_get_setting('profile', 'language') !== 'true') {
-			$form->freeze('language');
-		}
-		if (api_get_setting('profile', 'language') == 'true') {
-			$form->addRule('language', get_lang('ThisFieldIsRequired'), 'required');
-		}
-	}
-
-	// EXTRA FIELDS	
-	$extra_data = UserManager :: get_extra_user_data($user_id, true);    
+    //echo '
'; print_r($survey_invitation);
+    $form_fields = explode('@', $survey_data['form_fields']);
+    $list = array();
+    foreach ($form_fields as $field) {
+        $field_value = explode(':', $field);
+        if ($field_value[1] == 1) {
+            if ($field_value[0] != '') {
+                $val = api_substr($field_value[0], 8, api_strlen($field_value[0]));
+                $list[$val] = 1;
+            }
+        }
+    }
+
+    // We use the same form as in auth/profile.php    
+    $form = new FormValidator('profile', 'post', api_get_self() . "?" . str_replace('&show_form=1', '&show_form=1', $_SERVER['QUERY_STRING']), null,
+        array('style' => 'width: 75%; float: ' . ($text_dir == 'rtl' ? 'right;' : 'left;'))
+    );
+
+    if (api_is_western_name_order()) {
+        if ($list['firstname'] == 1 ) {
+            //FIRST NAME
+            $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+            if (api_get_setting('profile', 'name') !== 'true') {
+                $form->freeze(array('firstname'));
+            }
+            $form->applyFilter(array('firstname'), 'stripslashes');
+            $form->applyFilter(array('firstname'), 'trim');
+            $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+        }
+        if ($list['lastname'] == 1) {
+            //    LAST NAME
+            $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
+            if (api_get_setting('profile', 'name') !== 'true') {
+                $form->freeze(array('lastname'));
+            }
+            $form->applyFilter(array('lastname'), 'stripslashes');
+            $form->applyFilter(array('lastname'), 'trim');
+            $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
+        }
+    } else {
+        if ($list['lastname'] == 1) {
+            //    LAST NAME
+            $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
+            if (api_get_setting('profile', 'name') !== 'true') {
+                $form->freeze(array('lastname'));
+            }
+            $form->applyFilter(array('lastname'), 'stripslashes');
+            $form->applyFilter(array('lastname'), 'trim');
+            $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
+        }
+        if ($list['firstname'] == 1 ) {
+            //FIRST NAME
+            $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+            if (api_get_setting('profile', 'name') !== 'true') {
+                $form->freeze(array('firstname'));
+            }
+            $form->applyFilter(array('firstname'), 'stripslashes');
+            $form->applyFilter(array('firstname'), 'trim');
+            $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+        }
+    }
+
+    if ($list['official_code'] == 1) {
+        //    OFFICIAL CODE
+        if (CONFVAL_ASK_FOR_OFFICIAL_CODE) {
+            $form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40));
+            if (api_get_setting('profile', 'officialcode') !== 'true') {
+                $form->freeze('official_code');
+            }
+            $form->applyFilter('official_code', 'stripslashes');
+            $form->applyFilter('official_code', 'trim');
+            if (api_get_setting('registration', 'officialcode') == 'true' && api_get_setting('profile', 'officialcode') == 'true') {
+                $form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
+            }
+        }
+    }
+    if ($list['email'] == 1) {
+        //    EMAIL
+        $form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
+        if (api_get_setting('profile', 'email') !== 'true') {
+            $form->freeze('email');
+        }
+        $form->applyFilter('email', 'stripslashes');
+        $form->applyFilter('email', 'trim');
+        if (api_get_setting('registration', 'email') == 'true') {
+            $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
+        }
+        $form->addRule('email', get_lang('EmailWrong'), 'email');
+    }
+
+    if ($list['phone'] == 1) {
+        //    PHONE
+        $form->addElement('text', 'phone', get_lang('phone'), array('size' => 20));
+        if (api_get_setting('profile', 'phone') !== 'true') {
+            $form->freeze('phone');
+        }
+        $form->applyFilter('phone', 'stripslashes');
+        $form->applyFilter('phone', 'trim');
+        if (api_get_setting('profile', 'phone') == 'true') {
+            $form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
+        }
+    }
+
+    if ($list['language'] == 1) {
+        //    LANGUAGE
+        $form->addElement('select_language', 'language', get_lang('Language'));
+        if (api_get_setting('profile', 'language') !== 'true') {
+            $form->freeze('language');
+        }
+        if (api_get_setting('profile', 'language') == 'true') {
+            $form->addRule('language', get_lang('ThisFieldIsRequired'), 'required');
+        }
+    }
+
+    // EXTRA FIELDS    
+    $extra_data = UserManager :: get_extra_user_data($user_id, true);    
     UserManager::set_extra_fields_in_form($form, $extra_data, 'profile');
     
-	$form->addElement('style_submit_button', '', get_lang('Next'), array('class' => 'next'));
-	$user_data = array_merge($user_data, $extra_data);
-	$form->setDefaults($user_data);
+    $form->addElement('style_submit_button', '', get_lang('Next'), array('class' => 'next'));
+    $user_data = array_merge($user_data, $extra_data);
+    $form->setDefaults($user_data);
 }
 
 if ($survey_data['form_fields'] && $survey_data['anonymous'] == 0 && is_array($user_data) && !isset($_GET['show'])) {
-	if ($form->validate()) {
-		$user_data = $form->exportValues();
-		if (is_array($user_data)) {
-			if (count($user_data) > 0) {
-				$extras = array();
-				// Build SQL query
-				$sql = "UPDATE $table_user SET";
-				foreach ($user_data as $key => $value) {
-					if (substr($key, 0, 6) == 'extra_') { //an extra field
-						$extras[substr($key, 6)] = $value;
-					} else {
-						$sql .= " $key = '" . Database :: escape_string($value) . "',";
-					}
-				}
-				// Remove trailing , from the query we have so far
-				$sql = rtrim($sql, ',');
-				$sql .= " WHERE user_id  = '" . $user_id . "'";
-				Database::query($sql);
-				// Update the extra fields
-				if (is_array($extras)) {
-					foreach ($extras as $key => $value) {
-						$myres = UserManager :: update_extra_field_value($user_id, $key, $value);
-					}
-				}
-				echo '
' . get_lang('InformationUpdated') . ' ' . get_lang('PleaseFillSurvey') . '
'; - } - } - //$_GET['show_form'] = 0; - //$show_form = 0; - $_GET['show'] = 0; - $show = 0; - // We unset the sessions - unset($_SESSION['paged_questions']); - unset($_SESSION['page_questions_sec']); - $paged_questions_sec = array(); - - } - //elseif ($_GET['show_form'] == 1) { // Displaying the field - else { - echo '
' . get_lang('UpdateInformation') . '
'; - // We unset the sessions - unset($_SESSION['paged_questions']); - unset($_SESSION['page_questions_sec']); - $paged_questions_sec = array(); - $form->display(); - } + if ($form->validate()) { + $user_data = $form->exportValues(); + if (is_array($user_data)) { + if (count($user_data) > 0) { + $extras = array(); + // Build SQL query + $sql = "UPDATE $table_user SET"; + foreach ($user_data as $key => $value) { + if (substr($key, 0, 6) == 'extra_') { //an extra field + $extras[substr($key, 6)] = $value; + } else { + $sql .= " $key = '" . Database :: escape_string($value) . "',"; + } + } + // Remove trailing , from the query we have so far + $sql = rtrim($sql, ','); + $sql .= " WHERE user_id = '" . $user_id . "'"; + Database::query($sql); + // Update the extra fields + if (is_array($extras)) { + foreach ($extras as $key => $value) { + $myres = UserManager :: update_extra_field_value($user_id, $key, $value); + } + } + echo '
' . get_lang('InformationUpdated') . ' ' . get_lang('PleaseFillSurvey') . '
'; + } + } + //$_GET['show_form'] = 0; + //$show_form = 0; + $_GET['show'] = 0; + $show = 0; + // We unset the sessions + unset($_SESSION['paged_questions']); + unset($_SESSION['page_questions_sec']); + $paged_questions_sec = array(); + + } + //elseif ($_GET['show_form'] == 1) { // Displaying the field + else { + echo '
' . get_lang('UpdateInformation') . '
'; + // We unset the sessions + unset($_SESSION['paged_questions']); + unset($_SESSION['page_questions_sec']); + $paged_questions_sec = array(); + $form->display(); + } } // Displaying the survey thanks message -if (isset($_POST['finish_survey'])) { +if (isset($_POST['finish_survey'])) { Display::display_confirmation_message(get_lang('SurveyFinished')); echo $survey_data['survey_thanks']; - survey_manager::update_survey_answered($survey_data['survey_id'], $survey_invitation['user'], $survey_invitation['survey_code']); - unset($_SESSION['paged_questions']); - unset($_SESSION['page_questions_sec']); - Display :: display_footer(); - exit(); + survey_manager::update_survey_answered($survey_data['survey_id'], $survey_invitation['user'], $survey_invitation['survey_code']); + unset($_SESSION['paged_questions']); + unset($_SESSION['page_questions_sec']); + Display :: display_footer(); + exit(); } // Sets the random questions $shuffle = ''; if ($survey_data['shuffle'] == 1) { - $shuffle = ' BY RAND() '; + $shuffle = ' BY RAND() '; } if (isset($_GET['show']) || isset($_POST['personality'])) { - // Getting all the questions for this page and add them to a multidimensional array where the first index is the page. - // As long as there is no pagebreak fount we keep adding questions to the page - $questions_displayed = array(); - $counter = 0; + // Getting all the questions for this page and add them to a multidimensional array where the first index is the page. + // As long as there is no pagebreak fount we keep adding questions to the page + $questions_displayed = array(); + $counter = 0; $paged_questions = array(); - // If non-conditional survey - if ($survey_data['survey_type'] === '0') { - if (empty($_SESSION['paged_questions'])) { - $sql = "SELECT * FROM $table_survey_question - WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' - ORDER BY sort ASC"; - $result = Database::query($sql); - while ($row = Database::fetch_array($result, 'ASSOC')) { - if ($row['type'] == 'pagebreak') { - $counter++; - } else { - // ids from question of the current survey - $paged_questions[$counter][] = $row['question_id']; - } - } + // If non-conditional survey + if ($survey_data['survey_type'] === '0') { + if (empty($_SESSION['paged_questions'])) { + $sql = "SELECT * FROM $table_survey_question + WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' + ORDER BY sort ASC"; + $result = Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + if ($row['type'] == 'pagebreak') { + $counter++; + } else { + // ids from question of the current survey + $paged_questions[$counter][] = $row['question_id']; + } + } $_SESSION['paged_questions'] = $paged_questions; } else { - $paged_questions = $_SESSION['paged_questions']; + $paged_questions = $_SESSION['paged_questions']; } $course_id = api_get_course_int_id(); - if (key_exists($_GET['show'], $paged_questions)) { - if (isset($_GET['user_id'])) { - - // Get the user into survey answer table (user or anonymus) - $my_user_id=($survey_data['anonymous']==1) ? $_SESSION['surveyuser'] :api_get_user_id(); - - $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri, - survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value, - survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort - FROM $table_survey_question survey_question - LEFT JOIN $table_survey_question_option survey_question_option - ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id - WHERE survey_question.survey_id = '" . Database :: escape_string($survey_invitation['survey_id']) . "' - AND survey_question.question_id NOT IN (SELECT sa.question_id FROM ".$table_survey_answer." sa WHERE sa.user='".$my_user_id."') AND - survey_question.c_id = $course_id - ORDER BY survey_question.sort, survey_question_option.sort ASC"; - } else { - $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri, - survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value, - survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort - FROM $table_survey_question survey_question - LEFT JOIN $table_survey_question_option survey_question_option - ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id - WHERE survey_question.survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' AND - survey_question.question_id IN (".implode(',',$paged_questions[$_GET['show']]).") AND - survey_question.c_id = $course_id - ORDER BY survey_question.sort, survey_question_option.sort ASC"; - } - - $result = Database::query($sql); - $question_counter_max = Database::num_rows($result); - $counter = 0; - $limit = 0; - $questions = array(); - - while ($row = Database :: fetch_array($result, 'ASSOC')) { - - // If the type is not a pagebreak we store it in the $questions array - if ($row['type'] != 'pagebreak') { - $questions[$row['sort']]['question_id'] = $row['question_id']; - $questions[$row['sort']]['survey_id'] = $row['survey_id']; - $questions[$row['sort']]['survey_question'] = $row['survey_question']; - $questions[$row['sort']]['display'] = $row['display']; - $questions[$row['sort']]['type'] = $row['type']; - $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text']; - $questions[$row['sort']]['maximum_score'] = $row['max_value']; - } - // If the type is a pagebreak we are finished loading the questions for this page - else { - break; - } - $counter++; - } - } - } elseif ($survey_data['survey_type'] === '1') { - $my_survey_id=Database::escape_string($survey_invitation['survey_id']); - $current_user = Database::escape_string($survey_invitation['user']); - - if (isset($_POST['personality'])) { - // Compute the results to get the 3 groups nearest to the user's personality - if ($shuffle == '') { - $order = 'BY sort ASC '; - } else { - $order = $shuffle; - } - - $answer_list = array(); - - // Get current user results - $results = array(); - $sql = "SELECT survey_group_pri, user, SUM(value) as value - FROM $table_survey_answer as survey_answer INNER JOIN $table_survey_question as survey_question - ON (survey_question.question_id = survey_answer.question_id) - WHERE survey_answer.survey_id='".$my_survey_id."' AND - survey_answer.user='".$current_user."' AND - survey_answer.c_id = $course_id AND - survey_question.c_id = $course_id AND - GROUP BY survey_group_pri - ORDER BY survey_group_pri - "; - - $result = Database::query($sql); - while ($row = Database :: fetch_array($result)) { - $answer_list['value'] = $row['value']; - $answer_list['group'] = $row['survey_group_pri']; - $results[] = $answer_list; - } - - //echo '
'; print_r($results); echo '
'; - - // Get the total score for each group of questions - $totals = array(); - $sql = "SELECT SUM(temp.value) as value, temp.survey_group_pri FROM - ( - SELECT MAX(value) as value, survey_group_pri, survey_question.question_id - FROM $table_survey_question as survey_question - INNER JOIN $table_survey_question_option as survey_question_option - ON (survey_question.question_id = survey_question_option.question_id) - WHERE survey_question.survey_id='".$my_survey_id."' AND - survey_question.c_id = $course_id AND - survey_question_option.c_id = $course_id AND - survey_group_sec1='0' AND - survey_group_sec2='0' - GROUP BY survey_group_pri, survey_question.question_id + if (key_exists($_GET['show'], $paged_questions)) { + if (isset($_GET['user_id'])) { + + // Get the user into survey answer table (user or anonymus) + $my_user_id=($survey_data['anonymous']==1) ? $_SESSION['surveyuser'] :api_get_user_id(); + + $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri, + survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value, + survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort + FROM $table_survey_question survey_question + LEFT JOIN $table_survey_question_option survey_question_option + ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id + WHERE survey_question.survey_id = '" . Database :: escape_string($survey_invitation['survey_id']) . "' + AND survey_question.question_id NOT IN (SELECT sa.question_id FROM ".$table_survey_answer." sa WHERE sa.user='".$my_user_id."') AND + survey_question.c_id = $course_id + ORDER BY survey_question.sort, survey_question_option.sort ASC"; + } else { + $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri, + survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value, + survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort + FROM $table_survey_question survey_question + LEFT JOIN $table_survey_question_option survey_question_option + ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id + WHERE survey_question.survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' AND + survey_question.question_id IN (".implode(',',$paged_questions[$_GET['show']]).") AND + survey_question.c_id = $course_id + ORDER BY survey_question.sort, survey_question_option.sort ASC"; + } + + $result = Database::query($sql); + $question_counter_max = Database::num_rows($result); + $counter = 0; + $limit = 0; + $questions = array(); + + while ($row = Database :: fetch_array($result, 'ASSOC')) { + + // If the type is not a pagebreak we store it in the $questions array + if ($row['type'] != 'pagebreak') { + $questions[$row['sort']]['question_id'] = $row['question_id']; + $questions[$row['sort']]['survey_id'] = $row['survey_id']; + $questions[$row['sort']]['survey_question'] = $row['survey_question']; + $questions[$row['sort']]['display'] = $row['display']; + $questions[$row['sort']]['type'] = $row['type']; + $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text']; + $questions[$row['sort']]['maximum_score'] = $row['max_value']; + } + // If the type is a pagebreak we are finished loading the questions for this page + else { + break; + } + $counter++; + } + } + } elseif ($survey_data['survey_type'] === '1') { + $my_survey_id=Database::escape_string($survey_invitation['survey_id']); + $current_user = Database::escape_string($survey_invitation['user']); + + if (isset($_POST['personality'])) { + // Compute the results to get the 3 groups nearest to the user's personality + if ($shuffle == '') { + $order = 'BY sort ASC '; + } else { + $order = $shuffle; + } + + $answer_list = array(); + + // Get current user results + $results = array(); + $sql = "SELECT survey_group_pri, user, SUM(value) as value + FROM $table_survey_answer as survey_answer INNER JOIN $table_survey_question as survey_question + ON (survey_question.question_id = survey_answer.question_id) + WHERE survey_answer.survey_id='".$my_survey_id."' AND + survey_answer.user='".$current_user."' AND + survey_answer.c_id = $course_id AND + survey_question.c_id = $course_id AND + GROUP BY survey_group_pri + ORDER BY survey_group_pri + "; + + $result = Database::query($sql); + while ($row = Database :: fetch_array($result)) { + $answer_list['value'] = $row['value']; + $answer_list['group'] = $row['survey_group_pri']; + $results[] = $answer_list; + } + + //echo '
'; print_r($results); echo '
'; + + // Get the total score for each group of questions + $totals = array(); + $sql = "SELECT SUM(temp.value) as value, temp.survey_group_pri FROM + ( + SELECT MAX(value) as value, survey_group_pri, survey_question.question_id + FROM $table_survey_question as survey_question + INNER JOIN $table_survey_question_option as survey_question_option + ON (survey_question.question_id = survey_question_option.question_id) + WHERE survey_question.survey_id='".$my_survey_id."' AND + survey_question.c_id = $course_id AND + survey_question_option.c_id = $course_id AND + survey_group_sec1='0' AND + survey_group_sec2='0' + GROUP BY survey_group_pri, survey_question.question_id ) as temp - GROUP BY temp.survey_group_pri - ORDER BY temp.survey_group_pri"; - - $result = Database::query($sql); - while ($row = Database::fetch_array($result)) { - $list['value'] = $row['value']; - $list['group'] = $row['survey_group_pri']; - $totals[] = $list; - } - //echo '
'; print_r($totals);
+                    GROUP BY temp.survey_group_pri
+                    ORDER BY temp.survey_group_pri";
+
+            $result = Database::query($sql);
+            while ($row = Database::fetch_array($result)) {
+                $list['value'] = $row['value'];
+                $list['group'] = $row['survey_group_pri'];
+                $totals[] = $list;
+            }
+            //echo '
'; print_r($totals);
 
-			$final_results = array();
+            $final_results = array();
 
             // Get a percentage score for each group
-			for ($i = 0; $i < count($totals); $i++) {
-				for ($j = 0; $j < count($results); $j++) {
-					if ($totals[$i]['group'] == $results[$j]['group']) {
-						$group = $totals[$i]['group'];
-						$porcen = ($results[$j]['value'] / $totals[$i]['value']);
-						$final_results[$group] = $porcen;
-					}
-				}
-			}
-
-			// Sort the results by score (getting a list of group IDs by score into $groups)
-			arsort($final_results);
-			$groups=array_keys($final_results);		
-			$result = array();
-			$count_result = 0;
-			foreach ($final_results as $key => & $sub_result) {
-				$result[] = array('group' => $key, 'value' => $sub_result);
-				$count_result++;
-			}
-
-			/*
-			//i.e 70% - 70% -70% 70%  $equal_count =3
-			while (1) {
-				if ($result[$i]['value']  == $result[$i+1]['value']) {
-					$equal_count++;
-				} else {
-					break;
-				}
-				$i++;
-			}
-			echo 'eq'. $equal_count;
-			echo '
'; - if ($equal_count == 0) { - //i.e 70% 70% -60% 60% $equal_count = 1 only we get the first 2 options - if (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) { - $group_cant = 1; - } else { - // By default we chose the highest 3 - $group_cant=2; - } - } elseif ($equal_count == 2) { - $group_cant = 2; - } else { - $group_cant = -1; - } - */ - - // i.e 70% - 70% -70% 70% $equal_count =3 - - $i = 0; - $group_cant = 0; - $equal_count = 0; - // This is the case if the user does not select any question - if ($count_result > 0) { - // Count the number of scores equal to the first - while (1) { - if ($result[$i]['value'] == $result[$i + 1]['value']) { - $equal_count++; - } else { - break; - } - $i++; - } - } else { - // We force the exit of the survey undeterminated - $equal_count=10; - } + for ($i = 0; $i < count($totals); $i++) { + for ($j = 0; $j < count($results); $j++) { + if ($totals[$i]['group'] == $results[$j]['group']) { + $group = $totals[$i]['group']; + $porcen = ($results[$j]['value'] / $totals[$i]['value']); + $final_results[$group] = $porcen; + } + } + } + + // Sort the results by score (getting a list of group IDs by score into $groups) + arsort($final_results); + $groups=array_keys($final_results); + $result = array(); + $count_result = 0; + foreach ($final_results as $key => & $sub_result) { + $result[] = array('group' => $key, 'value' => $sub_result); + $count_result++; + } + + /* + //i.e 70% - 70% -70% 70% $equal_count =3 + while (1) { + if ($result[$i]['value'] == $result[$i+1]['value']) { + $equal_count++; + } else { + break; + } + $i++; + } + echo 'eq'. $equal_count; + echo '
'; + if ($equal_count == 0) { + //i.e 70% 70% -60% 60% $equal_count = 1 only we get the first 2 options + if (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) { + $group_cant = 1; + } else { + // By default we chose the highest 3 + $group_cant=2; + } + } elseif ($equal_count == 2) { + $group_cant = 2; + } else { + $group_cant = -1; + } + */ + + // i.e 70% - 70% -70% 70% $equal_count =3 + + $i = 0; + $group_cant = 0; + $equal_count = 0; + // This is the case if the user does not select any question + if ($count_result > 0) { + // Count the number of scores equal to the first + while (1) { + if ($result[$i]['value'] == $result[$i + 1]['value']) { + $equal_count++; + } else { + break; + } + $i++; + } + } else { + // We force the exit of the survey undeterminated + $equal_count=10; + } // If we have only 3 or less equal scores (i.e. 0,1 or 2 equalities), then we can use the three first groups - if ($equal_count < 4) { - // If there is one or less score equalities - if ($equal_count === 0 || $equal_count === 1) { - // i.e 70% - 70% -60% - 60% $equal_count = 1 we only get the first 2 options - if (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) { - $group_cant = 1; - } - // i.e 70% - 70% -0% - 0% - $equal_count = 0 we only get the first 2 options - /*elseif (($result[0]['value'] == $result[1]['value']) && ($result[1]['value'] != $result[2]['value'])) { - $group_cant = 0; - }*/ - /* - // i.e 70% - 70% -60% - 60% $equal_count = 0 we only get the first 2 options - elseif (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) { - $group_cant = 0; - }*/ - // i.e. 80% - 70% - 70% - 70% - elseif (($result[0]['value'] != $result[1]['value']) && ($result[1]['value'] == $result[2]['value']) && ($result[2]['value'] == $result[3]['value'])) { - $group_cant = 0; - } else { - // i.e. 80% - 70% - 70% - 50 - // i.e. 80% - 80% - 70% - 50 - - // By default we choose the highest 3 - $group_cant = 2; - } - } else { - // If there are two score equalities - $group_cant = $equal_count; - } - - //@todo Translate these comments. - // conditional_status - // 0 no determinado - // 1 determinado - // 2 un solo valor - // 3 valores iguales - - if ($group_cant > 0) { - //echo '$equal_count'.$group_cant; - // We only get highest 3 - $secondary = ''; - $combi = ''; - - for ($i = 0; $i <= $group_cant; $i++) { - $group1 = $groups[$i]; - $group2 = $groups[$i + 1]; - // Here we made all the posibilities with the 3 groups - if ($group_cant == 2 && $i == $group_cant) { - $group2 = $groups[0]; - $secondary .= " OR ( survey_group_sec1 = '$group1' AND survey_group_sec2 = '$group2') "; - $secondary .= " OR ( survey_group_sec1 = '$group2' AND survey_group_sec2 = '$group1' ) "; - $combi.= $group1.' - '.$group2." or ".$group2.' - '.$group1.'
'; - } else { - if ($i != 0) { - $secondary .= " OR ( survey_group_sec1 = '$group1' AND survey_group_sec2 = '$group2') "; - $secondary .= " OR ( survey_group_sec1 = '$group2' AND survey_group_sec2 = '$group1' ) "; - $combi.= $group1.' - '.$group2." or ".$group2.' - '.$group1.'
'; - } else { - $secondary .= " ( survey_group_sec1 = '$group1' AND survey_group_sec2 = '$group2') "; - $secondary .= " OR ( survey_group_sec1 = '$group2' AND survey_group_sec2 = '$group1' ) "; - $combi.= $group1.' - '.$group2." or ".$group2.' - '.$group1.'
'; - } - } - } - /* + if ($equal_count < 4) { + // If there is one or less score equalities + if ($equal_count === 0 || $equal_count === 1) { + // i.e 70% - 70% -60% - 60% $equal_count = 1 we only get the first 2 options + if (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) { + $group_cant = 1; + } + // i.e 70% - 70% -0% - 0% - $equal_count = 0 we only get the first 2 options + /*elseif (($result[0]['value'] == $result[1]['value']) && ($result[1]['value'] != $result[2]['value'])) { + $group_cant = 0; + }*/ + /* + // i.e 70% - 70% -60% - 60% $equal_count = 0 we only get the first 2 options + elseif (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) { + $group_cant = 0; + }*/ + // i.e. 80% - 70% - 70% - 70% + elseif (($result[0]['value'] != $result[1]['value']) && ($result[1]['value'] == $result[2]['value']) && ($result[2]['value'] == $result[3]['value'])) { + $group_cant = 0; + } else { + // i.e. 80% - 70% - 70% - 50 + // i.e. 80% - 80% - 70% - 50 + + // By default we choose the highest 3 + $group_cant = 2; + } + } else { + // If there are two score equalities + $group_cant = $equal_count; + } + + //@todo Translate these comments. + // conditional_status + // 0 no determinado + // 1 determinado + // 2 un solo valor + // 3 valores iguales + + if ($group_cant > 0) { + //echo '$equal_count'.$group_cant; + // We only get highest 3 + $secondary = ''; + $combi = ''; + + for ($i = 0; $i <= $group_cant; $i++) { + $group1 = $groups[$i]; + $group2 = $groups[$i + 1]; + // Here we made all the posibilities with the 3 groups + if ($group_cant == 2 && $i == $group_cant) { + $group2 = $groups[0]; + $secondary .= " OR ( survey_group_sec1 = '$group1' AND survey_group_sec2 = '$group2') "; + $secondary .= " OR ( survey_group_sec1 = '$group2' AND survey_group_sec2 = '$group1' ) "; + $combi.= $group1.' - '.$group2." or ".$group2.' - '.$group1.'
'; + } else { + if ($i != 0) { + $secondary .= " OR ( survey_group_sec1 = '$group1' AND survey_group_sec2 = '$group2') "; + $secondary .= " OR ( survey_group_sec1 = '$group2' AND survey_group_sec2 = '$group1' ) "; + $combi.= $group1.' - '.$group2." or ".$group2.' - '.$group1.'
'; + } else { + $secondary .= " ( survey_group_sec1 = '$group1' AND survey_group_sec2 = '$group2') "; + $secondary .= " OR ( survey_group_sec1 = '$group2' AND survey_group_sec2 = '$group1' ) "; + $combi.= $group1.' - '.$group2." or ".$group2.' - '.$group1.'
'; + } + } + } + /* echo '
';
                     echo 'Pair of Groups 

'; - echo $combi; - echo '
'; - */ - // Create the new select with the questions from the secondary phase - if (empty($_SESSION['page_questions_sec']) && !is_array($_SESSION['page_questions_sec']) && count($_SESSION['page_questions_sec'] == 0)) { - - $sql = "SELECT * FROM $table_survey_question - WHERE c_id = $course_id AND survey_id = '".$my_survey_id."' - AND ($secondary ) - ORDER BY sort ASC"; - $result = Database::query($sql); - $counter = 0; - while ($row = Database::fetch_array($result, 'ASSOC')) { - if ($survey_data['one_question_per_page'] == 1) { - $paged_questions_sec[$counter][] = $row['question_id']; - $counter++; - } elseif ($row['type'] == 'pagebreak') { - $counter++; - } else { - // ids from question of the current survey - $paged_questions_sec[$counter][] = $row['question_id']; - } - } + echo $combi; + echo '
'; + */ + // Create the new select with the questions from the secondary phase + if (empty($_SESSION['page_questions_sec']) && !is_array($_SESSION['page_questions_sec']) && count($_SESSION['page_questions_sec'] == 0)) { + + $sql = "SELECT * FROM $table_survey_question + WHERE c_id = $course_id AND survey_id = '".$my_survey_id."' + AND ($secondary ) + ORDER BY sort ASC"; + $result = Database::query($sql); + $counter = 0; + while ($row = Database::fetch_array($result, 'ASSOC')) { + if ($survey_data['one_question_per_page'] == 1) { + $paged_questions_sec[$counter][] = $row['question_id']; + $counter++; + } elseif ($row['type'] == 'pagebreak') { + $counter++; + } else { + // ids from question of the current survey + $paged_questions_sec[$counter][] = $row['question_id']; + } + } $_SESSION['paged_questions_sec'] = $paged_questions_sec; } else { - $paged_questions_sec = $_SESSION['paged_questions_sec']; + $paged_questions_sec = $_SESSION['paged_questions_sec']; } - //print_r($paged_questions_sec); + //print_r($paged_questions_sec); $paged_questions = $_SESSION['paged_questions']; // For the sake of pages counting //$paged_questions = $paged_questions_sec; // For the sake of pages counting coming up at display time... - if ($shuffle == '') { - $shuffle = ' BY survey_question.sort, survey_question_option.sort ASC '; - } - - //$val = 0; - //if ($survey_data['one_question_per_page'] == 0) { - $val = (int)$_POST['personality']; - //} - //echo '
'; print_r($paged_questions_sec); echo '
'; - if (is_array($paged_questions_sec)) { - - $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri, - survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value, - survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort - FROM $table_survey_question survey_question - LEFT JOIN $table_survey_question_option survey_question_option - ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id - WHERE survey_question.survey_id = '".$my_survey_id."' AND - survey_question.c_id = $course_id AND - survey_question.question_id IN (".implode(',',$paged_questions_sec[$val]).") - ORDER $shuffle "; - - $result = Database::query($sql); - $question_counter_max = Database::num_rows($result); - $counter = 0; - $limit = 0; - $questions = array(); - while ($row = Database::fetch_array($result, 'ASSOC')) { - // If the type is not a pagebreak we store it in the $questions array - if ($row['type'] != 'pagebreak') { - $questions[$row['sort']]['question_id'] = $row['question_id']; - $questions[$row['sort']]['survey_id'] = $row['survey_id']; - $questions[$row['sort']]['survey_question'] = $row['survey_question']; - $questions[$row['sort']]['display'] = $row['display']; - $questions[$row['sort']]['type'] = $row['type']; - $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text']; - $questions[$row['sort']]['maximum_score'] = $row['max_value']; - // Personality params - $questions[$row['sort']]['survey_group_sec1'] = $row['survey_group_sec1']; - $questions[$row['sort']]['survey_group_sec2'] = $row['survey_group_sec2']; - $questions[$row['sort']]['survey_group_pri'] = $row['survey_group_pri']; - } - // If the type is a pagebreak we are finished loading the questions for this page - else { - break; - } - $counter++; - } - } else { - echo get_lang('SurveyUndetermined'); - } - } else { - echo get_lang('SurveyUndetermined'); - } - } else { - echo get_lang('SurveyUndetermined'); - } - } else { - // We need this variable only in the 2nd set of questions when personality is set. - unset($_SESSION['page_questions_sec']); - $paged_questions_sec=array(); - - // Only the questions from the basic group - // the 50 questions A B C D E F G - $order_sql = $shuffle; - if ($shuffle == '') { - $order_sql=' BY question_id '; - } + if ($shuffle == '') { + $shuffle = ' BY survey_question.sort, survey_question_option.sort ASC '; + } + + //$val = 0; + //if ($survey_data['one_question_per_page'] == 0) { + $val = (int)$_POST['personality']; + //} + //echo '
'; print_r($paged_questions_sec); echo '
'; + if (is_array($paged_questions_sec)) { + + $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri, + survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value, + survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort + FROM $table_survey_question survey_question + LEFT JOIN $table_survey_question_option survey_question_option + ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id + WHERE survey_question.survey_id = '".$my_survey_id."' AND + survey_question.c_id = $course_id AND + survey_question.question_id IN (".implode(',',$paged_questions_sec[$val]).") + ORDER $shuffle "; + + $result = Database::query($sql); + $question_counter_max = Database::num_rows($result); + $counter = 0; + $limit = 0; + $questions = array(); + while ($row = Database::fetch_array($result, 'ASSOC')) { + // If the type is not a pagebreak we store it in the $questions array + if ($row['type'] != 'pagebreak') { + $questions[$row['sort']]['question_id'] = $row['question_id']; + $questions[$row['sort']]['survey_id'] = $row['survey_id']; + $questions[$row['sort']]['survey_question'] = $row['survey_question']; + $questions[$row['sort']]['display'] = $row['display']; + $questions[$row['sort']]['type'] = $row['type']; + $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text']; + $questions[$row['sort']]['maximum_score'] = $row['max_value']; + // Personality params + $questions[$row['sort']]['survey_group_sec1'] = $row['survey_group_sec1']; + $questions[$row['sort']]['survey_group_sec2'] = $row['survey_group_sec2']; + $questions[$row['sort']]['survey_group_pri'] = $row['survey_group_pri']; + } + // If the type is a pagebreak we are finished loading the questions for this page + else { + break; + } + $counter++; + } + } else { + echo get_lang('SurveyUndetermined'); + } + } else { + echo get_lang('SurveyUndetermined'); + } + } else { + echo get_lang('SurveyUndetermined'); + } + } else { + // We need this variable only in the 2nd set of questions when personality is set. + unset($_SESSION['page_questions_sec']); + $paged_questions_sec=array(); + + // Only the questions from the basic group + // the 50 questions A B C D E F G + $order_sql = $shuffle; + if ($shuffle == '') { + $order_sql=' BY question_id '; + } if (empty($_SESSION['paged_questions'])) { - $sql = "SELECT * FROM $table_survey_question - WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' - AND survey_group_sec1='0' AND survey_group_sec2='0' - ORDER ".$order_sql." "; - //echo '
'; echo '
'; - $result = Database::query($sql); - $counter = 0; - while ($row = Database::fetch_array($result, 'ASSOC')) { - if ($survey_data['one_question_per_page'] == 1) { - $paged_questions[$counter][] = $row['question_id']; - $counter++; - } else { - if ($row['type'] == 'pagebreak') { - $counter++; - } else { - // ids from question of the current survey - $paged_questions[$counter][] = $row['question_id']; - } - } - } + $sql = "SELECT * FROM $table_survey_question + WHERE c_id = $course_id AND survey_id = '".Database::escape_string($survey_invitation['survey_id'])."' + AND survey_group_sec1='0' AND survey_group_sec2='0' + ORDER ".$order_sql." "; + //echo '
'; echo '
'; + $result = Database::query($sql); + $counter = 0; + while ($row = Database::fetch_array($result, 'ASSOC')) { + if ($survey_data['one_question_per_page'] == 1) { + $paged_questions[$counter][] = $row['question_id']; + $counter++; + } else { + if ($row['type'] == 'pagebreak') { + $counter++; + } else { + // ids from question of the current survey + $paged_questions[$counter][] = $row['question_id']; + } + } + } $_SESSION['paged_questions'] = $paged_questions; } else { - $paged_questions = $_SESSION['paged_questions']; + $paged_questions = $_SESSION['paged_questions']; } - //print_r($paged_questions); //print_r($paged_questions); - //if (key_exists($_GET['show'], $paged_questions)) { - $order_sql = $shuffle; - if ($shuffle == '') { - $order_sql=' BY survey_question.sort, survey_question_option.sort ASC '; - } - - //$val = 0; - //if ($survey_data['one_question_per_page'] == 0) { - $val = $_GET['show']; - //} - //echo '
'; print_r($paged_questions); echo $val;
-
-			$result = null;
-			if ($val != '') {
-				$imploded = implode(',', $paged_questions[$val]);
-				if ($imploded != '') {
-					// The answers are always in the same order NO shuffle
-					$order_sql = ' BY survey_question.sort, survey_question_option.sort ASC ';
-					$sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri,
-							survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value,
-							survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort
-							FROM $table_survey_question survey_question
-							LEFT JOIN $table_survey_question_option survey_question_option
-							ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id 
-							WHERE    survey_question.survey_id = '" . Database :: escape_string($survey_invitation['survey_id']) . "' AND
-							         survey_question.c_id = $course_id  AND
-							         survey_question.question_id IN (" .$imploded. ")
-							ORDER $order_sql ";
-					$result = Database::query($sql);
-					$question_counter_max = Database :: num_rows($result);
-				}
-			}
-			if (!is_null($result)) {
-				$counter = 0;
-				$limit = 0;
-				$questions = array();
-				while ($row = Database :: fetch_array($result, 'ASSOC')) {
-					// If the type is not a pagebreak we store it in the $questions array
-					if ($row['type'] != 'pagebreak') {
-						$questions[$row['sort']]['question_id'] = $row['question_id'];
-						$questions[$row['sort']]['survey_id'] = $row['survey_id'];
-						$questions[$row['sort']]['survey_question'] = $row['survey_question'];
-						$questions[$row['sort']]['display'] = $row['display'];
-						$questions[$row['sort']]['type'] = $row['type'];
-						$questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text'];
-						$questions[$row['sort']]['maximum_score'] = $row['max_value'];
-						// Personality params
-						$questions[$row['sort']]['survey_group_sec1'] = $row['survey_group_sec1'];
-						$questions[$row['sort']]['survey_group_sec2'] = $row['survey_group_sec2'];
-						$questions[$row['sort']]['survey_group_pri'] = $row['survey_group_pri'];
-					}
-					// If the type is a pagebreak we are finished loading the questions for this page
-					else {
-						break;
-					}
-					$counter++;
-				}
-			}
-		}
-	} else { // In case it's another type than 0 or 1
+            //print_r($paged_questions);
+            //if (key_exists($_GET['show'], $paged_questions)) {
+            $order_sql = $shuffle;
+            if ($shuffle == '') {
+                $order_sql=' BY survey_question.sort, survey_question_option.sort ASC ';
+            }
+
+            //$val = 0;
+            //if ($survey_data['one_question_per_page'] == 0) {
+                $val = $_GET['show'];
+            //}
+            //echo '
'; print_r($paged_questions); echo $val;
+
+            $result = null;
+            if ($val != '') {
+                $imploded = implode(',', $paged_questions[$val]);
+                if ($imploded != '') {
+                    // The answers are always in the same order NO shuffle
+                    $order_sql = ' BY survey_question.sort, survey_question_option.sort ASC ';
+                    $sql = "SELECT survey_question.survey_group_sec1, survey_question.survey_group_sec2, survey_question.survey_group_pri,
+                            survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value,
+                            survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort
+                            FROM $table_survey_question survey_question
+                            LEFT JOIN $table_survey_question_option survey_question_option
+                            ON survey_question.question_id = survey_question_option.question_id AND survey_question_option.c_id = $course_id 
+                            WHERE    survey_question.survey_id = '" . Database :: escape_string($survey_invitation['survey_id']) . "' AND
+                                     survey_question.c_id = $course_id  AND
+                                     survey_question.question_id IN (" .$imploded. ")
+                            ORDER $order_sql ";
+                    $result = Database::query($sql);
+                    $question_counter_max = Database :: num_rows($result);
+                }
+            }
+            if (!is_null($result)) {
+                $counter = 0;
+                $limit = 0;
+                $questions = array();
+                while ($row = Database :: fetch_array($result, 'ASSOC')) {
+                    // If the type is not a pagebreak we store it in the $questions array
+                    if ($row['type'] != 'pagebreak') {
+                        $questions[$row['sort']]['question_id'] = $row['question_id'];
+                        $questions[$row['sort']]['survey_id'] = $row['survey_id'];
+                        $questions[$row['sort']]['survey_question'] = $row['survey_question'];
+                        $questions[$row['sort']]['display'] = $row['display'];
+                        $questions[$row['sort']]['type'] = $row['type'];
+                        $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text'];
+                        $questions[$row['sort']]['maximum_score'] = $row['max_value'];
+                        // Personality params
+                        $questions[$row['sort']]['survey_group_sec1'] = $row['survey_group_sec1'];
+                        $questions[$row['sort']]['survey_group_sec2'] = $row['survey_group_sec2'];
+                        $questions[$row['sort']]['survey_group_pri'] = $row['survey_group_pri'];
+                    }
+                    // If the type is a pagebreak we are finished loading the questions for this page
+                    else {
+                        break;
+                    }
+                    $counter++;
+                }
+            }
+        }
+    } else { // In case it's another type than 0 or 1
         echo get_lang('ErrorSurveyTypeUnknown');
     }
 }
@@ -949,16 +949,16 @@ $numberofpages = Database::num_rows($result) + 1;
 
 // Displaying the form with the questions
 if (isset($_GET['show'])) {
-	$show = (int)$_GET['show'] + 1;
+    $show = (int)$_GET['show'] + 1;
 } else {
-	$show = 0;
+    $show = 0;
 }
 
 // Displaying the form with the questions
 if (isset($_POST['personality'])) {
-	$personality = (int)$_POST['personality'] + 1;
+    $personality = (int)$_POST['personality'] + 1;
 } else {
-	$personality = 0;
+    $personality = 0;
 }
 
 // Displaying the form with the questions
@@ -973,118 +973,118 @@ echo '
'; if (isset($questions) && is_array($questions)) { - foreach ($questions as $key => & $question) { - $ch_type = 'ch_'.$question['type']; - $display = new $ch_type; - $display->render_question($question); - } + foreach ($questions as $key => & $question) { + $ch_type = 'ch_'.$question['type']; + $display = new $ch_type; + $display->render_question($question); + } } if ($survey_data['survey_type'] === '0') { - if ($survey_data['show_form_profile'] == 0) { - // The normal survey as always - if (($show < $numberofpages) || !$_GET['show']) { //$show = $_GET['show'] + 1 - //echo ''; - echo ''; - } - - if ($show >= $numberofpages && $_GET['show']) { - //echo ''; - echo ''; - } - } else { - // The normal survey as always but with the form profile - if (isset($_GET['show'])) { - $numberofpages = count($paged_questions); - if (($show < $numberofpages) || !$_GET['show']) { //$show = $_GET['show'] + 1 - //echo ''; - echo ''; - } - - if ($show >= $numberofpages && $_GET['show'] ) { - //echo ''; - echo ''; - } - } - } + if ($survey_data['show_form_profile'] == 0) { + // The normal survey as always + if (($show < $numberofpages) || !$_GET['show']) { //$show = $_GET['show'] + 1 + //echo ''; + echo ''; + } + + if ($show >= $numberofpages && $_GET['show']) { + //echo ''; + echo ''; + } + } else { + // The normal survey as always but with the form profile + if (isset($_GET['show'])) { + $numberofpages = count($paged_questions); + if (($show < $numberofpages) || !$_GET['show']) { //$show = $_GET['show'] + 1 + //echo ''; + echo ''; + } + + if ($show >= $numberofpages && $_GET['show'] ) { + //echo ''; + echo ''; + } + } + } } elseif ($survey_data['survey_type'] === '1') { //conditional/personality-test type survey - if (isset($_GET['show']) || isset($_POST['personality'])) { - $numberofpages = count($paged_questions); - //echo '
'; echo 'num pages norma:'.$numberofpages; echo '
'; - //echo '
'; print_r($paged_questions_sec);
-		if (!empty ($paged_questions_sec) && count($paged_questions_sec) > 0) {
-			// In case we're in the second phase, also sum the second group questions
-			//echo 'pagesec :'.count($paged_questions_sec);
-			$numberofpages += count($paged_questions_sec);
-			//echo 'pagesec :';
-		} else {
-			// We need this variable only if personality == 1
-			unset($_SESSION['page_questions_sec']);
-			$paged_questions_sec = array();
-		}
-
-		/*echo '
'; - echo 'num pages:'.$numberofpages; echo '
'; - echo 'show :'.$show;echo '
'; - echo 'personality :'.$personality; - echo '
'; - */ - //echo $show.' / '.$numberofpages.'
'; - if ($personality == 0) - if (($show <= $numberofpages) || !$_GET['show']) { //$show = $_GET['show'] + 1 - //echo ''; - echo ''; - if ($survey_data['one_question_per_page'] == 0) { - if ($personality >= 0) { - echo ''; - } - } else { - if ($personality > 0) { - echo ''; - } - } - - if ($numberofpages == $show) { - echo ''; - } - } - - if ($show > $numberofpages && $_GET['show'] && $personality == 0) { - echo ''; - //$numberofpages = count($paged_questions); - //echo $numberofpages = count($paged_questions_sec); - //echo $personality.' / '.$numberofpages; - //echo '
'; - //if ($personality > count($paged_questions_sec) - 1) - //|| $numberofpages == $show +$personality +1 - //echo $show + $personality; - //echo $numberofpages; - } elseif ($personality > 0) { - if ($survey_data['one_question_per_page'] == 1) { - if ($show >= $numberofpages) { - //echo ''; - echo ''; - } else { - echo ''; - //echo ''; - echo ''; - } - } else { - // if the personality test hidden input was set. - //echo ''; - echo ''; - } - } - } - // This is the case when the show_profile_form is true but there are not form_fields - elseif ($survey_data['form_fields'] == '') { - //echo ''; - echo ''; - } elseif(!is_array($user_data)) { - // If the user is not registered in the platform we do not show the form to update his information - //echo ''; - echo ''; - } + if (isset($_GET['show']) || isset($_POST['personality'])) { + $numberofpages = count($paged_questions); + //echo '
'; echo 'num pages norma:'.$numberofpages; echo '
'; + //echo '
'; print_r($paged_questions_sec);
+        if (!empty ($paged_questions_sec) && count($paged_questions_sec) > 0) {
+            // In case we're in the second phase, also sum the second group questions
+            //echo 'pagesec :'.count($paged_questions_sec);
+            $numberofpages += count($paged_questions_sec);
+            //echo 'pagesec :';
+        } else {
+            // We need this variable only if personality == 1
+            unset($_SESSION['page_questions_sec']);
+            $paged_questions_sec = array();
+        }
+
+        /*echo '
'; + echo 'num pages:'.$numberofpages; echo '
'; + echo 'show :'.$show;echo '
'; + echo 'personality :'.$personality; + echo '
'; + */ + //echo $show.' / '.$numberofpages.'
'; + if ($personality == 0) + if (($show <= $numberofpages) || !$_GET['show']) { //$show = $_GET['show'] + 1 + //echo ''; + echo ''; + if ($survey_data['one_question_per_page'] == 0) { + if ($personality >= 0) { + echo ''; + } + } else { + if ($personality > 0) { + echo ''; + } + } + + if ($numberofpages == $show) { + echo ''; + } + } + + if ($show > $numberofpages && $_GET['show'] && $personality == 0) { + echo ''; + //$numberofpages = count($paged_questions); + //echo $numberofpages = count($paged_questions_sec); + //echo $personality.' / '.$numberofpages; + //echo '
'; + //if ($personality > count($paged_questions_sec) - 1) + //|| $numberofpages == $show +$personality +1 + //echo $show + $personality; + //echo $numberofpages; + } elseif ($personality > 0) { + if ($survey_data['one_question_per_page'] == 1) { + if ($show >= $numberofpages) { + //echo ''; + echo ''; + } else { + echo ''; + //echo ''; + echo ''; + } + } else { + // if the personality test hidden input was set. + //echo ''; + echo ''; + } + } + } + // This is the case when the show_profile_form is true but there are not form_fields + elseif ($survey_data['form_fields'] == '') { + //echo ''; + echo ''; + } elseif(!is_array($user_data)) { + // If the user is not registered in the platform we do not show the form to update his information + //echo ''; + echo ''; + } } echo ''; @@ -1109,4 +1109,4 @@ function check_time_availability($surv_data) { Display :: display_footer(); exit; } -} \ No newline at end of file +} From 36f5ab7caa661a9ef0eef4a6e7ced44d4c72130f Mon Sep 17 00:00:00 2001 From: Jose Manuel Abuin Mosquera Date: Wed, 26 Sep 2012 18:38:18 -0500 Subject: [PATCH 010/124] Fixing wrong course ID in survey e-mail sending - refs #5529 --- main/survey/fillsurvey.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index bd07bff6c5..bfc964c339 100644 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -489,8 +489,8 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { } else { $paged_questions = $_SESSION['paged_questions']; } - - $course_id = api_get_course_int_id(); + + $course_id = $survey_invitation['c_id']; if (key_exists($_GET['show'], $paged_questions)) { if (isset($_GET['user_id'])) { From 604f4a54142470edb2554b547ccfa0bdd69f4eb1 Mon Sep 17 00:00:00 2001 From: Yoselyn Castillo Date: Wed, 26 Sep 2012 23:46:50 -0500 Subject: [PATCH 011/124] Fixing visualization of sessions for users - refs #5353 --- main/inc/lib/userportal.lib.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 990ee5c260..3bede22af6 100644 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -910,8 +910,9 @@ class IndexManager { // Courses inside the current session. $date_session_start = $session['date_start']; - $days_access_before_beginning = $session['nb_days_access_before_beginning'] * 24 * 3600; - + $days_access_before_beginning = $session['nb_days_access_before_beginning']; + $days_access_after_end = $session['nb_days_access_after_end']; + $date_session_end = $session['date_end']; $session_now = time(); $html_courses_session = ''; $count_courses_session = 0; @@ -919,14 +920,19 @@ class IndexManager { foreach ($session['courses'] as $course) { $is_coach_course = api_is_coach($session_id, $course['code']); $allowed_time = 0; + $dif_time_after = 0; if ($date_session_start != '0000-00-00') { if ($is_coach_course) { - $allowed_time = api_strtotime($date_session_start) - $days_access_before_beginning; + $allowed_time = api_strtotime($date_session_start) - ($days_access_before_beginning*86400); + if ($session_now > $date_session_end) { + $dif_time_after = $session_now - api_strtotime($date_session_end); + $dif_time_after = round($dif_time_after/86400); + } } else { $allowed_time = api_strtotime($date_session_start); } } - if ($session_now > $allowed_time) { + if ($session_now > $allowed_time && $days_access_after_end >= $dif_time_after-1) { //read only and accesible if (api_get_setting('hide_courses_in_sessions') == 'false') { $c = CourseManager :: get_logged_user_course_html($course, $session_id, 'session_course_item', true, $this->load_directories_preview); @@ -981,20 +987,26 @@ class IndexManager { } $date_session_start = $session['date_start']; //api_get_session_visibility($session_id); - $days_access_before_beginning = $session['nb_days_access_before_beginning'] * 24 * 3600; + $days_access_before_beginning = $session['nb_days_access_before_beginning']; + $days_access_after_end = $session['nb_days_access_after_end']; + $date_session_end = $session['date_end']; $session_now = time(); $html_courses_session = ''; $count = 0; foreach ($session['courses'] as $course) { $is_coach_course = api_is_coach($session_id, $course['code']); - + $dif_time_after = 0; if ($is_coach_course) { - $allowed_time = api_strtotime($date_session_start) - $days_access_before_beginning; + $allowed_time = api_strtotime($date_session_start) - ($days_access_before_beginning*86400); + if ($session_now > $date_session_end) { + $dif_time_after = $session_now - api_strtotime($date_session_end); + $dif_time_after = round($dif_time_after/86400); + } } else { $allowed_time = api_strtotime($date_session_start); } - if ($session_now > $allowed_time) { + if ($session_now > $allowed_time && $days_access_after_end >= $dif_time_after-1) { if (api_get_setting('hide_courses_in_sessions') == 'false') { $c = CourseManager :: get_logged_user_course_html($course, $session_id, 'session_course_item'); $html_courses_session .= $c[1]; @@ -1087,4 +1099,4 @@ class IndexManager { function return_hot_courses() { return CourseManager::return_hot_courses(); } -} \ No newline at end of file +} From f4133d235bd6a87f31005aaba72ee929b0fb96f6 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 00:05:57 -0500 Subject: [PATCH 012/124] Minor: code indentation fix --- .../classes/CourseBuilder.class.php | 1450 ++++++++--------- 1 file changed, 725 insertions(+), 725 deletions(-) diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 1acb3786ad..4b8e4c24f2 100644 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -30,8 +30,8 @@ require_once 'Attendance.class.php'; * @package chamilo.backup */ class CourseBuilder { - /** Course */ - var $course; + /** Course */ + var $course; /* With this array you can filter the tools you want to be parsed by default all tools are included*/ var $tools_to_build = array( @@ -56,25 +56,25 @@ class CourseBuilder { /* With this array you can filter wich elements of the tools are going to be added in the course obj (only works with LPs) */ var $specific_id_list = array(); - /** - * Create a new CourseBuilder - */ - function __construct($type='', $course = null) { - global $_course; - - if (!empty($course['official_code'])){ - $_course = $course; - } - - $this->course = new Course(); + /** + * Create a new CourseBuilder + */ + function __construct($type='', $course = null) { + global $_course; + + if (!empty($course['official_code'])){ + $_course = $course; + } + + $this->course = new Course(); $this->course->code = $_course['official_code']; - $this->course->type = $type; - $this->course->path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/'; - $this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['path']; - $this->course->encoding = api_get_system_encoding(); //current platform encoding - $this->course->db_name = $_course['dbName']; - $this->course->info = $_course; - } + $this->course->type = $type; + $this->course->path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/'; + $this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['path']; + $this->course->encoding = api_get_system_encoding(); //current platform encoding + $this->course->db_name = $_course['dbName']; + $this->course->info = $_course; + } /** * @@ -92,46 +92,46 @@ class CourseBuilder { $this->specific_id_list = $array; } - /** - * Get the created course - * @return course The course - */ - function get_course() { - return $this->course; - } - - /** - * Build the course-object - * - * @param int session_id - * @param string course_code - * @param bool true if you want to get the elements that exists in the course and - * in the session, (session_id = 0 or session_id = X) - */ - function build($session_id = 0, $course_code = '', $with_base_content = false) { + /** + * Get the created course + * @return course The course + */ + function get_course() { + return $this->course; + } + + /** + * Build the course-object + * + * @param int session_id + * @param string course_code + * @param bool true if you want to get the elements that exists in the course and + * in the session, (session_id = 0 or session_id = X) + */ + function build($session_id = 0, $course_code = '', $with_base_content = false) { $table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES); - $table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY); + $table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY); - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; foreach ($this->tools_to_build as $tool) { $function_build = 'build_'.$tool; $this->$function_build($session_id, $course_code, $with_base_content, $this->specific_id_list[$tool]); } - - if (!empty($session_id) && !empty($course_code)) { - /*$this->build_documents($session_id, $course_code, $with_base_content); - $this->build_quizzes($session_id, $course_code, $with_base_content); - $this->build_glossary($session_id, $course_code, $with_base_content); - $this->build_learnpaths($session_id, $course_code,$with_base_content); - $this->build_links($session_id, $course_code, $with_base_content); - $this->build_course_descriptions($session_id, $course_code, $with_base_content); - $this->build_wiki($session_id, $course_code, $with_base_content); - //$this->build_thematic($session_id, $course_code, $with_base_content); - $this->build_thematic(); - $this->build_attendance();*/ - } else { + + if (!empty($session_id) && !empty($course_code)) { + /*$this->build_documents($session_id, $course_code, $with_base_content); + $this->build_quizzes($session_id, $course_code, $with_base_content); + $this->build_glossary($session_id, $course_code, $with_base_content); + $this->build_learnpaths($session_id, $course_code,$with_base_content); + $this->build_links($session_id, $course_code, $with_base_content); + $this->build_course_descriptions($session_id, $course_code, $with_base_content); + $this->build_wiki($session_id, $course_code, $with_base_content); + //$this->build_thematic($session_id, $course_code, $with_base_content); + $this->build_thematic(); + $this->build_attendance();*/ + } else { /*$this->build_events(); $this->build_announcements(); $this->build_links(); @@ -146,750 +146,750 @@ class CourseBuilder { $this->build_thematic(); $this->build_attendance();*/ - } + } - //TABLE_LINKED_RESOURCES is the "resource" course table, which is deprecated, apparently + //TABLE_LINKED_RESOURCES is the "resource" course table, which is deprecated, apparently - foreach ($this->course->resources as $type => $resources) { - foreach ($resources as $id => $resource) { - $sql = "SELECT * FROM ".$table_link." WHERE c_id = $course_id AND source_type = '".$resource->get_type()."' AND source_id = '".$resource->get_id()."'"; - $res = Database::query($sql); - while ($link = Database::fetch_object($res)) { - $this->course->resources[$type][$id]->add_linked_resource($link->resource_type, $link->resource_id); - } - } - } + foreach ($this->course->resources as $type => $resources) { + foreach ($resources as $id => $resource) { + $sql = "SELECT * FROM ".$table_link." WHERE c_id = $course_id AND source_type = '".$resource->get_type()."' AND source_id = '".$resource->get_id()."'"; + $res = Database::query($sql); + while ($link = Database::fetch_object($res)) { + $this->course->resources[$type][$id]->add_linked_resource($link->resource_type, $link->resource_id); + } + } + } - foreach ($this->course->resources as $type => $resources) { - foreach ($resources as $id => $resource) { - $tool = $resource->get_tool(); - if ($tool != null) { - $sql = "SELECT * FROM $table_properties WHERE c_id = $course_id AND TOOL = '".$tool."' AND ref='".$resource->get_id()."'"; - $res = Database::query($sql); - $all_properties = array (); - while ($item_property = Database::fetch_array($res)) { - $all_properties[]= $item_property; - } - $this->course->resources[$type][$id]->item_properties = $all_properties; - } - } - } - return $this->course; - } - - /** - * Build the documents - */ - function build_documents($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + foreach ($this->course->resources as $type => $resources) { + foreach ($resources as $id => $resource) { + $tool = $resource->get_tool(); + if ($tool != null) { + $sql = "SELECT * FROM $table_properties WHERE c_id = $course_id AND TOOL = '".$tool."' AND ref='".$resource->get_id()."'"; + $res = Database::query($sql); + $all_properties = array (); + while ($item_property = Database::fetch_array($res)) { + $all_properties[]= $item_property; + } + $this->course->resources[$type][$id]->item_properties = $all_properties; + } + } + } + return $this->course; + } + + /** + * Build the documents + */ + function build_documents($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $table_doc = Database::get_course_table(TABLE_DOCUMENT); - $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $table_doc = Database::get_course_table(TABLE_DOCUMENT); + $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); //Remove chat_files and shared_folder files $avoid_paths = " path NOT LIKE '/shared_folder%' AND path NOT LIKE '/chat_files%' "; //$avoid_paths = " 1 = 1 "; - if (!empty($course_code) && !empty($session_id)) { - $session_id = intval($session_id); + if (!empty($course_code) && !empty($session_id)) { + $session_id = intval($session_id); if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); } - if (!empty($this->course->type) && $this->course->type=='partial') { - $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d, $table_prop p - WHERE d.c_id = $course_id AND - p.c_id = $course_id AND - tool = '".TOOL_DOCUMENT."' AND - p.ref = d.id AND - p.visibility != 2 AND - path NOT LIKE '/images/gallery%' AND + if (!empty($this->course->type) && $this->course->type=='partial') { + $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d, $table_prop p + WHERE d.c_id = $course_id AND + p.c_id = $course_id AND + tool = '".TOOL_DOCUMENT."' AND + p.ref = d.id AND + p.visibility != 2 AND + path NOT LIKE '/images/gallery%' AND $avoid_paths - $session_condition - ORDER BY path"; - } else { - $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d, $table_prop p - WHERE d.c_id = $course_id AND - p.c_id = $course_id AND - tool = '".TOOL_DOCUMENT."' AND + $session_condition + ORDER BY path"; + } else { + $sql = "SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM $table_doc d, $table_prop p + WHERE d.c_id = $course_id AND + p.c_id = $course_id AND + tool = '".TOOL_DOCUMENT."' AND $avoid_paths AND - p.ref = d.id AND + p.ref = d.id AND p.visibility != 2 $session_condition - ORDER BY path"; - } + ORDER BY path"; + } - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size); - $this->course->add_resource($doc); - } - } else { - - if (!empty($this->course->type) && $this->course->type=='partial') - $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p - WHERE d.c_id = '.$course_id.' AND - p.c_id = '.$course_id.' AND - tool = \''.TOOL_DOCUMENT.'\' AND + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size); + $this->course->add_resource($doc); + } + } else { + + if (!empty($this->course->type) && $this->course->type=='partial') + $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size FROM '.$table_doc.' d, '.$table_prop.' p + WHERE d.c_id = '.$course_id.' AND + p.c_id = '.$course_id.' AND + tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND path NOT LIKE \'/images/gallery%\' AND '.$avoid_paths.'AND d.session_id = 0 ORDER BY path'; - else - $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size - FROM '.$table_doc.' d, '.$table_prop.' p - WHERE d.c_id = '.$course_id.' AND - p.c_id = '.$course_id.' AND - tool = \''.TOOL_DOCUMENT.'\' AND + else + $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size + FROM '.$table_doc.' d, '.$table_prop.' p + WHERE d.c_id = '.$course_id.' AND + p.c_id = '.$course_id.' AND + tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND '.$avoid_paths.' AND d.session_id = 0 ORDER BY path'; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size); - $this->course->add_resource($doc); - } - } - } + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size); + $this->course->add_resource($doc); + } + } + } - /** - * Build the forums - */ - function build_forums($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; + /** + * Build the forums + */ + function build_forums($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array()) { + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; - $table = Database :: get_course_table(TABLE_FORUM); + $table = Database :: get_course_table(TABLE_FORUM); - $sql = "SELECT * FROM $table WHERE c_id = $course_id "; + $sql = "SELECT * FROM $table WHERE c_id = $course_id "; $sql .= " ORDER BY forum_title, forum_category"; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { $forum = new Forum($obj); - $this->course->add_resource($forum); - } - } + $this->course->add_resource($forum); + } + } - /** - * Build a forum-category - */ - function build_forum_category($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array()) { - $table = Database :: get_course_table(TABLE_FORUM_CATEGORY); - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $sql = "SELECT * FROM $table WHERE c_id = $course_id ORDER BY cat_title"; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { + /** + * Build a forum-category + */ + function build_forum_category($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array()) { + $table = Database :: get_course_table(TABLE_FORUM_CATEGORY); + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $sql = "SELECT * FROM $table WHERE c_id = $course_id ORDER BY cat_title"; + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { $forum_category = new ForumCategory($obj); - $this->course->add_resource($forum_category); - } - } + $this->course->add_resource($forum_category); + } + } - /** - * Build the forum-topics - */ - function build_forum_topics($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array()) { - $table = Database :: get_course_table(TABLE_FORUM_THREAD); - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - $sql = "SELECT * FROM $table WHERE c_id = $course_id + /** + * Build the forum-topics + */ + function build_forum_topics($session_id = 0, $course_code = null, $with_base_content = false, $id_list = array()) { + $table = Database :: get_course_table(TABLE_FORUM_THREAD); + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + $sql = "SELECT * FROM $table WHERE c_id = $course_id ORDER BY thread_title "; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { $forum_topic = new ForumTopic($obj); - $this->course->add_resource($forum_topic); + $this->course->add_resource($forum_topic); $this->build_forum_posts($obj->thread_id, $obj->forum_id); - } - } + } + } - /** - * Build the forum-posts - * TODO: All tree structure of posts should be built, attachments for example. - */ - function build_forum_posts($thread_id = null, $forum_id = null) { - $table = Database :: get_course_table(TABLE_FORUM_POST); - $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM $table WHERE c_id = $course_id "; + /** + * Build the forum-posts + * TODO: All tree structure of posts should be built, attachments for example. + */ + function build_forum_posts($thread_id = null, $forum_id = null) { + $table = Database :: get_course_table(TABLE_FORUM_POST); + $course_id = api_get_course_int_id(); + $sql = "SELECT * FROM $table WHERE c_id = $course_id "; if (!empty($thread_id) && !empty($forum_id)) { $forum_id = intval($forum_id); $thread_id = intval($thread_id); $sql .= " AND thread_id = $thread_id AND forum_id = $forum_id "; } - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $forum_post = new ForumPost($obj); - $this->course->add_resource($forum_post); - } - } - - /** - * Build the links - */ - function build_links($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $table = Database :: get_course_table(TABLE_LINK); - $table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY); - - if (!empty($session_id) && !empty($course_code)) { - $session_id = intval($session_id); + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $forum_post = new ForumPost($obj); + $this->course->add_resource($forum_post); + } + } + + /** + * Build the links + */ + function build_links($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $table = Database :: get_course_table(TABLE_LINK); + $table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY); + + if (!empty($session_id) && !empty($course_code)) { + $session_id = intval($session_id); if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); } - $sql = "SELECT l.id, l.title, l.url, l.description, l.category_id, l.on_homepage - FROM $table l, $table_prop p - WHERE l.c_id = $course_id AND p.c_id = $course_id AND p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 $session_condition - ORDER BY l.display_order"; - } else { - $sql = "SELECT l.id, l.title, l.url, l.description, l.category_id, l.on_homepage - FROM $table l, $table_prop p - WHERE l.c_id = $course_id AND p.c_id = $course_id AND p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 AND l.session_id = 0 - ORDER BY l.display_order"; - } + $sql = "SELECT l.id, l.title, l.url, l.description, l.category_id, l.on_homepage + FROM $table l, $table_prop p + WHERE l.c_id = $course_id AND p.c_id = $course_id AND p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 $session_condition + ORDER BY l.display_order"; + } else { + $sql = "SELECT l.id, l.title, l.url, l.description, l.category_id, l.on_homepage + FROM $table l, $table_prop p + WHERE l.c_id = $course_id AND p.c_id = $course_id AND p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 AND l.session_id = 0 + ORDER BY l.display_order"; + } - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $link = new Link($obj->id, $obj->title, $obj->url, $obj->description, $obj->category_id, $obj->on_homepage); - $this->course->add_resource($link); + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $link = new Link($obj->id, $obj->title, $obj->url, $obj->description, $obj->category_id, $obj->on_homepage); + $this->course->add_resource($link); - if (!empty($course_code)) { - $res = $this->build_link_category($obj->category_id,$course_code); - } else { - $res = $this->build_link_category($obj->category_id); - } + if (!empty($course_code)) { + $res = $this->build_link_category($obj->category_id,$course_code); + } else { + $res = $this->build_link_category($obj->category_id); + } - if($res > 0) { - $this->course->resources[RESOURCE_LINK][$obj->id]->add_linked_resource(RESOURCE_LINKCATEGORY, $obj->category_id); - } - } - } + if($res > 0) { + $this->course->resources[RESOURCE_LINK][$obj->id]->add_linked_resource(RESOURCE_LINKCATEGORY, $obj->category_id); + } + } + } - /** - * Build tool intro - */ - function build_tool_intro($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $table = Database :: get_course_table(TABLE_TOOL_INTRO); - $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM $table WHERE c_id = $course_id "; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $tool_intro = new ToolIntro($obj->id, $obj->intro_text); - $this->course->add_resource($tool_intro); - } - } + /** + * Build tool intro + */ + function build_tool_intro($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $table = Database :: get_course_table(TABLE_TOOL_INTRO); + $course_id = api_get_course_int_id(); + $sql = "SELECT * FROM $table WHERE c_id = $course_id "; + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $tool_intro = new ToolIntro($obj->id, $obj->intro_text); + $this->course->add_resource($tool_intro); + } + } - /** - * Build a link category - */ - function build_link_category($id, $course_code = '') { - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY); + /** + * Build a link category + */ + function build_link_category($id, $course_code = '') { + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY); - $sql = "SELECT * FROM $link_cat_table WHERE c_id = $course_id AND id = $id"; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $link_category = new LinkCategory($obj->id, $obj->category_title, $obj->description, $obj->display_order); - $this->course->add_resource($link_category); - return $id; - } - return 0; - } + $sql = "SELECT * FROM $link_cat_table WHERE c_id = $course_id AND id = $id"; + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $link_category = new LinkCategory($obj->id, $obj->category_title, $obj->description, $obj->display_order); + $this->course->add_resource($link_category); + return $id; + } + return 0; + } - /** - * Build the Quizzes - */ - function build_quizzes($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); - - $course_id = $course_info['real_id']; - - if (!empty($course_code) && !empty($session_id)) { - $session_id = intval($session_id); + /** + * Build the Quizzes + */ + function build_quizzes($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $course_info = api_get_course_info($course_code); + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); + + $course_id = $course_info['real_id']; + + if (!empty($course_code) && !empty($session_id)) { + $session_id = intval($session_id); if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); - } - $sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 $session_condition"; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes) - } else { - $sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 AND session_id = 0"; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes) - } - - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - if (strlen($obj->sound) > 0) { + } + $sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 $session_condition"; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes) + } else { + $sql = "SELECT * FROM $table_qui WHERE c_id = $course_id AND active >=0 AND session_id = 0"; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes) + } + + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + if (strlen($obj->sound) > 0) { $sql = "SELECT id FROM ".$table_doc." WHERE c_id = $course_id AND path = '/audio/".$obj->sound."'"; $res = Database::query($sql); - $doc = Database::fetch_object($res); - $obj->sound = $doc->id; - } - $quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound, $obj->max_attempt, - $obj->results_disabled, $obj->access_condition, $obj->start_time, $obj->end_time, $obj->feedback_type, $obj->random_answers, $obj->expired_time, $obj->session_id); - $sql = 'SELECT * FROM '.$table_rel.' WHERE c_id = '.$course_id.' AND exercice_id = '.$obj->id; - $db_result2 = Database::query($sql); - while ($obj2 = Database::fetch_object($db_result2)) { - $quiz->add_question($obj2->question_id, $obj2->question_order); - } - $this->course->add_resource($quiz); - } + $doc = Database::fetch_object($res); + $obj->sound = $doc->id; + } + $quiz = new Quiz($obj->id, $obj->title, $obj->description, $obj->random, $obj->type, $obj->active, $obj->sound, $obj->max_attempt, + $obj->results_disabled, $obj->access_condition, $obj->start_time, $obj->end_time, $obj->feedback_type, $obj->random_answers, $obj->expired_time, $obj->session_id); + $sql = 'SELECT * FROM '.$table_rel.' WHERE c_id = '.$course_id.' AND exercice_id = '.$obj->id; + $db_result2 = Database::query($sql); + while ($obj2 = Database::fetch_object($db_result2)) { + $quiz->add_question($obj2->question_id, $obj2->question_order); + } + $this->course->add_resource($quiz); + } - if (!empty($course_code)) { - $this->build_quiz_questions($course_code); - } else { - $this->build_quiz_questions(); - } - } - - /** - * Build the Quiz-Questions - */ - function build_quiz_questions($course_code = null) { - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); - $table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION); - $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER); + if (!empty($course_code)) { + $this->build_quiz_questions($course_code); + } else { + $this->build_quiz_questions(); + } + } + + /** + * Build the Quiz-Questions + */ + function build_quiz_questions($course_code = null) { + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); + $table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION); + $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER); - // Building normal tests. - $sql = "SELECT * FROM $table_que WHERE c_id = $course_id "; - - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra); - $sql = 'SELECT * FROM '.$table_ans.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->id; - $db_result2 = Database::query($sql); - while ($obj2 = Database::fetch_object($db_result2)) { - $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); - } - $this->course->add_resource($question); - } + // Building normal tests. + $sql = "SELECT * FROM $table_que WHERE c_id = $course_id "; + + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra); + $sql = 'SELECT * FROM '.$table_ans.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->id; + $db_result2 = Database::query($sql); + while ($obj2 = Database::fetch_object($db_result2)) { + $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); + } + $this->course->add_resource($question); + } - // Building a fictional test for collecting orphan questions. - $build_orphan_questions = !empty($_POST['recycle_option']); // When a course is emptied this option should be activated (true). + // Building a fictional test for collecting orphan questions. + $build_orphan_questions = !empty($_POST['recycle_option']); // When a course is emptied this option should be activated (true). - $sql = "SELECT questions.* FROM $table_que as questions + $sql = "SELECT questions.* FROM $table_que as questions LEFT JOIN $table_rel as quizz_questions ON (questions.id = quizz_questions.question_id AND questions.c_id = $course_id AND quizz_questions.c_id = $course_id) LEFT JOIN $table_qui as exercices ON (exercice_id = exercices.id AND exercices.c_id = $course_id AND questions.c_id = $course_id) - WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1"; // active = -1 means "deleted" test. - - $db_result = Database::query($sql); - if (Database::num_rows($db_result) > 0) { - $build_orphan_questions = true; - while ($obj = Database::fetch_object($db_result)) { - $question = new QuizQuestion($obj->id.$course_id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level, $obj->extra); - $sql = "SELECT * FROM $table_ans WHERE c_id = $course_id AND question_id = ".$obj->id; - $db_result2 = Database::query($sql); + WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1"; // active = -1 means "deleted" test. + + $db_result = Database::query($sql); + if (Database::num_rows($db_result) > 0) { + $build_orphan_questions = true; + while ($obj = Database::fetch_object($db_result)) { + $question = new QuizQuestion($obj->id.$course_id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level, $obj->extra); + $sql = "SELECT * FROM $table_ans WHERE c_id = $course_id AND question_id = ".$obj->id; + $db_result2 = Database::query($sql); if (Database::num_rows($db_result2)) { while ($obj2 = Database::fetch_object($db_result2)) { $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); } } - $this->course->add_resource($question); - } - } - - if ($build_orphan_questions) { - //$this->course->add_resource(new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0)); - } - } + $this->course->add_resource($question); + } + } + + if ($build_orphan_questions) { + //$this->course->add_resource(new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0)); + } + } - /** - * Build the orphan questions - */ - function build_quiz_orphan_questions() { - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); - $table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION); - $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER); - - $course_id = api_get_course_int_id(); + /** + * Build the orphan questions + */ + function build_quiz_orphan_questions() { + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); + $table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION); + $table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER); + + $course_id = api_get_course_int_id(); - $sql = 'SELECT * FROM '.$table_que.' as questions LEFT JOIN '.$table_rel.' as quizz_questions - ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.' as exercices - ON exercice_id=exercices.id - WHERE questions.c_id = '.$course_id.' AND - quizz_questions.c_id = '.$course_id.' AND - exercices.c_id = '.$course_id.' AND - quizz_questions.exercice_id IS NULL OR - exercices.active = -1'; - $db_result = Database::query($sql); - if (Database::num_rows($db_result) > 0) { - $orphan_questions = new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0); // Tjis is the fictional test for collecting orphan questions. - $this->course->add_resource($orphan_questions); - while ($obj = Database::fetch_object($db_result)) - { - $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level,$obj->extra); - $sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id; - $db_result2 = Database::query($sql); - while ($obj2 = Database::fetch_object($db_result2)) - { - $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); - } - $this->course->add_resource($question); - } - } - } + $sql = 'SELECT * FROM '.$table_que.' as questions LEFT JOIN '.$table_rel.' as quizz_questions + ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.' as exercices + ON exercice_id=exercices.id + WHERE questions.c_id = '.$course_id.' AND + quizz_questions.c_id = '.$course_id.' AND + exercices.c_id = '.$course_id.' AND + quizz_questions.exercice_id IS NULL OR + exercices.active = -1'; + $db_result = Database::query($sql); + if (Database::num_rows($db_result) > 0) { + $orphan_questions = new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0); // Tjis is the fictional test for collecting orphan questions. + $this->course->add_resource($orphan_questions); + while ($obj = Database::fetch_object($db_result)) + { + $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level,$obj->extra); + $sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id; + $db_result2 = Database::query($sql); + while ($obj2 = Database::fetch_object($db_result2)) + { + $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type); + } + $this->course->add_resource($question); + } + } + } - /** - * Build the Surveys - */ - function build_surveys($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $table_survey = Database :: get_course_table(TABLE_SURVEY); - $table_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); - $course_id = api_get_course_int_id(); - - $sql = 'SELECT * FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND session_id = 0 '; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $survey = new Survey($obj->survey_id, $obj->code,$obj->title, - $obj->subtitle, $obj->author, $obj->lang, - $obj->avail_from, $obj->avail_till, $obj->is_shared, - $obj->template, $obj->intro, $obj->surveythanks, - $obj->creation_date, $obj->invited, $obj->answered, - $obj->invite_mail, $obj->reminder_mail); - $sql = 'SELECT * FROM '.$table_question.' WHERE c_id = '.$course_id.' AND survey_id = '.$obj->survey_id; - $db_result2 = Database::query($sql); - while ($obj2 = Database::fetch_object($db_result2)){ - $survey->add_question($obj2->question_id); - } - $this->course->add_resource($survey); - } - $this->build_survey_questions(); - } - /** - * Build the Survey Questions - */ - function build_survey_questions() { - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); - $table_opt = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); - - $course_id = api_get_course_int_id(); - - $sql = 'SELECT * FROM '.$table_que.' WHERE c_id = '.$course_id.' '; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)){ - $question = new SurveyQuestion($obj->question_id, $obj->survey_id, - $obj->survey_question, $obj->survey_question_comment, - $obj->type, $obj->display, $obj->sort, - $obj->shared_question_id, $obj->max_value); - $sql = 'SELECT * FROM '.$table_opt.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->question_id; - $db_result2 = Database::query($sql); - while ($obj2 = Database::fetch_object($db_result2)) { - $question->add_answer($obj2->option_text, $obj2->sort); - } - $this->course->add_resource($question); - } - } + /** + * Build the Surveys + */ + function build_surveys($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $table_survey = Database :: get_course_table(TABLE_SURVEY); + $table_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $course_id = api_get_course_int_id(); + + $sql = 'SELECT * FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND session_id = 0 '; + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $survey = new Survey($obj->survey_id, $obj->code,$obj->title, + $obj->subtitle, $obj->author, $obj->lang, + $obj->avail_from, $obj->avail_till, $obj->is_shared, + $obj->template, $obj->intro, $obj->surveythanks, + $obj->creation_date, $obj->invited, $obj->answered, + $obj->invite_mail, $obj->reminder_mail); + $sql = 'SELECT * FROM '.$table_question.' WHERE c_id = '.$course_id.' AND survey_id = '.$obj->survey_id; + $db_result2 = Database::query($sql); + while ($obj2 = Database::fetch_object($db_result2)){ + $survey->add_question($obj2->question_id); + } + $this->course->add_resource($survey); + } + $this->build_survey_questions(); + } + /** + * Build the Survey Questions + */ + function build_survey_questions() { + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); + $table_opt = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); + + $course_id = api_get_course_int_id(); + + $sql = 'SELECT * FROM '.$table_que.' WHERE c_id = '.$course_id.' '; + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)){ + $question = new SurveyQuestion($obj->question_id, $obj->survey_id, + $obj->survey_question, $obj->survey_question_comment, + $obj->type, $obj->display, $obj->sort, + $obj->shared_question_id, $obj->max_value); + $sql = 'SELECT * FROM '.$table_opt.' WHERE c_id = '.$course_id.' AND question_id = '.$obj->question_id; + $db_result2 = Database::query($sql); + while ($obj2 = Database::fetch_object($db_result2)) { + $question->add_answer($obj2->option_text, $obj2->sort); + } + $this->course->add_resource($question); + } + } - /** - * Build the announcements - */ - function build_announcements($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); - $course_id = api_get_course_int_id(); - - $sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$course_id.' AND session_id = 0'; - $db_result = Database::query($sql); - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); - while ($obj = Database::fetch_object($db_result)) { - $sql = 'SELECT path, comment, filename, size FROM '.$table_attachment.' WHERE c_id = '.$course_id.' AND announcement_id = '.$obj->id.''; - $result = Database::query($sql); - $attachment_obj = Database::fetch_object($result); - $att_path = $att_filename = $att_size = $atth_comment = ''; - if (!empty($attachment_obj)) { - $att_path = $attachment_obj->path; - $att_filename = $attachment_obj->filename; - $att_size = $attachment_obj->size; - $atth_comment = $attachment_obj->comment; - } - $announcement = new Announcement($obj->id, $obj->title, $obj->content, $obj->end_date,$obj->display_order,$obj->email_sent, $att_path, $att_filename, $att_size, $atth_comment); - $this->course->add_resource($announcement); - - } - } - /** - * Build the events - */ - function build_events($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $table = Database :: get_course_table(TABLE_AGENDA); - $course_id = api_get_course_int_id(); - - $sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$course_id.' AND session_id = 0'; - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); - $sql = 'SELECT path, comment, filename, size FROM '.$table_attachment.' WHERE c_id = '.$course_id.' AND agenda_id = '.$obj->id.''; - $result = Database::query($sql); - - $attachment_obj = Database::fetch_object($result); - $att_path = $att_filename = $att_size = $atth_comment = ''; - if (!empty($attachment_obj)) { - $att_path = $attachment_obj->path; - $att_filename = $attachment_obj->filename; - $att_size = $attachment_obj->size; - $atth_comment = $attachment_obj->comment; - } - $event = new Event($obj->id, $obj->title, $obj->content, $obj->start_date, $obj->end_date, $att_path, $att_filename, $att_size, $atth_comment, $obj->all_day); - $this->course->add_resource($event); - } - - } - /** - * Build the course-descriptions - */ - function build_course_descriptions($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); - - if (!empty($session_id) && !empty($course_code)) { - $session_id = intval($session_id); + /** + * Build the announcements + */ + function build_announcements($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); + $course_id = api_get_course_int_id(); + + $sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$course_id.' AND session_id = 0'; + $db_result = Database::query($sql); + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); + while ($obj = Database::fetch_object($db_result)) { + $sql = 'SELECT path, comment, filename, size FROM '.$table_attachment.' WHERE c_id = '.$course_id.' AND announcement_id = '.$obj->id.''; + $result = Database::query($sql); + $attachment_obj = Database::fetch_object($result); + $att_path = $att_filename = $att_size = $atth_comment = ''; + if (!empty($attachment_obj)) { + $att_path = $attachment_obj->path; + $att_filename = $attachment_obj->filename; + $att_size = $attachment_obj->size; + $atth_comment = $attachment_obj->comment; + } + $announcement = new Announcement($obj->id, $obj->title, $obj->content, $obj->end_date,$obj->display_order,$obj->email_sent, $att_path, $att_filename, $att_size, $atth_comment); + $this->course->add_resource($announcement); + + } + } + /** + * Build the events + */ + function build_events($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $table = Database :: get_course_table(TABLE_AGENDA); + $course_id = api_get_course_int_id(); + + $sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$course_id.' AND session_id = 0'; + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); + $sql = 'SELECT path, comment, filename, size FROM '.$table_attachment.' WHERE c_id = '.$course_id.' AND agenda_id = '.$obj->id.''; + $result = Database::query($sql); + + $attachment_obj = Database::fetch_object($result); + $att_path = $att_filename = $att_size = $atth_comment = ''; + if (!empty($attachment_obj)) { + $att_path = $attachment_obj->path; + $att_filename = $attachment_obj->filename; + $att_size = $attachment_obj->size; + $atth_comment = $attachment_obj->comment; + } + $event = new Event($obj->id, $obj->title, $obj->content, $obj->start_date, $obj->end_date, $att_path, $att_filename, $att_size, $atth_comment, $obj->all_day); + $this->course->add_resource($event); + } + + } + /** + * Build the course-descriptions + */ + function build_course_descriptions($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); + + if (!empty($session_id) && !empty($course_code)) { + $session_id = intval($session_id); if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); } - $sql = 'SELECT * FROM '.$table. ' WHERE c_id = '.$course_id.' '.$session_condition; - } else { - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); - $sql = 'SELECT * FROM '.$table. ' WHERE c_id = '.$course_id.' AND session_id = 0'; - } + $sql = 'SELECT * FROM '.$table. ' WHERE c_id = '.$course_id.' '.$session_condition; + } else { + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); + $sql = 'SELECT * FROM '.$table. ' WHERE c_id = '.$course_id.' AND session_id = 0'; + } - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $cd = new CourseDescription($obj->id, $obj->title, $obj->content, $obj->description_type); - $this->course->add_resource($cd); - } - } - /** - * Build the learnpaths - */ - function build_learnpaths($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - - $course_info = api_get_course_info($course_code); - $course_id = $course_info['real_id']; - $table_main = Database::get_course_table(TABLE_LP_MAIN); - $table_item = Database::get_course_table(TABLE_LP_ITEM); - $table_tool = Database::get_course_table(TABLE_TOOL_LIST); - - if (!empty($session_id) && !empty($course_code)) { - $session_id = intval($session_id); + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $cd = new CourseDescription($obj->id, $obj->title, $obj->content, $obj->description_type); + $this->course->add_resource($cd); + } + } + /** + * Build the learnpaths + */ + function build_learnpaths($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + + $course_info = api_get_course_info($course_code); + $course_id = $course_info['real_id']; + $table_main = Database::get_course_table(TABLE_LP_MAIN); + $table_item = Database::get_course_table(TABLE_LP_ITEM); + $table_tool = Database::get_course_table(TABLE_TOOL_LIST); + + if (!empty($session_id) && !empty($course_code)) { + $session_id = intval($session_id); if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); } - $sql = 'SELECT * FROM '.$table_main.' WHERE c_id = '.$course_id.' '.$session_condition; - } else { - $sql = 'SELECT * FROM '.$table_main.' WHERE c_id = '.$course_id.' AND session_id = 0'; - } + $sql = 'SELECT * FROM '.$table_main.' WHERE c_id = '.$course_id.' '.$session_condition; + } else { + $sql = 'SELECT * FROM '.$table_main.' WHERE c_id = '.$course_id.' AND session_id = 0'; + } if (!empty($id_list)) { array_map('intval', $id_list); $sql .=" AND id IN (".implode(', ', $id_list).") "; } - $db_result = Database::query($sql); - if ($db_result) - while ($obj = Database::fetch_object($db_result)) { - $items = array(); - $sql_items = "SELECT * FROM ".$table_item." WHERE c_id = '$course_id' AND lp_id = ".$obj->id; - $db_items = Database::query($sql_items); - while ($obj_item = Database::fetch_object($db_items)) { - $item['id'] = $obj_item->id; - $item['item_type'] = $obj_item->item_type; - $item['ref'] = $obj_item->ref; - $item['title'] = $obj_item->title; - $item['description'] = $obj_item->description; - $item['path'] = $obj_item->path; - $item['min_score'] = $obj_item->min_score; - $item['max_score'] = $obj_item->max_score; - $item['mastery_score'] = $obj_item->mastery_score; - $item['parent_item_id'] = $obj_item->parent_item_id; - $item['previous_item_id'] = $obj_item->previous_item_id; - $item['next_item_id'] = $obj_item->next_item_id; - $item['display_order'] = $obj_item->display_order; - $item['prerequisite'] = $obj_item->prerequisite; - $item['parameters'] = $obj_item->parameters; - $item['launch_data'] = $obj_item->launch_data; - $item['audio'] = $obj_item->audio; - $items[] = $item; - } + $db_result = Database::query($sql); + if ($db_result) + while ($obj = Database::fetch_object($db_result)) { + $items = array(); + $sql_items = "SELECT * FROM ".$table_item." WHERE c_id = '$course_id' AND lp_id = ".$obj->id; + $db_items = Database::query($sql_items); + while ($obj_item = Database::fetch_object($db_items)) { + $item['id'] = $obj_item->id; + $item['item_type'] = $obj_item->item_type; + $item['ref'] = $obj_item->ref; + $item['title'] = $obj_item->title; + $item['description'] = $obj_item->description; + $item['path'] = $obj_item->path; + $item['min_score'] = $obj_item->min_score; + $item['max_score'] = $obj_item->max_score; + $item['mastery_score'] = $obj_item->mastery_score; + $item['parent_item_id'] = $obj_item->parent_item_id; + $item['previous_item_id'] = $obj_item->previous_item_id; + $item['next_item_id'] = $obj_item->next_item_id; + $item['display_order'] = $obj_item->display_order; + $item['prerequisite'] = $obj_item->prerequisite; + $item['parameters'] = $obj_item->parameters; + $item['launch_data'] = $obj_item->launch_data; + $item['audio'] = $obj_item->audio; + $items[] = $item; + } - $sql_tool = "SELECT id FROM ".$table_tool." WHERE c_id = $course_id AND (link LIKE '%lp_controller.php%lp_id=".$obj->id."%' and image='scormbuilder.gif') AND visibility='1'"; - $db_tool = Database::query($sql_tool); + $sql_tool = "SELECT id FROM ".$table_tool." WHERE c_id = $course_id AND (link LIKE '%lp_controller.php%lp_id=".$obj->id."%' and image='scormbuilder.gif') AND visibility='1'"; + $db_tool = Database::query($sql_tool); - if(Database::num_rows($db_tool)) { - $visibility='1'; - } else { - $visibility='0'; - } + if(Database::num_rows($db_tool)) { + $visibility='1'; + } else { + $visibility='0'; + } - $lp = new CourseCopyLearnpath($obj->id, - $obj->lp_type, - $obj->name, - $obj->path, - $obj->ref, - $obj->description, - $obj->content_local, - $obj->default_encoding, - $obj->default_view_mod, - $obj->prevent_reinit, - $obj->force_commit, - $obj->content_maker, - $obj->display_order, - $obj->js_lib, - $obj->content_license, - $obj->debug, - $visibility, - $obj->author, - $obj->preview_image, - $obj->use_max_score, - $obj->autolunch, - $obj->created_on, - $obj->modified_on, - $obj->publicated_on, - $obj->expired_on, - $obj->session_id, - $items); - $this->course->add_resource($lp); - } + $lp = new CourseCopyLearnpath($obj->id, + $obj->lp_type, + $obj->name, + $obj->path, + $obj->ref, + $obj->description, + $obj->content_local, + $obj->default_encoding, + $obj->default_view_mod, + $obj->prevent_reinit, + $obj->force_commit, + $obj->content_maker, + $obj->display_order, + $obj->js_lib, + $obj->content_license, + $obj->debug, + $visibility, + $obj->author, + $obj->preview_image, + $obj->use_max_score, + $obj->autolunch, + $obj->created_on, + $obj->modified_on, + $obj->publicated_on, + $obj->expired_on, + $obj->session_id, + $items); + $this->course->add_resource($lp); + } - //save scorm directory (previously build_scorm_documents()) - $i = 1; - if ($dir=@opendir($this->course->backup_path.'/scorm')) { - while($file=readdir($dir)) { - if(is_dir($this->course->backup_path.'/scorm/'.$file) && !in_array($file,array('.','..'))) { - $doc = new ScormDocument($i++, '/'.$file, $file); - $this->course->add_resource($doc); - } - } - closedir($dir); - } - } + //save scorm directory (previously build_scorm_documents()) + $i = 1; + if ($dir=@opendir($this->course->backup_path.'/scorm')) { + while($file=readdir($dir)) { + if(is_dir($this->course->backup_path.'/scorm/'.$file) && !in_array($file,array('.','..'))) { + $doc = new ScormDocument($i++, '/'.$file, $file); + $this->course->add_resource($doc); + } + } + closedir($dir); + } + } - /** - * Build the glossarys - */ - function build_glossary($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); - $course_id = $course_info['real_id']; - - if (!empty($session_id) && !empty($course_code)) { - $session_id = intval($session_id); - if ($with_base_content) { + /** + * Build the glossarys + */ + function build_glossary($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $course_info = api_get_course_info($course_code); + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); + $course_id = $course_info['real_id']; + + if (!empty($session_id) && !empty($course_code)) { + $session_id = intval($session_id); + if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); } //@todo check this queries are the same ... - if (!empty($this->course->type) && $this->course->type=='partial') { - $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' '.$session_condition; - } else { - $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' '.$session_condition; - } - } else { - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); - //@todo check this queries are the same ... ayayay - if (!empty($this->course->type) && $this->course->type=='partial') { - $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' AND session_id = 0'; - } else { - $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' AND session_id = 0'; - } - } - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $doc = new Glossary($obj->glossary_id, $obj->name, $obj->description, $obj->display_order); - $this->course->add_resource($doc); - } - } + if (!empty($this->course->type) && $this->course->type=='partial') { + $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' '.$session_condition; + } else { + $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' '.$session_condition; + } + } else { + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); + //@todo check this queries are the same ... ayayay + if (!empty($this->course->type) && $this->course->type=='partial') { + $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' AND session_id = 0'; + } else { + $sql = 'SELECT * FROM '.$table_glossary.' g WHERE g.c_id = '.$course_id.' AND session_id = 0'; + } + } + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $doc = new Glossary($obj->glossary_id, $obj->name, $obj->description, $obj->display_order); + $this->course->add_resource($doc); + } + } - /* - * build session course by jhon - * */ - function build_session_course(){ - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); - $list_course = Database::get_course_list(); - $list = array(); - foreach($list_course as $_course) { - $this->course = new Course(); - $this->course->code = $_course['code']; - $this->course->type = 'partial'; - $this->course->path = api_get_path(SYS_COURSE_PATH).$_course['directory'].'/'; - $this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['directory']; - $this->course->encoding = api_get_system_encoding(); //current platform encoding - $code_course = $_course['code']; - $sql_session = "SELECT id, name, course_code FROM $tbl_session_course - INNER JOIN $tbl_session ON id_session = id - WHERE course_code = '$code_course' "; - $query_session = Database::query($sql_session); - while ($rows_session = Database::fetch_assoc($query_session)) { - $session = new CourseSession($rows_session['id'], $rows_session['name']); - $this->course->add_resource($session); - } - $list[] = $this->course; - } - return $list; - } + /* + * build session course by jhon + * */ + function build_session_course(){ + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); + $list_course = Database::get_course_list(); + $list = array(); + foreach($list_course as $_course) { + $this->course = new Course(); + $this->course->code = $_course['code']; + $this->course->type = 'partial'; + $this->course->path = api_get_path(SYS_COURSE_PATH).$_course['directory'].'/'; + $this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['directory']; + $this->course->encoding = api_get_system_encoding(); //current platform encoding + $code_course = $_course['code']; + $sql_session = "SELECT id, name, course_code FROM $tbl_session_course + INNER JOIN $tbl_session ON id_session = id + WHERE course_code = '$code_course' "; + $query_session = Database::query($sql_session); + while ($rows_session = Database::fetch_assoc($query_session)) { + $session = new CourseSession($rows_session['id'], $rows_session['name']); + $this->course->add_resource($session); + } + $list[] = $this->course; + } + return $list; + } - function build_wiki($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $course_info = api_get_course_info($course_code); - $tbl_wiki = Database::get_course_table(TABLE_WIKI); - - $course_id = $course_info['real_id']; - - if (!empty($session_id) && !empty($course_code)) { - $session_id = intval($session_id); + function build_wiki($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $course_info = api_get_course_info($course_code); + $tbl_wiki = Database::get_course_table(TABLE_WIKI); + + $course_id = $course_info['real_id']; + + if (!empty($session_id) && !empty($course_code)) { + $session_id = intval($session_id); if ($with_base_content) { $session_condition = api_get_session_condition($session_id, true, true); } else { $session_condition = api_get_session_condition($session_id, true); } - $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE c_id = '.$course_id.' '.$session_condition; - } else { - $tbl_wiki = Database::get_course_table(TABLE_WIKI); - $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE c_id = '.$course_id.' AND session_id = 0'; - } - $db_result = Database::query($sql); - while ($obj = Database::fetch_object($db_result)) { - $wiki = new Wiki($obj->id, $obj->page_id, $obj->reflink, $obj->title, $obj->content, $obj->user_id, $obj->group_id, $obj->dtime, $obj->progress, $obj->version); - $this->course->add_resource($wiki); - } - } - - /** - * Build the Surveys - */ - function build_thematic($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $table_thematic = Database :: get_course_table(TABLE_THEMATIC); - $table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE); - $table_thematic_plan = Database :: get_course_table(TABLE_THEMATIC_PLAN); + $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE c_id = '.$course_id.' '.$session_condition; + } else { + $tbl_wiki = Database::get_course_table(TABLE_WIKI); + $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE c_id = '.$course_id.' AND session_id = 0'; + } + $db_result = Database::query($sql); + while ($obj = Database::fetch_object($db_result)) { + $wiki = new Wiki($obj->id, $obj->page_id, $obj->reflink, $obj->title, $obj->content, $obj->user_id, $obj->group_id, $obj->dtime, $obj->progress, $obj->version); + $this->course->add_resource($wiki); + } + } + + /** + * Build the Surveys + */ + function build_thematic($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $table_thematic = Database :: get_course_table(TABLE_THEMATIC); + $table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE); + $table_thematic_plan = Database :: get_course_table(TABLE_THEMATIC_PLAN); $session_id = intval($session_id); if ($with_base_content) { @@ -897,26 +897,26 @@ class CourseBuilder { } else { $session_condition = api_get_session_condition($session_id, true); } - - $course_id = api_get_course_int_id(); - - $sql = "SELECT * FROM $table_thematic WHERE c_id = $course_id $session_condition "; - $db_result = Database::query($sql); - while ($row = Database::fetch_array($db_result,'ASSOC')) { - $thematic = new Thematic($row); - $sql = 'SELECT * FROM '.$table_thematic_advance.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id']; - - $result = Database::query($sql); - while ($sub_row = Database::fetch_array($result,'ASSOC')) { - $thematic->add_thematic_advance($sub_row); - } + + $course_id = api_get_course_int_id(); + + $sql = "SELECT * FROM $table_thematic WHERE c_id = $course_id $session_condition "; + $db_result = Database::query($sql); + while ($row = Database::fetch_array($db_result,'ASSOC')) { + $thematic = new Thematic($row); + $sql = 'SELECT * FROM '.$table_thematic_advance.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id']; + + $result = Database::query($sql); + while ($sub_row = Database::fetch_array($result,'ASSOC')) { + $thematic->add_thematic_advance($sub_row); + } - $items = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), $session_id); + $items = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), $session_id); //$items_from_session = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), api_get_session_id()); $thematic_plan_id_list = array(); if (!empty($items)) { - foreach($items as $item) { + foreach($items as $item) { $thematic_plan_id_list[] = $item['ref']; //$thematic_plan_complete_list[$item['ref']] = $item; } @@ -924,38 +924,38 @@ class CourseBuilder { //$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id']; $sql = "SELECT tp.* - FROM $table_thematic_plan tp INNER JOIN $table_thematic t ON (t.id=tp.thematic_id) + FROM $table_thematic_plan tp INNER JOIN $table_thematic t ON (t.id=tp.thematic_id) WHERE t.c_id = $course_id AND tp.c_id = $course_id AND thematic_id = {$row['id']} AND tp.id IN (".implode(', ', $thematic_plan_id_list).") "; - - $result = Database::query($sql); - while ($sub_row = Database::fetch_array($result,'ASSOC')) { - $thematic->add_thematic_plan($sub_row); - } - $this->course->add_resource($thematic); - } - } - - /** - * Build the Surveys - */ - function build_attendance($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); - - $course_id = api_get_course_int_id(); - - $sql = 'SELECT * FROM '.$table_attendance.' WHERE c_id = '.$course_id.' AND session_id = 0 '; - $db_result = Database::query($sql); - while ($row = Database::fetch_array($db_result,'ASSOC')) { - $obj = new Attendance($row); - $sql = 'SELECT * FROM '.$table_attendance_calendar.' WHERE c_id = '.$course_id.' AND attendance_id = '.$row['id']; - - $result = Database::query($sql); - while ($sub_row = Database::fetch_array($result,'ASSOC')) { - $obj->add_attendance_calendar($sub_row); - } - $this->course->add_resource($obj); - } - } + + $result = Database::query($sql); + while ($sub_row = Database::fetch_array($result,'ASSOC')) { + $thematic->add_thematic_plan($sub_row); + } + $this->course->add_resource($thematic); + } + } + + /** + * Build the Surveys + */ + function build_attendance($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); + + $course_id = api_get_course_int_id(); + + $sql = 'SELECT * FROM '.$table_attendance.' WHERE c_id = '.$course_id.' AND session_id = 0 '; + $db_result = Database::query($sql); + while ($row = Database::fetch_array($db_result,'ASSOC')) { + $obj = new Attendance($row); + $sql = 'SELECT * FROM '.$table_attendance_calendar.' WHERE c_id = '.$course_id.' AND attendance_id = '.$row['id']; + + $result = Database::query($sql); + while ($sub_row = Database::fetch_array($result,'ASSOC')) { + $obj->add_attendance_calendar($sub_row); + } + $this->course->add_resource($obj); + } + } } From 9946f57258c355129e20fa63d4cee290ef932c56 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 00:19:16 -0500 Subject: [PATCH 013/124] Course copy: Only copy first forum post in any thread to avoid inconsistency when restoring in another course - refs #5462 --- main/coursecopy/classes/CourseBuilder.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 4b8e4c24f2..048b2ec733 100644 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -309,7 +309,7 @@ class CourseBuilder { while ($obj = Database::fetch_object($db_result)) { $forum_topic = new ForumTopic($obj); $this->course->add_resource($forum_topic); - $this->build_forum_posts($obj->thread_id, $obj->forum_id); + $this->build_forum_posts($obj->thread_id, $obj->forum_id, true); } } @@ -317,7 +317,7 @@ class CourseBuilder { * Build the forum-posts * TODO: All tree structure of posts should be built, attachments for example. */ - function build_forum_posts($thread_id = null, $forum_id = null) { + function build_forum_posts($thread_id = null, $forum_id = null, $only_first_post = false) { $table = Database :: get_course_table(TABLE_FORUM_POST); $course_id = api_get_course_int_id(); $sql = "SELECT * FROM $table WHERE c_id = $course_id "; @@ -325,7 +325,8 @@ class CourseBuilder { $forum_id = intval($forum_id); $thread_id = intval($thread_id); $sql .= " AND thread_id = $thread_id AND forum_id = $forum_id "; - } + } + $sql .= " ORDER BY post_id ASC LIMIT 1"; $db_result = Database::query($sql); while ($obj = Database::fetch_object($db_result)) { $forum_post = new ForumPost($obj); From 65147631e762bef7be82468846826d86a64b11ec Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 00:29:48 -0500 Subject: [PATCH 014/124] Updated version numbers for 1.9.2 package --- main/install/index.php | 3 ++- main/install/install.lib.php | 2 +- main/install/version.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main/install/index.php b/main/install/index.php index 90d30fb8e5..71c0b6f47c 100644 --- a/main/install/index.php +++ b/main/install/index.php @@ -110,7 +110,7 @@ error_reporting(E_ALL); // Upgrading from any subversion of 1.6 is just like upgrading from 1.6.5 $update_from_version_6 = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5'); // Upgrading from any subversion of 1.8 avoids the additional step of upgrading from 1.6 -$update_from_version_8 = array('1.8', '1.8.2', '1.8.3', '1.8.4', '1.8.5', '1.8.6', '1.8.6.1', '1.8.6.2','1.8.7','1.8.7.1','1.8.8','1.8.8.2', '1.8.8.4', '1.8.8.6'); +$update_from_version_8 = array('1.8', '1.8.2', '1.8.3', '1.8.4', '1.8.5', '1.8.6', '1.8.6.1', '1.8.6.2','1.8.7','1.8.7.1','1.8.8','1.8.8.2', '1.8.8.4', '1.8.8.6', '1.9.0'); $my_old_version = ''; $tmp_version = get_config_param('dokeos_version'); @@ -849,6 +849,7 @@ if (@$_POST['step2']) { include 'update-configuration.inc.php'; break; + case '1.9.0': default: break; } diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 6f0dbf5afe..8539468d25 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -1516,7 +1516,7 @@ function get_contact_registration_form() {
-
+
diff --git a/main/install/version.php b/main/install/version.php index aa2adda96b..06675c4339 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -12,9 +12,9 @@ * Variables used from the main/install/index.php */ $new_version = '1.9.2'; -$new_version_status = 'Unstable'; +$new_version_status = 'Stable'; $new_version_last_id = 1; -$new_version_stable = false; +$new_version_stable = true; $new_version_major = false; $software_name = 'Chamilo'; $software_url = 'http://www.chamilo.org/'; From 5e64ab6ca5b74bcc7045e8a9d00f7c927a18dfcf Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 02:02:09 -0500 Subject: [PATCH 015/124] Updated changelog for 1.9.2 --- documentation/changelog.html | 92 ++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/documentation/changelog.html b/documentation/changelog.html index 9c31577445..03e53732b3 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -41,20 +41,102 @@

Chamilo Changelog

This is our technical changelog, aimed at providing you a list of the new features, small changes and bug fixes as well as the security issues, style changes and known issues that remain present. This changelog is provided version by version, latest versions first and helps you locate when a specific feature has been made available in Chamilo. If you would like a shorter list of features or a list of overall features, please check our website: http://www.chamilo.org/

-

Note: most #xyz references are issue numbers you can find in our public bug tracking system

+

Note: most #wxyz references are issue numbers you can find in our public bug tracking system

 

-

Chamilo 1.10.0 - ???, 31st of ???, 2012

+

Chamilo 1.9.2 - Hanga Roa, 27th of September, 2012

Release notes - summary

-

Chamilo 1.10.0 is a major stable version with loads of added features.

+

Chamilo 1.9.2 is a minor stable version with a series of improvements on top of 1.9.0.

Release name

-

Vogüé is a small town in the French region of Rhône-Alpes, and one of the most beautiful villages of France. It features a 12th century, a generally very pretty landscape and is one of the few remote towns in current growth. One of our new development team members chose this familiar town because it inspires stability and diversity.

+

Hanga Roa is the capital city of Rapa Nui, the Easter Island. The entire Rapa Nui culture is filled with mystery and assumptions about where and how the first Rapa Nui people came to be on the island, but it is accepted by many that the main strain came from Polynesia a long time ago. The population there is around 3,300 but warmly welcomes tons of tourists every year, a bit in the image of the small team of Chamilo now serving more than 1.4M users worldwide, with a welcoming 1.9.2 version that will help you get more time to yourself...

New Features

+
    +
  • Course home: Allow for the publication of direct links to learning paths in the sessions (#3367)
  • +
  • Global: We now show th teacher's professional "card" when clicking on the teacher's name in the courses list (#3388)
  • +
  • Global: Added option to send the student to the courses catalog the first time he logs in (#3898)
  • +
  • Exercises: Added "success score" to exercises (#4541)
  • +
  • Exercises: Added automated distribution of score in specific question type (#4656)
  • +
  • Attendances: Added PDF + print button to attendance sheets (#5069)
  • +
  • Assignments: Users can now see if they have already uploaded their assignment (#5145)
  • +
  • Global: Added a course-specific registration link to increase speed of auto-registration (#5299)
  • +
  • Exercises: Success score for an exercise can now be set manually to allow for specific percentages (#5330)
  • +
  • Documents: The images and audio integrated apps now check available space left on disk before saving (#5346)
  • +
  • Sessions: Added an "official" start and end date to the sessions
  • +
  • Forum: Forum categories, fora and forum threads (but not forum posts to avoid inconsistencies in users property) can now be copied from one course to another (#5462)
  • +
  • Users: Added the possibility for teachers to add students to their course through users classes (#5514)
  • +

Improvements

+
    +
  • Exercises: Exercises and questions can now be copied inside or between courses, and be better included into learning paths (#651)
  • +
  • Global: Improved WYSIWYG behaviour, now more natural (#1780)
  • +
  • Interface: The action icons bar was improved (#2810)
  • +
  • Social network: Added an icon to show whether users are on- or offline (#3316)
  • +
  • Exercises: Improved interface in true/false/don't know question type (#3370)
  • +
  • Learning paths: Fixed a series of small issues with the learning paths edition page (#3533)
  • +
  • Global: Improvements on various timezone issues (#3747)
  • +
  • Exercises: The test description now only shows on the test start page (#3845)
  • +
  • Global: Fixed CSS positionning problem (#4075)
  • +
  • Learning paths: Improved error message for too large SCORM files (#4142)
  • +
  • Attendances: Reduced steps to create attendance sheets (#4484)
  • +
  • Forum: E-mail notifications can now be sent daily only (#4761)
  • +
  • Plugins: Improved the BBB 0.8 plugin (#4840 & #5312)
  • +
  • Global: Enabled custom pages feature, which allows the system to server specific pages after login to specific user roles (#4850)
  • +
  • Survey: Added surveys in item_property tracking (#4923)
  • +
  • Global: Disable auto-capitalize when using mobile phones (#5116)
  • +
  • Agenda: Improved the personal agenda items system (#5201)
  • +
  • Global: Added a link for portal admins to hide the "Popular courses" block (#5268)
  • +
  • Social network: Deleting private messages now requires confirmation (#5269)
  • +
  • Global: Invalid address errors are now saved to the default error log (#5306)
  • +
  • Exercises: Exercises with a pass % of 0 disable the pass % feature (#5383)
  • +
  • Exercises: Small aesthetics improvements for true/false/dunno answer type (#5385)
  • +
  • Users: Added the registration date in the users lists tables (#5473)
  • +
  • Course copy: Improved error message on missing file (#5515)
  • +
  • Exercises: Added grey icon for audio questions when exercise is bloqued (#5516)
  • +

Debugging

+
    +
  • Global: Fixed a bug with XLS export encoding (#1831)
  • +
  • Documents: Fixed bug editing jpg/png with SVGedit (#3261)
  • +
  • Exercises: Fixed missing reports on some questions in test feedback (#3347)
  • +
  • Learning paths: Fixed tab-switching issue in LP edition (#3352)
  • +
  • Assignments: Fixed issue by which students could send assignments passed the end date (#3918)
  • +
  • Global: Fixed issue by which password reminder stopped working in some cases (#4032)
  • +
  • Global: Fixed bug by which users lost their sessions when the Wiris plugin was enabled (#4468)
  • +
  • Assessments: Fixed issue with the QR code generation in certificates (#5015)
  • +
  • Plugins: Fixed issue when installing the BBB plugin when using subdirectories (#5103)
  • +
  • Learning paths: Fixed the learning path tracking reset buttong (#5239)
  • +
  • Learning paths: Fixed issue with HotPotatoes files paths being shown (#5253)
  • +
  • Learning paths: Fixed blanck page when editing a document without title (#5265)
  • +
  • Learning paths: Fixed issues in learning paths export (#5286)
  • +
  • Social network: Fixed chat box remaining enabled when social network is not (#5295)
  • +
  • Exercises: Fixed issue with exercise's start time not being saved (#5301)
  • +
  • Migration: Fixed courses disappearing when migrating from 1.8 to 1.9 (#5302)
  • +
  • Global: Fixed font preview being different from the final result (#5303)
  • +
  • Exercises: Fixed very rare case where the expiration of time when reviewing questions with delete results (#5304)
  • +
  • Exercises: Fixed display bug in modal results window (#5311)
  • +
  • Social network: Fixed wrong extra text field in reply form in social messaging (#5327)
  • +
  • Learning paths: Fixed a fatal error in learner reporting (#5347)
  • +
  • Agenda: Fixed wrong month in calendar event popup (#5348)
  • +
  • Global: Fixed issue by which profile fields of type select did not unfold (#5351)
  • +
  • Sessions: Fixed issue by which access delays did not influence the visibility in courses list (#5353)
  • +
  • Global: Fixed online e-mail editor setting (#5356)
  • +
  • Exercises: Fixed but in exercises scenario (#5375)
  • +
  • Exercixes: Fixed issue with open questions (#5434)
  • +
  • Global: Fixed issue when enabling openid without the right config in the right place (#5463)
  • +
  • Assignments: Fixed SQL error when adding an assignment (#5484)
  • +
  • Global: Fixed FCKEditor error in assessments model creation (#5490)
  • +
  • Global: Fixed courses backup (broken by the implementation of forum backup) (#5499)
  • +
  • Assessments: Qualification's icon did not appear on tasks (#5517)
  • +
  • Exercises: Fixed issue with reviewed question and 0 score (#5517)
  • +
  • Global: Fixed missing student view button (#5528)
  • +
  • Survey: Fixed issue sending survey invitations by e-mail (#5529)
  • +
  • Admin: Fixed name clash between home-made function http_request() and a pre-defined http_request() function (#5531)
  • +
  • Users: Problem accessing the course groups (#5537)
  • +
  • Social network: An user could not modify its own official code, even if configured to be possible (#5538)
  • +

Chamilo 1.9.0 - Vogüé, 31st of July, 2012

@@ -2177,4 +2259,4 @@ a simple videoconferencing interface.

Valid CSS - \ No newline at end of file + From 4c2f2f88a90cc1ac8bb94e26af0b7326c51aae76 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 02:06:34 -0500 Subject: [PATCH 016/124] Trying to find all credits to add --- documentation/credits.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/documentation/credits.html b/documentation/credits.html index 82d84f38a8..04263a78a8 100644 --- a/documentation/credits.html +++ b/documentation/credits.html @@ -124,6 +124,9 @@ In the following credits, when possible, we tried to put the latest contributors

Quality Assurance

  • Yannick Warnier as QA coordinator
  • +
  • Yoselyn Castillo
  • +
  • Jeremy Saavedra
  • +
  • Coursenligne on the forum
  • Noa Orizales, through numerous implementations in Spain
  • Hector Lacherre and colleagues from USIL, Lima
  • Carlos Vargas
  • @@ -136,6 +139,7 @@ In the following credits, when possible, we tried to put the latest contributors
    • Yannick Warnier - implementation of CDN, SQL improvements, memcached and documentation in the optimization guide
    • Ivan Tcholakov - language loading performances improvements in 1.8
    • +
    • Julio Montoya
    • Arnaud Ligot
    • Jérôme Warnier
    • Ludwig Chauvin
    • @@ -656,6 +660,7 @@ There are too much translators to list them all. Please check http://translate.c
    • Ludovic Gasc, France, for optimization patch in LMS 1.9
    • Juho Paranko, Finland, for bug reports in LMS 1.9
    • All the supporting parents, partners, children, friends, colleagues and sometimes students, of the very special geeks that we are, for their continous support and inspiration
    • +
    • Jeremy Saavedra, for bug reports in LMS 1.9.2
    @@ -679,6 +684,8 @@ These institutions and companies have either contributed to the Chamilo project
  • Commission Scolaire des Hautes-Rivières, project TIC-FP, Canada
  • ACTA VZW, Belgium
  • NoSoloRed, Spain
  • +
  • ICPNA, Peru
  • +
  • Universidad Autónoma, Chile
From a01afb8c798cc36fcca4727057f3cc4beee18736 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 02:12:04 -0500 Subject: [PATCH 017/124] Updated a few more things --- documentation/installation_guide.html | 2 +- documentation/optimization.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/installation_guide.html b/documentation/installation_guide.html index edb21aeb7f..50d61b97fd 100644 --- a/documentation/installation_guide.html +++ b/documentation/installation_guide.html @@ -299,7 +299,7 @@ date.timezone = 'America/New_York'

3. Upgrade from a -previous version of Chamilo LMS (1.*) or Dok€os (<2.0)

+previous version of Chamilo LMS (1.*) or Dok€os (<2.0) Before upgrading, we heavily recommend you do a full backup of the previous Chamilo or Dok€os directories and databases. If you are unsure how to achieve this please ask your hosting provider for advice.
diff --git a/documentation/optimization.html b/documentation/optimization.html index f66c91f02c..a9671859dc 100644 --- a/documentation/optimization.html +++ b/documentation/optimization.html @@ -9,7 +9,7 @@
-

Chamilo 1.8.8.4 : Optimization Guide

+

Chamilo : Optimization Guide

Documentation > Optimization Guide From fe16060d4fe43c75668ee94e74ebcf9d4d4ec984 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 02:13:47 -0500 Subject: [PATCH 018/124] New language vars --- main/lang/english/trad4all.inc.php | 1 + main/lang/french/index.inc.php | 1 + main/lang/french/trad4all.inc.php | 7 +++++++ main/lang/slovenian/admin.inc.php | 2 ++ main/lang/slovenian/agenda.inc.php | 1 + main/lang/slovenian/trad4all.inc.php | 8 ++++++++ main/lang/spanish/trad4all.inc.php | 1 + 7 files changed, 21 insertions(+) diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index eb8d1188ac..4a1fcdf0b6 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -976,6 +976,7 @@ $NumberOfCoursesPrivate = "Number of private courses"; $NumberOfCoursesClosed = "Number of closed courses"; $NumberOfCoursesTotal = "Total number of courses"; $NumberOfUsersActive = "Number of active users"; +$ReturnToCourseList = "Return to the course list"; $dateFormatShortNumberNoYear = "%d/%m"; $CourseTutor = "Course tutor"; $StudentInSessionCourse = "Student in session course"; diff --git a/main/lang/french/index.inc.php b/main/lang/french/index.inc.php index 1dd8cea8df..d33da70136 100644 --- a/main/lang/french/index.inc.php +++ b/main/lang/french/index.inc.php @@ -77,5 +77,6 @@ $Username = "Nom d'utilisateur"; $GoAheadAndBrowseOurCourseCatalogXOnceRegisteredYouWillSeeTheCourseHereX = "Révisez notre catalogue de cours %s pour vous inscrire à votre cours préféré. Une fois inscrit(e), votre cours apparaîtra %s, à la place de ce message."; $HelloXAsYouCanSeeYourCourseListIsEmpty = "Bonjour %s, nous vous souhaitons la bienvenue,
Comme vous pouvez le voir, votre liste de cours est vide. C'est parce que vous ne nous êtes pas encore inscrit à un cours!"; +$PleaseAllowUsALittleTimeToSubscribeYouToOneOfOurCourses = "Merci de nous donner un moment pour vous inscrire à l'un de nos cours. Si vous pensez avoir été oublié, merci de contacter les administrateurs du site. Vous pouvez généralement trouver leurs informations de contact dans le pied de page."; $Profile = "Profil"; ?> \ No newline at end of file diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php index 69f4c768e1..615abc073d 100644 --- a/main/lang/french/trad4all.inc.php +++ b/main/lang/french/trad4all.inc.php @@ -976,6 +976,13 @@ $NumberOfCoursesPrivate = "Nombre de cours privés"; $NumberOfCoursesClosed = "Nombre de cours fermés"; $NumberOfCoursesTotal = "Nombre total de cours"; $NumberOfUsersActive = "Nombre d'utilisateurs actifs"; +$ReturnToCourseList = "Retour liste de cours"; +$dateFormatShortNumberNoYear = "%d/%m"; +$CourseTutor = "Tuteur de cours"; +$StudentInSessionCourse = "Étudiant dans cours de session"; +$StudentInCourse = "Étudiant dans le cours"; +$SessionGeneralCoach = "Tuteur général de la session"; +$SessionCourseCoach = "Tuteur de cours dans la session"; $Admin = "Admin"; $UserNotAttendedSymbol = "NP"; $UserAttendedSymbol = "P"; diff --git a/main/lang/slovenian/admin.inc.php b/main/lang/slovenian/admin.inc.php index 2ef3e8c01d..1bda89a244 100644 --- a/main/lang/slovenian/admin.inc.php +++ b/main/lang/slovenian/admin.inc.php @@ -1256,6 +1256,8 @@ $SessionStartDate = "Datum pričetka dostopa"; $SessionDisplayEndDate = "Prikazan datum zaključka"; $SessionDisplayStartDate = "Prikazan datum začetka"; $UserHasNoCourse = "Ta uporabnik ni vpisan v noben tečaj"; +$SessionTutorsCanSeeExpiredSessionsResultsComment = "Ali bo tutor seje videl poročila seje po tem, ko bo seja pretekla!?"; +$SessionTutorsCanSeeExpiredSessionsResultsTitle = "Vidnost poročil tutorja seje"; $TheXMLImportLetYouAddMoreInfoAndCreateResources = "XML uvoz omogoča dodajanje več informacije in hkrati pri uvozu ustvari zahtevane elemente (tečaje, uporabnike). CSV uvoz zgolj kreira seje in omogoča prirejanje obstoječih resursov sejam."; $ShowLinkBugNotificationTitle = "Pokoži povezavo za poročanje o napakah"; $ShowLinkBugNotificationComment = "V glavi prikaže povezavo na stran za poročanje o napakah (http://support.chamilo.org). S klikom na povezavo se prestavite na podporno stran z Wiki stranjo, ki opisuje proces poročanja o odkritih napakah."; diff --git a/main/lang/slovenian/agenda.inc.php b/main/lang/slovenian/agenda.inc.php index f954f7025c..bf9679a72a 100644 --- a/main/lang/slovenian/agenda.inc.php +++ b/main/lang/slovenian/agenda.inc.php @@ -75,6 +75,7 @@ $AgendaSortChronologicallyDown = "Padajoče"; $ItemForUserSelection = "Izbira uporabnikov"; $IsNotiCalFormatFile = "Datoteka ni v iCal obliki"; $RepeatEvent = "Ponovi dogodek"; +$SessionCalendar = "Koledar seje"; $RepeatDate = "Ponovi datum"; $EndDateMustBeMoreThanStartDate = "Končni datum mora biti kasnejši od začetnega datuma"; $SelectACourse = "Izberi tečaj"; diff --git a/main/lang/slovenian/trad4all.inc.php b/main/lang/slovenian/trad4all.inc.php index 611c10b6e4..cbd0b66cea 100644 --- a/main/lang/slovenian/trad4all.inc.php +++ b/main/lang/slovenian/trad4all.inc.php @@ -937,13 +937,21 @@ $DateTime = "Datum in čas"; $Item = "Element"; $Never = "Nikoli"; $CopyLabelSuffix = "Kopiraj"; +$SkillsWheel = "Kolo veščin"; $Legend = "Legenda"; $ClickToZoom = "Povečaj"; $SkillXWithCourseX = "%s s %s"; $SkillRoot = "Koren"; +$ViewSkillsWheel = "Poglej kolo veščin"; $MissingXStepsToMatch = "Manjka korakov: %s"; $Rank = "Rang"; +$CurrentlyLearning = "Trenutno se uči"; +$SkillsAcquired = "Dosežene veščine"; +$AddSkillToProfileSearch = "Dodaj veščino k iskanju v profilu"; $ShortCode = "Kratka koda"; +$CreateChildSkill = "Ustvari podrejeno veščino"; +$IsThisWhatYouWereLookingFor = "Je to tisto, kar ste iskali?"; +$WhatSkillsAreYouLookingFor = "Katere veščine želite poiskati?"; $ProfileSearch = "Iskanje profila"; $here = "tule"; $ImportUsers = "Uvozi uporabnike"; diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index a3f838413a..019aa93159 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -977,6 +977,7 @@ $NumberOfCoursesPrivate = "Número de cursos privados"; $NumberOfCoursesClosed = "Número de cursos cerrados"; $NumberOfCoursesTotal = "Número total de cursos"; $NumberOfUsersActive = "Número de usuarios activos"; +$ReturnToCourseList = "Regreso a lista de cursos"; $dateFormatShortNumberNoYear = "%d/%m"; $CourseTutor = "Tutor de curso"; $StudentInSessionCourse = "Estudiante en un curso de sesión"; From c5358bcdddf53a4f6b545af644fbdf4f40fa471b Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 02:26:36 -0500 Subject: [PATCH 020/124] Automatic packaging version change - Stable 2 - refs #4796 --- main/install/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/install/version.php b/main/install/version.php index 06675c4339..0f16eac241 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -13,7 +13,7 @@ */ $new_version = '1.9.2'; $new_version_status = 'Stable'; -$new_version_last_id = 1; +$new_version_last_id = 2; $new_version_stable = true; $new_version_major = false; $software_name = 'Chamilo'; From 9c56000f244a972765113d3776ae992f514e06b7 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 02:28:11 -0500 Subject: [PATCH 021/124] Minor - Back to v1 --- main/install/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/install/version.php b/main/install/version.php index 0f16eac241..06675c4339 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -13,7 +13,7 @@ */ $new_version = '1.9.2'; $new_version_status = 'Stable'; -$new_version_last_id = 2; +$new_version_last_id = 1; $new_version_stable = true; $new_version_major = false; $software_name = 'Chamilo'; From f093bfde2073ebf6662a41923b9fa242d5f5b9fc Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Thu, 27 Sep 2012 17:41:41 +0200 Subject: [PATCH 022/124] Fix constant declaration in groupmanager.lib.php -ref #5544 --- main/inc/lib/groupmanager.lib.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 6cb6c45a8d..99e7d46499 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -12,6 +12,10 @@ require_once 'fileManage.lib.php'; require_once 'fileUpload.lib.php'; require_once 'document.lib.php'; +//define ("TOOL_NOT_AVAILABLE", "0"); +//define ("TOOL_PUBLIC", "1"); +//define ("TOOL_PRIVATE", "2"); + /** * infinite */ @@ -24,15 +28,6 @@ define("MEMBER_PER_GROUP_NO_LIMIT", "0"); * No limit on the number of groups per user */ define("GROUP_PER_MEMBER_NO_LIMIT", "0"); -/** - * The tools of a group can have 3 states - * - not available - * - public - * - private - */ -define("TOOL_NOT_AVAILABLE", "0"); -define("TOOL_PUBLIC", "1"); -define("TOOL_PRIVATE", "2"); /** * Constants for the available group tools */ @@ -62,9 +57,20 @@ define("DEFAULT_GROUP_CATEGORY", 2); */ class GroupManager { //CLASS CONSTANTS + /** + * The tools of a group can have 3 states + * - not available + * - public + * - private + */ const TOOL_NOT_AVAILABLE = 0; + const TOOL_PUBLIC = 1; + const TOOL_PRIVATE = 2; + const VIRTUAL_COURSE_CATEGORY = 1; const DEFAULT_GROUP_CATEGORY = 2; const MEMBER_PER_GROUP_NO_LIMIT = 0; + + //GROUP FUNCTIONS private function __construct() { } From d520ea28e633616b4d6975d0937a01b83674bd16 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 28 Sep 2012 00:22:51 +0200 Subject: [PATCH 023/124] Sending my changes of this see #5544 r ea080a27a871 --- main/inc/lib/groupmanager.lib.php | 155 ++++++++++++++---------------- 1 file changed, 73 insertions(+), 82 deletions(-) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 99e7d46499..531ac04822 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -12,42 +12,6 @@ require_once 'fileManage.lib.php'; require_once 'fileUpload.lib.php'; require_once 'document.lib.php'; -//define ("TOOL_NOT_AVAILABLE", "0"); -//define ("TOOL_PUBLIC", "1"); -//define ("TOOL_PRIVATE", "2"); - -/** - * infinite - */ -define("INFINITE", "99999"); -/** - * No limit on the number of users in a group - */ -define("MEMBER_PER_GROUP_NO_LIMIT", "0"); -/** - * No limit on the number of groups per user - */ -define("GROUP_PER_MEMBER_NO_LIMIT", "0"); -/** - * Constants for the available group tools - */ -define("GROUP_TOOL_FORUM", "0"); -define("GROUP_TOOL_DOCUMENTS", "1"); -define("GROUP_TOOL_CALENDAR","2"); -define("GROUP_TOOL_ANNOUNCEMENT","3"); -define("GROUP_TOOL_WORK","4"); -define("GROUP_TOOL_WIKI", "5"); -define("GROUP_TOOL_CHAT", "6"); - -/** - * Fixed id's for group categories - * - VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the - * virtual course of a course - * - DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform- - * setting), all groups are created in this 'dummy'-category - */ -define("VIRTUAL_COURSE_CATEGORY", 1); -define("DEFAULT_GROUP_CATEGORY", 2); /** * This library contains some functions for group-management. * @author Bart Mollet @@ -56,20 +20,48 @@ define("DEFAULT_GROUP_CATEGORY", 2); * be used outside a session. */ class GroupManager { - //CLASS CONSTANTS + //- VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the virtual course of a course + CONST VIRTUAL_COURSE_CATEGORY = 1; + + //DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform-setting), all groups are created in this 'dummy'-category + CONST DEFAULT_GROUP_CATEGORY = 2; + + /** + * infinite + */ + CONST INFINITE = 99999; + /** + * No limit on the number of users in a group + */ + CONST MEMBER_PER_GROUP_NO_LIMIT = 0; + /** + * No limit on the number of groups per user + */ + CONST GROUP_PER_MEMBER_NO_LIMIT = 0; /** * The tools of a group can have 3 states * - not available * - public * - private */ - const TOOL_NOT_AVAILABLE = 0; - const TOOL_PUBLIC = 1; - const TOOL_PRIVATE = 2; - const VIRTUAL_COURSE_CATEGORY = 1; - const DEFAULT_GROUP_CATEGORY = 2; - const MEMBER_PER_GROUP_NO_LIMIT = 0; - + CONST TOOL_NOT_AVAILABLE = 0; + CONST TOOL_PUBLIC = 1; + CONST TOOL_PRIVATE = 2; + /** + * Constants for the available group tools + */ + CONST GROUP_TOOL_FORUM = 0; + CONST GROUP_TOOL_DOCUMENTS = 1; + CONST GROUP_TOOL_CALENDAR = 2; + CONST GROUP_TOOL_ANNOUNCEMENT = 3; + CONST GROUP_TOOL_WORK = 4; + CONST GROUP_TOOL_WIKI = 5; + CONST GROUP_TOOL_CHAT = 6; + + + + + //GROUP FUNCTIONS private function __construct() { @@ -183,7 +175,7 @@ class GroupManager { $groups = array (); $thisGroup= array(); while ($thisGroup = Database::fetch_array($groupList)) { - if ($thisGroup['category_id'] == VIRTUAL_COURSE_CATEGORY) { + if ($thisGroup['category_id'] == self::VIRTUAL_COURSE_CATEGORY) { $sql = "SELECT title FROM $table_course WHERE code = '".$thisGroup['name']."'"; $obj = Database::fetch_object(Database::query($sql)); $thisGroup['name'] = $obj->title; @@ -298,7 +290,7 @@ class GroupManager { public static function create_subgroups ($group_id, $number_of_groups) { $course_id = api_get_course_int_id(); $table_group = Database :: get_course_table(TABLE_GROUP); - $category_id = self :: create_category('Subgroups', '', TOOL_PRIVATE, TOOL_PRIVATE, 0, 0, 1, 1); + $category_id = self :: create_category('Subgroups', '', GroupManager::TOOL_PRIVATE, GroupManager::TOOL_PRIVATE, 0, 0, 1, 1); $users = self :: get_users($group_id); $group_ids = array (); @@ -320,12 +312,12 @@ class GroupManager { * Create groups from all virtual courses in the given course. */ public static function create_groups_from_virtual_courses() { - self :: delete_category(VIRTUAL_COURSE_CATEGORY); - $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', TOOL_NOT_AVAILABLE, TOOL_NOT_AVAILABLE, 0, 0, 1, 1); + self :: delete_category(self::VIRTUAL_COURSE_CATEGORY); + $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', GroupManager::TOOL_NOT_AVAILABLE, GroupManager::TOOL_NOT_AVAILABLE, 0, 0, 1, 1); $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); $course_id = api_get_course_int_id(); - $sql = "UPDATE ".$table_group_cat." SET id=".VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; + $sql = "UPDATE ".$table_group_cat." SET id=".self::VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; Database::query($sql); $course = api_get_course_info(); $course['code'] = $course['sysCode']; @@ -342,7 +334,7 @@ class GroupManager { $members[] = $user['user_id']; } } - $id = self :: create_group($group_course['code'], VIRTUAL_COURSE_CATEGORY, 0, count($members)); + $id = self :: create_group($group_course['code'], self::VIRTUAL_COURSE_CATEGORY, 0, count($members)); self :: subscribe_users($members, $id); $ids[] = $id; } @@ -678,7 +670,7 @@ class GroupManager { max_student = '".Database::escape_string($maximum_number_of_students)."' "; Database::query($sql); $id = Database::insert_id(); - if ($id == VIRTUAL_COURSE_CATEGORY) { + if ($id == self::VIRTUAL_COURSE_CATEGORY) { $sql = "UPDATE ".$table_group_category." SET id = ". ($id +1)." WHERE c_id = $course_id AND id = $id"; Database::query($sql); return $id +1; @@ -858,8 +850,10 @@ class GroupManager { * @return void */ public static function fill_groups ($group_ids) { + global $_course; + $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids); - $group_ids = array_map('intval',$group_ids); + $group_ids = array_map('intval', $group_ids); if (api_is_course_coach()) { for ($i=0 ; $i< count($group_ids) ; $i++) { @@ -872,8 +866,7 @@ class GroupManager { return false; } } - - global $_course; + $category = self::get_category_from_group($group_ids[0]); $groups_per_user = $category['groups_per_user']; @@ -881,25 +874,23 @@ class GroupManager { $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $session_id = api_get_session_id(); - $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); - $number_groups_per_user = ($groups_per_user == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $groups_per_user); + $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); + $number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); /* * Retrieve all the groups where enrollment is still allowed * (reverse) ordered by the number of place available */ - $course_id = api_get_course_int_id(); - + $course_id = api_get_course_int_id(); $sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student FROM ".$group_table." g - LEFT JOIN ".$group_user_table." ug - ON g.id = ug.group_id - WHERE - g.c_id = $course_id AND + LEFT JOIN ".$group_user_table." ug ON + g.c_id = $course_id AND ug.c_id = $course_id AND g.id = ug.group_id + WHERE g.id IN (".implode(',', $group_ids).") GROUP BY (g.id) - HAVING (nbPlaces > 0 OR g.max_student = ".MEMBER_PER_GROUP_NO_LIMIT.") + HAVING (nbPlaces > 0 OR g.max_student = ".GroupManager::MEMBER_PER_GROUP_NO_LIMIT.") ORDER BY nbPlaces DESC"; $sql_result = Database::query($sql); $group_available_place = array (); @@ -986,7 +977,7 @@ class GroupManager { $db_result = Database::query("SELECT max_student FROM $table_group WHERE c_id = $course_id AND id = $group_id"); $db_object = Database::fetch_object($db_result); if ($db_object->max_student == 0) { - return INFINITE; + return self::INFINITE; } return $db_object->max_student; } @@ -1082,8 +1073,8 @@ class GroupManager { $result = CourseManager :: is_user_subscribed_in_real_or_linked_course($user_id, $course_code); $result = !self :: is_subscribed($user_id, $group_id); $result &= (self :: number_of_students($group_id) < self :: maximum_number_of_students($group_id)); - if ($category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT) { - $category['groups_per_user'] = INFINITE; + if ($category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT) { + $category['groups_per_user'] = self::INFINITE; } $result &= (self :: user_in_number_of_groups($user_id, $category['id']) < $category['groups_per_user']); $result &= !self :: is_tutor_of_group($user_id, $group_id); @@ -1421,7 +1412,7 @@ class GroupManager { public static function get_complete_list_of_users_that_can_be_added_to_group ($course_code, $group_id) { global $_course, $_user; $category = self :: get_category_from_group($group_id, $course_code); - $number_of_groups_limit = $category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $category['groups_per_user']; + $number_of_groups_limit = $category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $category['groups_per_user']; $real_course_code = $_course['sysCode']; $real_course_info = Database :: get_course_info($real_course_code); $real_course_user_list = CourseManager :: get_user_list_from_course_code($real_course_code); @@ -1545,25 +1536,25 @@ class GroupManager { } switch ($tool) { - case GROUP_TOOL_FORUM : + case self::GROUP_TOOL_FORUM : $state_key = 'forum_state'; break; - case GROUP_TOOL_DOCUMENTS : + case self::GROUP_TOOL_DOCUMENTS : $state_key = 'doc_state'; break; - case GROUP_TOOL_CALENDAR : + case self::GROUP_TOOL_CALENDAR : $state_key = 'calendar_state'; break; - case GROUP_TOOL_ANNOUNCEMENT : + case self::GROUP_TOOL_ANNOUNCEMENT : $state_key = 'announcements_state'; break; - case GROUP_TOOL_WORK : + case self::GROUP_TOOL_WORK : $state_key = 'work_state'; break; - case GROUP_TOOL_WIKI : + case self::GROUP_TOOL_WIKI : $state_key = 'wiki_state'; break; - case GROUP_TOOL_CHAT : + case self::GROUP_TOOL_CHAT : $state_key = 'chat_state'; break; default: @@ -1580,24 +1571,24 @@ class GroupManager { if (!empty($category_group_info)) { //if exists check the category group status first - if ($category_group_info[$state_key] == TOOL_NOT_AVAILABLE) { + if ($category_group_info[$state_key] == GroupManager::TOOL_NOT_AVAILABLE) { return false; - } elseif($category_group_info[$state_key] == TOOL_PRIVATE && !$user_is_in_group) { + } elseif($category_group_info[$state_key] == GroupManager::TOOL_PRIVATE && !$user_is_in_group) { return false; } } //is_user_in_group() is more complete that the is_subscribed() function - if ($group_info[$state_key] == TOOL_NOT_AVAILABLE) { + if ($group_info[$state_key] == GroupManager::TOOL_NOT_AVAILABLE) { return false; - } elseif ($group_info[$state_key] == TOOL_PUBLIC) { + } elseif ($group_info[$state_key] == self::TOOL_PUBLIC) { return true; } elseif (api_is_allowed_to_edit(false,true)) { return true; } elseif($group_info['tutor_id'] == $user_id) { //this tutor implementation was dropped return true; - } elseif($group_info[$state_key] == TOOL_PRIVATE && !$user_is_in_group) { + } elseif($group_info[$state_key] == GroupManager::TOOL_PRIVATE && !$user_is_in_group) { return false; } else { return $user_is_in_group; @@ -1657,7 +1648,7 @@ class GroupManager { $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $session_id = api_get_session_id(); $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['sysCode'], true, $session_id); - $number_groups_per_user = ($groups_per_user == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $groups_per_user); + $number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); $course_id = api_get_course_int_id(); /* * Retrieve all the groups where enrollment is still allowed @@ -1671,7 +1662,7 @@ class GroupManager { ug.c_id = $course_id AND g.id IN (".implode(',', $group_ids).") GROUP BY (g.id) - HAVING (nbPlaces > 0 OR g.max_student = ".MEMBER_PER_GROUP_NO_LIMIT.") + HAVING (nbPlaces > 0 OR g.max_student = ".GroupManager::MEMBER_PER_GROUP_NO_LIMIT.") ORDER BY nbPlaces DESC"; $sql_result = Database::query($sql); $group_available_place = array (); @@ -1693,7 +1684,7 @@ class GroupManager { //first sort by user_id to filter out duplicates $complete_user_list = TableSort :: sort_table($complete_user_list, 'user_id'); $complete_user_list = self :: filter_duplicates($complete_user_list, 'user_id'); - // $complete_user_list = self :: filter_only_students($complete_user_list); // #5526 + $complete_user_list = self :: filter_only_students($complete_user_list); //now sort by # of group left $complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC); return $complete_user_list; From 1b709ae2b9254d2908e4a7fe4b211973b450c109 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 28 Sep 2012 00:24:50 +0200 Subject: [PATCH 024/124] Resending Hubert's change 99ae65434b82 see #5544 --- main/inc/lib/groupmanager.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 531ac04822..86b968ab91 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -1684,7 +1684,7 @@ class GroupManager { //first sort by user_id to filter out duplicates $complete_user_list = TableSort :: sort_table($complete_user_list, 'user_id'); $complete_user_list = self :: filter_duplicates($complete_user_list, 'user_id'); - $complete_user_list = self :: filter_only_students($complete_user_list); + //$complete_user_list = self :: filter_only_students($complete_user_list); //now sort by # of group left $complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC); return $complete_user_list; From 279df974bf8985589096fc1e366c4b7615bb60e2 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 28 Sep 2012 02:05:02 -0500 Subject: [PATCH 025/124] Restored changes from previous commit, merging with fix for refs #5543 --- main/auth/profile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/auth/profile.php b/main/auth/profile.php index 30e8ebac03..6f64609727 100644 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -446,9 +446,8 @@ if ($form->validate()) { $changeemail = ''; - //If user is sending the email to be changed (input is available and is not freeze ) - if (api_get_setting('registration', 'email') == 'true' && api_get_setting('profile', 'email') == 'true') { - + //If user sending the email to be changed (input available and not frozen ) + if (api_get_setting('profile', 'email') == 'true') { if ($allow_users_to_change_email_with_no_password) { if (!check_user_email($user_data['email'])) { $changeemail = $user_data['email']; @@ -609,6 +608,7 @@ if ($form->validate()) { if (api_get_setting('profile', 'officialcode') == 'true' && isset($user_data['official_code'])) { $sql .= ", official_code = '".Database::escape_string($user_data['official_code'])."'"; } + $sql .= " WHERE user_id = '".api_get_user_id()."'"; Database::query($sql); From 1d3deb6a096c61feae49f8448817a29a5bb3a7bd Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 28 Sep 2012 02:07:45 -0500 Subject: [PATCH 026/124] This is 1.9.2 stable v2 --- main/install/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/install/version.php b/main/install/version.php index 06675c4339..0f16eac241 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -13,7 +13,7 @@ */ $new_version = '1.9.2'; $new_version_status = 'Stable'; -$new_version_last_id = 1; +$new_version_last_id = 2; $new_version_stable = true; $new_version_major = false; $software_name = 'Chamilo'; From a1f2ebc2b329181bbf2b3704250c3e551c2de003 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 28 Sep 2012 02:16:56 -0500 Subject: [PATCH 028/124] Switched version to 1.9.4 as 1.9.2 is already packaged and just waiting to be released --- main/install/version.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/install/version.php b/main/install/version.php index 0f16eac241..a81660b4af 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -11,10 +11,10 @@ /** * Variables used from the main/install/index.php */ -$new_version = '1.9.2'; +$new_version = '1.9.4'; $new_version_status = 'Stable'; -$new_version_last_id = 2; -$new_version_stable = true; +$new_version_last_id = 1; +$new_version_stable = false; $new_version_major = false; $software_name = 'Chamilo'; $software_url = 'http://www.chamilo.org/'; From 28ac94a53b6bb6fb650c914d0d5cb8b1a5782629 Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Fri, 28 Sep 2012 10:31:08 +0200 Subject: [PATCH 029/124] Display visual_code instead of code in Subscribe class to courses list - ref #5553 --- main/admin/add_courses_to_usergroup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/admin/add_courses_to_usergroup.php b/main/admin/add_courses_to_usergroup.php index ec45b7b123..ca40194a99 100644 --- a/main/admin/add_courses_to_usergroup.php +++ b/main/admin/add_courses_to_usergroup.php @@ -104,9 +104,9 @@ $elements_not_in = $elements_in= array(); if (!empty($course_list)) { foreach($course_list as $item) { if (in_array($item['id'], $course_list_in)) { - $elements_in[$item['id']] = $item['title']." (".$item['code'].")"; + $elements_in[$item['id']] = $item['title']." (".$item['visual_code'].")"; } else { - $elements_not_in[$item['id']] = $item['title']." (".$item['code'].")"; + $elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")"; } } } @@ -154,7 +154,7 @@ function search($needle,$type) { foreach ($list as $row ) { if (!in_array($row['id'], array_keys($elements_in))) { - $return .= ''; + $return .= ''; } } $return .= ''; From 8c6548dff6c3bb0daa3bbbc4da3145d67c945adf Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 1 Oct 2012 14:28:26 +0200 Subject: [PATCH 030/124] Fixing missing function see #5564 --- main/inc/lib/display.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 55e276f761..387f76cbbe 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -55,7 +55,9 @@ class Display { self::$global_template->set_help($help); if (!empty(self::$preview_style)) { self::$global_template->preview_theme = self::$preview_style; - self::$global_template->set_theme(); + self::$global_template->set_css_files(); + self::$global_template->set_js_files(); + } if (!empty($page_header)) { self::$global_template->assign('header', $page_header); From 38c8854ee873a538e659bd8e8c48c72d983d8523 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Mon, 1 Oct 2012 14:00:40 -0500 Subject: [PATCH 031/124] Added @assert tags to test phpunit-skelgen. Worked. --- main/inc/lib/usermanager.lib.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index d41f7718be..1e60698646 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -36,8 +36,7 @@ class UserManager { /** * Creates a new user for the platform * @author Hugues Peeters , - * Roan Embrechts - * + * @author Roan Embrechts * @param string Firstname * @param string Lastname * @param int Status (1 for course tutor, 5 for student, 6 for anonymous) @@ -55,10 +54,9 @@ class UserManager { * @param array Extra fields * @param string Encrypt method used if password is given encrypted. Set to an empty string by default * @return mixed new user id - if the new user creation succeeds, false otherwise - * - * @desc The function tries to retrieve $_user['user_id'] from the global space. - * if it exists, $_user['user_id'] is the creator id. If a problem arises, - * it stores the error message in global $api_failureList + * @desc The function tries to retrieve $_user['user_id'] from the global space. If it exists, $_user['user_id'] is the creator id. If a problem arises, it stores the error message in global $api_failureList + * @assert ('Sam','Gamegie',5,'sam@example.com','jo','jo') > 1 + * @assert ('Pippin','Took',null,null,'jo','jo') === false */ public static function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language = '', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1, $hr_dept_id = 0, $extra = null, $encrypt_method = '', $send_mail = false) { global $_user, $_configuration; @@ -3709,4 +3707,4 @@ EOF; Database::query($sql); } } -} \ No newline at end of file +} From b0c14ae5dcf3845c4d98af1b6acf2ae4a27e4ac1 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Mon, 1 Oct 2012 14:45:51 -0500 Subject: [PATCH 032/124] Adding default test classes for phpunit + generator script - refs #5568 --- tests/phpunit/.generate_test_classes.php.swp | Bin 0 -> 12288 bytes tests/phpunit/README.txt | 4 + tests/phpunit/classes/AccessAllTest.class.php | 76 +++++ .../classes/AccessForbiddenTest.class.php | 76 +++++ tests/phpunit/classes/AccessTest.class.php | 100 ++++++ .../phpunit/classes/AccessTokenTest.class.php | 136 ++++++++ tests/phpunit/classes/CacheTest.class.php | 112 +++++++ .../classes/ConditionalLoginTest.class.php | 52 +++ .../classes/CurrentCourseTest.class.php | 316 ++++++++++++++++++ .../phpunit/classes/CurrentUserTest.class.php | 292 ++++++++++++++++ .../phpunit/classes/CustomPagesTest.class.php | 76 +++++ .../phpunit/classes/EventsMailTest.class.php | 52 +++ tests/phpunit/classes/FileStoreTest.class.php | 112 +++++++ .../phpunit/classes/JavascriptTest.class.php | 76 +++++ .../classes/LoginRedirectionTest.class.php | 40 +++ tests/phpunit/classes/PageTest.class.php | 184 ++++++++++ tests/phpunit/classes/PluginTest.class.php | 232 +++++++++++++ tests/phpunit/classes/ResponseTest.class.php | 40 +++ tests/phpunit/classes/ResultSetTest.class.php | 196 +++++++++++ .../classes/SessionHandlerTest.class.php | 136 ++++++++ tests/phpunit/classes/TableSortTest.class.php | 52 +++ tests/phpunit/classes/UriTest.class.php | 100 ++++++ .../classes/UserApiKeyManagerTest.class.php | 88 +++++ tests/phpunit/classes/ZipTest.class.php | 100 ++++++ tests/phpunit/classes/dbTest.class.php | 172 ++++++++++ tests/phpunit/generate_test_classes.php | 33 ++ 26 files changed, 2853 insertions(+) create mode 100644 tests/phpunit/.generate_test_classes.php.swp create mode 100644 tests/phpunit/README.txt create mode 100644 tests/phpunit/classes/AccessAllTest.class.php create mode 100644 tests/phpunit/classes/AccessForbiddenTest.class.php create mode 100644 tests/phpunit/classes/AccessTest.class.php create mode 100644 tests/phpunit/classes/AccessTokenTest.class.php create mode 100644 tests/phpunit/classes/CacheTest.class.php create mode 100644 tests/phpunit/classes/ConditionalLoginTest.class.php create mode 100644 tests/phpunit/classes/CurrentCourseTest.class.php create mode 100644 tests/phpunit/classes/CurrentUserTest.class.php create mode 100644 tests/phpunit/classes/CustomPagesTest.class.php create mode 100644 tests/phpunit/classes/EventsMailTest.class.php create mode 100644 tests/phpunit/classes/FileStoreTest.class.php create mode 100644 tests/phpunit/classes/JavascriptTest.class.php create mode 100644 tests/phpunit/classes/LoginRedirectionTest.class.php create mode 100644 tests/phpunit/classes/PageTest.class.php create mode 100644 tests/phpunit/classes/PluginTest.class.php create mode 100644 tests/phpunit/classes/ResponseTest.class.php create mode 100644 tests/phpunit/classes/ResultSetTest.class.php create mode 100644 tests/phpunit/classes/SessionHandlerTest.class.php create mode 100644 tests/phpunit/classes/TableSortTest.class.php create mode 100644 tests/phpunit/classes/UriTest.class.php create mode 100644 tests/phpunit/classes/UserApiKeyManagerTest.class.php create mode 100644 tests/phpunit/classes/ZipTest.class.php create mode 100644 tests/phpunit/classes/dbTest.class.php create mode 100644 tests/phpunit/generate_test_classes.php diff --git a/tests/phpunit/.generate_test_classes.php.swp b/tests/phpunit/.generate_test_classes.php.swp new file mode 100644 index 0000000000000000000000000000000000000000..57d3d38799aea01c7a7e2e7a469fcf25c57394b8 GIT binary patch literal 12288 zcmeI2&yO256vthTlmepvz}v9WBug^0OAk=CQ7`4kN<~_UmID-xoEayvc4DVvPt!nG z2qeTG!hr)P#DBnFz=i(+A;b|72u^%GnaL)r)gF4Q^elZf<9YV;^T#iiR{KW#A0E9= zZ^SnQ+RH*b_(LCm_mL384}@4QWNEZ2gXyy7q`u6&wk3~bnJgBIB%8{aF6_b0$B9?Y zyJS9{S4R6}qKqn~S84d1W`%T4xfs^94}M_+OyDU9RDL{o^P0Hv`oVsf{c2~2uD^2s zDID<>Ccp%k025#WOn?b60Vco%o>c;Venota;Gb(Yu+u!RoO?E1elP(hzyz286JP>N zfC(@GCcp%k025#W&maMr3vuUpA%20v|Nq;+|NnbQh`*t4p|7AXpi}4snm}(s*P*{& z6yj&-d+1B(HRvkz+chD+fjo2@>Og{~eGUDNIDT#7`8UMG zjR`OTCcp%k025#WOn?boOyG30iLDONsUS4BbY9K6QB!X^a3`uj%_$8Aq2Lq`isD_P z7Io!m9EDz?N4YNJ-LWpz>dTq^UYLY2nax!g6eV$duA;T6VNJIDhI#R74MY<44(s5O zgx+oHU&&7uWwI#9TRInPJ$5%&m|v>=<4yU$^u`QL%rqo@3RgR=P8`PuEFl^I0 zBw3bnndW*tuBWx$`?OxD4l+z?ZCH1reA;%~YTa%DcWKfLR8t*Qs<~1 zqs@dm=P-AuGKF%Ew5KUTmj$+zFKMK3R*maCj^hWW6Wjq@KsB*8?~}0$nwK_HI1#vB zXg{S#vd}p-M}Y}?OkHi#dehzdWc$17aUHSi0S{%?cx@_mSmzD=udKnLo2yLA0;hx0 z1_a2HrJwwk^E#%A^5l()EE>ghc zmuacy)@g6c`RRC?JUBn#-?#d>7NE6Pq=vkIy?Fa+mmsXSFq8$MY6ZoT5_9JGmxqc$ZvJFBmh<|?TdzI7Wt F@jsn(`se@v literal 0 HcmV?d00001 diff --git a/tests/phpunit/README.txt b/tests/phpunit/README.txt new file mode 100644 index 0000000000..b30d988856 --- /dev/null +++ b/tests/phpunit/README.txt @@ -0,0 +1,4 @@ +Do not modify these test classes by hand. They will probably get overwritten +with the next automatic generation. Instead, use copies of the existing files +and suffix them with "Custom" to maintain them in the code versioning system. +For example: AccessTestCustom.class.php diff --git a/tests/phpunit/classes/AccessAllTest.class.php b/tests/phpunit/classes/AccessAllTest.class.php new file mode 100644 index 0000000000..e986e23852 --- /dev/null +++ b/tests/phpunit/classes/AccessAllTest.class.php @@ -0,0 +1,76 @@ +object = new AccessAll; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers AccessAll::instance + * @todo Implement testInstance(). + */ + public function testInstance() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessAll::can_edit + * @todo Implement testCan_edit(). + */ + public function testCan_edit() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessAll::can_view + * @todo Implement testCan_view(). + */ + public function testCan_view() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessAll::authorize + * @todo Implement testAuthorize(). + */ + public function testAuthorize() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/AccessForbiddenTest.class.php b/tests/phpunit/classes/AccessForbiddenTest.class.php new file mode 100644 index 0000000000..2bc283f887 --- /dev/null +++ b/tests/phpunit/classes/AccessForbiddenTest.class.php @@ -0,0 +1,76 @@ +object = new AccessForbidden; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers AccessForbidden::instance + * @todo Implement testInstance(). + */ + public function testInstance() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessForbidden::can_edit + * @todo Implement testCan_edit(). + */ + public function testCan_edit() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessForbidden::can_view + * @todo Implement testCan_view(). + */ + public function testCan_view() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessForbidden::authorize + * @todo Implement testAuthorize(). + */ + public function testAuthorize() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/AccessTest.class.php b/tests/phpunit/classes/AccessTest.class.php new file mode 100644 index 0000000000..eb3dd35855 --- /dev/null +++ b/tests/phpunit/classes/AccessTest.class.php @@ -0,0 +1,100 @@ +object = new Access; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Access::all + * @todo Implement testAll(). + */ + public function testAll() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Access::forbidden + * @todo Implement testForbidden(). + */ + public function testForbidden() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Access::is_token_valid + * @todo Implement testIs_token_valid(). + */ + public function testIs_token_valid() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Access::get_session_token + * @todo Implement testGet_session_token(). + */ + public function testGet_session_token() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Access::get_token + * @todo Implement testGet_token(). + */ + public function testGet_token() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Access::authorize + * @todo Implement testAuthorize(). + */ + public function testAuthorize() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/AccessTokenTest.class.php b/tests/phpunit/classes/AccessTokenTest.class.php new file mode 100644 index 0000000000..22eccb3eb0 --- /dev/null +++ b/tests/phpunit/classes/AccessTokenTest.class.php @@ -0,0 +1,136 @@ +object = new AccessToken; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers AccessToken::empty_token + * @todo Implement testEmpty_token(). + */ + public function testEmpty_token() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::parse + * @todo Implement testParse(). + */ + public function testParse() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::create + * @todo Implement testCreate(). + */ + public function testCreate() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::get_id + * @todo Implement testGet_id(). + */ + public function testGet_id() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::get_user_id + * @todo Implement testGet_user_id(). + */ + public function testGet_user_id() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::get_key + * @todo Implement testGet_key(). + */ + public function testGet_key() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::is_empty + * @todo Implement testIs_empty(). + */ + public function testIs_empty() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::is_valid + * @todo Implement testIs_valid(). + */ + public function testIs_valid() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers AccessToken::__toString + * @todo Implement test__toString(). + */ + public function test__toString() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/CacheTest.class.php b/tests/phpunit/classes/CacheTest.class.php new file mode 100644 index 0000000000..1a3d9cbd0d --- /dev/null +++ b/tests/phpunit/classes/CacheTest.class.php @@ -0,0 +1,112 @@ +object = new Cache; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Cache::get + * @todo Implement testGet(). + */ + public function testGet() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Cache::has + * @todo Implement testHas(). + */ + public function testHas() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Cache::put + * @todo Implement testPut(). + */ + public function testPut() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Cache::remove + * @todo Implement testRemove(). + */ + public function testRemove() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Cache::clear + * @todo Implement testClear(). + */ + public function testClear() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Cache::path + * @todo Implement testPath(). + */ + public function testPath() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Cache::key + * @todo Implement testKey(). + */ + public function testKey() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/ConditionalLoginTest.class.php b/tests/phpunit/classes/ConditionalLoginTest.class.php new file mode 100644 index 0000000000..c3c6d36c22 --- /dev/null +++ b/tests/phpunit/classes/ConditionalLoginTest.class.php @@ -0,0 +1,52 @@ +object = new ConditionalLogin; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers ConditionalLogin::check_conditions + * @todo Implement testCheck_conditions(). + */ + public function testCheck_conditions() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ConditionalLogin::login + * @todo Implement testLogin(). + */ + public function testLogin() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/CurrentCourseTest.class.php b/tests/phpunit/classes/CurrentCourseTest.class.php new file mode 100644 index 0000000000..e17d7310b4 --- /dev/null +++ b/tests/phpunit/classes/CurrentCourseTest.class.php @@ -0,0 +1,316 @@ +object = new CurrentCourse; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers CurrentCourse::instance + * @todo Implement testInstance(). + */ + public function testInstance() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::is_empty + * @todo Implement testIs_empty(). + */ + public function testIs_empty() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::data + * @todo Implement testData(). + */ + public function testData() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::real_id + * @todo Implement testReal_id(). + */ + public function testReal_id() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::code + * @todo Implement testCode(). + */ + public function testCode() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::name + * @todo Implement testName(). + */ + public function testName() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::title + * @todo Implement testTitle(). + */ + public function testTitle() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::official_code + * @todo Implement testOfficial_code(). + */ + public function testOfficial_code() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::sys_code + * @todo Implement testSys_code(). + */ + public function testSys_code() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::path + * @todo Implement testPath(). + */ + public function testPath() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::db_name + * @todo Implement testDb_name(). + */ + public function testDb_name() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::db_name_glu + * @todo Implement testDb_name_glu(). + */ + public function testDb_name_glu() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::titular + * @todo Implement testTitular(). + */ + public function testTitular() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::language + * @todo Implement testLanguage(). + */ + public function testLanguage() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::category_code + * @todo Implement testCategory_code(). + */ + public function testCategory_code() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::category_ame + * @todo Implement testCategory_ame(). + */ + public function testCategory_ame() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::visibility + * @todo Implement testVisibility(). + */ + public function testVisibility() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::subscribe_allowed + * @todo Implement testSubscribe_allowed(). + */ + public function testSubscribe_allowed() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::unsubscribe_allowed + * @todo Implement testUnsubscribe_allowed(). + */ + public function testUnsubscribe_allowed() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::activate_legal + * @todo Implement testActivate_legal(). + */ + public function testActivate_legal() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::show_score + * @todo Implement testShow_score(). + */ + public function testShow_score() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::extrnal_link + * @todo Implement testExtrnal_link(). + */ + public function testExtrnal_link() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::user + * @todo Implement testUser(). + */ + public function testUser() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentCourse::get + * @todo Implement testGet(). + */ + public function testGet() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/CurrentUserTest.class.php b/tests/phpunit/classes/CurrentUserTest.class.php new file mode 100644 index 0000000000..9413998bf3 --- /dev/null +++ b/tests/phpunit/classes/CurrentUserTest.class.php @@ -0,0 +1,292 @@ +object = new CurrentUser; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers CurrentUser::instance + * @todo Implement testInstance(). + */ + public function testInstance() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::data + * @todo Implement testData(). + */ + public function testData() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_anonymous + * @todo Implement testIs_anonymous(). + */ + public function testIs_anonymous() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::first_name + * @todo Implement testFirst_name(). + */ + public function testFirst_name() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::last_name + * @todo Implement testLast_name(). + */ + public function testLast_name() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::email + * @todo Implement testEmail(). + */ + public function testEmail() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::last_login + * @todo Implement testLast_login(). + */ + public function testLast_login() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::official_code + * @todo Implement testOfficial_code(). + */ + public function testOfficial_code() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::picture_uri + * @todo Implement testPicture_uri(). + */ + public function testPicture_uri() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::user_id + * @todo Implement testUser_id(). + */ + public function testUser_id() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::language + * @todo Implement testLanguage(). + */ + public function testLanguage() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::auth_source + * @todo Implement testAuth_source(). + */ + public function testAuth_source() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::theme + * @todo Implement testTheme(). + */ + public function testTheme() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_platform_admin + * @todo Implement testIs_platform_admin(). + */ + public function testIs_platform_admin() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_session_admin + * @todo Implement testIs_session_admin(). + */ + public function testIs_session_admin() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_allowed_to_create_course + * @todo Implement testIs_allowed_to_create_course(). + */ + public function testIs_allowed_to_create_course() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_course_admin + * @todo Implement testIs_course_admin(). + */ + public function testIs_course_admin() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_course_member + * @todo Implement testIs_course_member(). + */ + public function testIs_course_member() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_allowed_in_course + * @todo Implement testIs_allowed_in_course(). + */ + public function testIs_allowed_in_course() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_course_coach + * @todo Implement testIs_course_coach(). + */ + public function testIs_course_coach() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::is_course_tutor + * @todo Implement testIs_course_tutor(). + */ + public function testIs_course_tutor() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CurrentUser::get + * @todo Implement testGet(). + */ + public function testGet() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/CustomPagesTest.class.php b/tests/phpunit/classes/CustomPagesTest.class.php new file mode 100644 index 0000000000..a9f2988a5e --- /dev/null +++ b/tests/phpunit/classes/CustomPagesTest.class.php @@ -0,0 +1,76 @@ +object = new CustomPages; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers CustomPages::enabled + * @todo Implement testEnabled(). + */ + public function testEnabled() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CustomPages::path + * @todo Implement testPath(). + */ + public function testPath() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CustomPages::display + * @todo Implement testDisplay(). + */ + public function testDisplay() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers CustomPages::getURLImages + * @todo Implement testGetURLImages(). + */ + public function testGetURLImages() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/EventsMailTest.class.php b/tests/phpunit/classes/EventsMailTest.class.php new file mode 100644 index 0000000000..78db857824 --- /dev/null +++ b/tests/phpunit/classes/EventsMailTest.class.php @@ -0,0 +1,52 @@ +object = new EventsMail; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers EventsMail::send_mail + * @todo Implement testSend_mail(). + */ + public function testSend_mail() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers EventsMail::check_if_using_class + * @todo Implement testCheck_if_using_class(). + */ + public function testCheck_if_using_class() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/FileStoreTest.class.php b/tests/phpunit/classes/FileStoreTest.class.php new file mode 100644 index 0000000000..8673f4333e --- /dev/null +++ b/tests/phpunit/classes/FileStoreTest.class.php @@ -0,0 +1,112 @@ +object = new FileStore; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers FileStore::course + * @todo Implement testCourse(). + */ + public function testCourse() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FileStore::root + * @todo Implement testRoot(). + */ + public function testRoot() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FileStore::accept + * @todo Implement testAccept(). + */ + public function testAccept() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FileStore::add + * @todo Implement testAdd(). + */ + public function testAdd() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FileStore::remove + * @todo Implement testRemove(). + */ + public function testRemove() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FileStore::get + * @todo Implement testGet(). + */ + public function testGet() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FileStore::new_id + * @todo Implement testNew_id(). + */ + public function testNew_id() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/JavascriptTest.class.php b/tests/phpunit/classes/JavascriptTest.class.php new file mode 100644 index 0000000000..92e32f0363 --- /dev/null +++ b/tests/phpunit/classes/JavascriptTest.class.php @@ -0,0 +1,76 @@ +object = new Javascript; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Javascript::minify + * @todo Implement testMinify(). + */ + public function testMinify() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Javascript::get_lang + * @todo Implement testGet_lang(). + */ + public function testGet_lang() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Javascript::tag + * @todo Implement testTag(). + */ + public function testTag() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Javascript::tag_code + * @todo Implement testTag_code(). + */ + public function testTag_code() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/LoginRedirectionTest.class.php b/tests/phpunit/classes/LoginRedirectionTest.class.php new file mode 100644 index 0000000000..e67dc89fc8 --- /dev/null +++ b/tests/phpunit/classes/LoginRedirectionTest.class.php @@ -0,0 +1,40 @@ +object = new LoginRedirection; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers LoginRedirection::redirect + * @todo Implement testRedirect(). + */ + public function testRedirect() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/PageTest.class.php b/tests/phpunit/classes/PageTest.class.php new file mode 100644 index 0000000000..9f79d4ec28 --- /dev/null +++ b/tests/phpunit/classes/PageTest.class.php @@ -0,0 +1,184 @@ +object = new Page; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Page::create + * @todo Implement testCreate(). + */ + public function testCreate() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::header + * @todo Implement testHeader(). + */ + public function testHeader() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::title + * @todo Implement testTitle(). + */ + public function testTitle() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::breadcrumbs + * @todo Implement testBreadcrumbs(). + */ + public function testBreadcrumbs() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::help + * @todo Implement testHelp(). + */ + public function testHelp() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::message + * @todo Implement testMessage(). + */ + public function testMessage() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::warning + * @todo Implement testWarning(). + */ + public function testWarning() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::error + * @todo Implement testError(). + */ + public function testError() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::content + * @todo Implement testContent(). + */ + public function testContent() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::__toString + * @todo Implement test__toString(). + */ + public function test__toString() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::display + * @todo Implement testDisplay(). + */ + public function testDisplay() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::display_header + * @todo Implement testDisplay_header(). + */ + public function testDisplay_header() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Page::display_footer + * @todo Implement testDisplay_footer(). + */ + public function testDisplay_footer() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/PluginTest.class.php b/tests/phpunit/classes/PluginTest.class.php new file mode 100644 index 0000000000..ca724195be --- /dev/null +++ b/tests/phpunit/classes/PluginTest.class.php @@ -0,0 +1,232 @@ +object = new Plugin; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Plugin::get_info + * @todo Implement testGet_info(). + */ + public function testGet_info() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_name + * @todo Implement testGet_name(). + */ + public function testGet_name() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_title + * @todo Implement testGet_title(). + */ + public function testGet_title() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_comment + * @todo Implement testGet_comment(). + */ + public function testGet_comment() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_version + * @todo Implement testGet_version(). + */ + public function testGet_version() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_author + * @todo Implement testGet_author(). + */ + public function testGet_author() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_css + * @todo Implement testGet_css(). + */ + public function testGet_css() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_settings_form + * @todo Implement testGet_settings_form(). + */ + public function testGet_settings_form() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get + * @todo Implement testGet(). + */ + public function testGet() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_settings + * @todo Implement testGet_settings(). + */ + public function testGet_settings() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_lang_plugin_exists + * @todo Implement testGet_lang_plugin_exists(). + */ + public function testGet_lang_plugin_exists() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::get_lang + * @todo Implement testGet_lang(). + */ + public function testGet_lang() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::course_install + * @todo Implement testCourse_install(). + */ + public function testCourse_install() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::install_course_fields + * @todo Implement testInstall_course_fields(). + */ + public function testInstall_course_fields() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::uninstall_course_fields + * @todo Implement testUninstall_course_fields(). + */ + public function testUninstall_course_fields() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::install_course_fields_in_all_courses + * @todo Implement testInstall_course_fields_in_all_courses(). + */ + public function testInstall_course_fields_in_all_courses() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Plugin::uninstall_course_fields_in_all_courses + * @todo Implement testUninstall_course_fields_in_all_courses(). + */ + public function testUninstall_course_fields_in_all_courses() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/ResponseTest.class.php b/tests/phpunit/classes/ResponseTest.class.php new file mode 100644 index 0000000000..401dab2114 --- /dev/null +++ b/tests/phpunit/classes/ResponseTest.class.php @@ -0,0 +1,40 @@ +object = new Response; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Response::not_found + * @todo Implement testNot_found(). + */ + public function testNot_found() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/ResultSetTest.class.php b/tests/phpunit/classes/ResultSetTest.class.php new file mode 100644 index 0000000000..ad92b81925 --- /dev/null +++ b/tests/phpunit/classes/ResultSetTest.class.php @@ -0,0 +1,196 @@ +object = new ResultSet; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers ResultSet::create + * @todo Implement testCreate(). + */ + public function testCreate() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::sql + * @todo Implement testSql(). + */ + public function testSql() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::count + * @todo Implement testCount(). + */ + public function testCount() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::first + * @todo Implement testFirst(). + */ + public function testFirst() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::limit + * @todo Implement testLimit(). + */ + public function testLimit() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::orderby + * @todo Implement testOrderby(). + */ + public function testOrderby() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::return_type + * @todo Implement testReturn_type(). + */ + public function testReturn_type() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::current + * @todo Implement testCurrent(). + */ + public function testCurrent() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::key + * @todo Implement testKey(). + */ + public function testKey() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::next + * @todo Implement testNext(). + */ + public function testNext() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::rewind + * @todo Implement testRewind(). + */ + public function testRewind() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::valid + * @todo Implement testValid(). + */ + public function testValid() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::__clone + * @todo Implement test__clone(). + */ + public function test__clone() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers ResultSet::reset + * @todo Implement testReset(). + */ + public function testReset() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/SessionHandlerTest.class.php b/tests/phpunit/classes/SessionHandlerTest.class.php new file mode 100644 index 0000000000..7b5f0c1ee0 --- /dev/null +++ b/tests/phpunit/classes/SessionHandlerTest.class.php @@ -0,0 +1,136 @@ +object = new SessionHandler; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers SessionHandler::sqlConnect + * @todo Implement testSqlConnect(). + */ + public function testSqlConnect() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::sqlClose + * @todo Implement testSqlClose(). + */ + public function testSqlClose() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::sqlQuery + * @todo Implement testSqlQuery(). + */ + public function testSqlQuery() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::open + * @todo Implement testOpen(). + */ + public function testOpen() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::close + * @todo Implement testClose(). + */ + public function testClose() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::read + * @todo Implement testRead(). + */ + public function testRead() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::write + * @todo Implement testWrite(). + */ + public function testWrite() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::destroy + * @todo Implement testDestroy(). + */ + public function testDestroy() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers SessionHandler::garbage + * @todo Implement testGarbage(). + */ + public function testGarbage() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/TableSortTest.class.php b/tests/phpunit/classes/TableSortTest.class.php new file mode 100644 index 0000000000..28205b67c2 --- /dev/null +++ b/tests/phpunit/classes/TableSortTest.class.php @@ -0,0 +1,52 @@ +object = new TableSort; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers TableSort::sort_table + * @todo Implement testSort_table(). + */ + public function testSort_table() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers TableSort::sort_table_config + * @todo Implement testSort_table_config(). + */ + public function testSort_table_config() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/UriTest.class.php b/tests/phpunit/classes/UriTest.class.php new file mode 100644 index 0000000000..5162df9dec --- /dev/null +++ b/tests/phpunit/classes/UriTest.class.php @@ -0,0 +1,100 @@ +object = new Uri; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Uri::chamilo + * @todo Implement testChamilo(). + */ + public function testChamilo() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Uri::www + * @todo Implement testWww(). + */ + public function testWww() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Uri::here + * @todo Implement testHere(). + */ + public function testHere() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Uri::url + * @todo Implement testUrl(). + */ + public function testUrl() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Uri::params + * @todo Implement testParams(). + */ + public function testParams() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Uri::course_params + * @todo Implement testCourse_params(). + */ + public function testCourse_params() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/UserApiKeyManagerTest.class.php b/tests/phpunit/classes/UserApiKeyManagerTest.class.php new file mode 100644 index 0000000000..8853a20021 --- /dev/null +++ b/tests/phpunit/classes/UserApiKeyManagerTest.class.php @@ -0,0 +1,88 @@ +object = new UserApiKeyManager; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers UserApiKeyManager::default_service + * @todo Implement testDefault_service(). + */ + public function testDefault_service() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers UserApiKeyManager::end_of_time + * @todo Implement testEnd_of_time(). + */ + public function testEnd_of_time() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers UserApiKeyManager::get_by_id + * @todo Implement testGet_by_id(). + */ + public function testGet_by_id() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers UserApiKeyManager::create_temp_token + * @todo Implement testCreate_temp_token(). + */ + public function testCreate_temp_token() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers UserApiKeyManager::create_token + * @todo Implement testCreate_token(). + */ + public function testCreate_token() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/ZipTest.class.php b/tests/phpunit/classes/ZipTest.class.php new file mode 100644 index 0000000000..6085ce5524 --- /dev/null +++ b/tests/phpunit/classes/ZipTest.class.php @@ -0,0 +1,100 @@ +object = new Zip; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers Zip::pool + * @todo Implement testPool(). + */ + public function testPool() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Zip::create + * @todo Implement testCreate(). + */ + public function testCreate() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Zip::get_path + * @todo Implement testGet_path(). + */ + public function testGet_path() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Zip::get_hash + * @todo Implement testGet_hash(). + */ + public function testGet_hash() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Zip::add + * @todo Implement testAdd(). + */ + public function testAdd() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Zip::callback + * @todo Implement testCallback(). + */ + public function testCallback() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/classes/dbTest.class.php b/tests/phpunit/classes/dbTest.class.php new file mode 100644 index 0000000000..9e77ce64b0 --- /dev/null +++ b/tests/phpunit/classes/dbTest.class.php @@ -0,0 +1,172 @@ +object = new db; + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + /** + * @covers db::instance + * @todo Implement testInstance(). + */ + public function testInstance() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::save + * @todo Implement testSave(). + */ + public function testSave() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::remove + * @todo Implement testRemove(). + */ + public function testRemove() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::flush + * @todo Implement testFlush(). + */ + public function testFlush() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::test + * @todo Implement testTest(). + */ + public function testTest() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::em + * @todo Implement testEm(). + */ + public function testEm() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::get_repository + * @todo Implement testGet_repository(). + */ + public function testGet_repository() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::get_entity_path + * @todo Implement testGet_entity_path(). + */ + public function testGet_entity_path() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::is_production + * @todo Implement testIs_production(). + */ + public function testIs_production() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::is_dev + * @todo Implement testIs_dev(). + */ + public function testIs_dev() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::generate_model + * @todo Implement testGenerate_model(). + */ + public function testGenerate_model() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers db::update_schema + * @todo Implement testUpdate_schema(). + */ + public function testUpdate_schema() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/phpunit/generate_test_classes.php b/tests/phpunit/generate_test_classes.php new file mode 100644 index 0000000000..3bcf876568 --- /dev/null +++ b/tests/phpunit/generate_test_classes.php @@ -0,0 +1,33 @@ + Date: Mon, 1 Oct 2012 14:47:17 -0500 Subject: [PATCH 033/124] Removed temp file --- tests/phpunit/.generate_test_classes.php.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/phpunit/.generate_test_classes.php.swp diff --git a/tests/phpunit/.generate_test_classes.php.swp b/tests/phpunit/.generate_test_classes.php.swp deleted file mode 100644 index 57d3d38799aea01c7a7e2e7a469fcf25c57394b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&yO256vthTlmepvz}v9WBug^0OAk=CQ7`4kN<~_UmID-xoEayvc4DVvPt!nG z2qeTG!hr)P#DBnFz=i(+A;b|72u^%GnaL)r)gF4Q^elZf<9YV;^T#iiR{KW#A0E9= zZ^SnQ+RH*b_(LCm_mL384}@4QWNEZ2gXyy7q`u6&wk3~bnJgBIB%8{aF6_b0$B9?Y zyJS9{S4R6}qKqn~S84d1W`%T4xfs^94}M_+OyDU9RDL{o^P0Hv`oVsf{c2~2uD^2s zDID<>Ccp%k025#WOn?b60Vco%o>c;Venota;Gb(Yu+u!RoO?E1elP(hzyz286JP>N zfC(@GCcp%k025#W&maMr3vuUpA%20v|Nq;+|NnbQh`*t4p|7AXpi}4snm}(s*P*{& z6yj&-d+1B(HRvkz+chD+fjo2@>Og{~eGUDNIDT#7`8UMG zjR`OTCcp%k025#WOn?boOyG30iLDONsUS4BbY9K6QB!X^a3`uj%_$8Aq2Lq`isD_P z7Io!m9EDz?N4YNJ-LWpz>dTq^UYLY2nax!g6eV$duA;T6VNJIDhI#R74MY<44(s5O zgx+oHU&&7uWwI#9TRInPJ$5%&m|v>=<4yU$^u`QL%rqo@3RgR=P8`PuEFl^I0 zBw3bnndW*tuBWx$`?OxD4l+z?ZCH1reA;%~YTa%DcWKfLR8t*Qs<~1 zqs@dm=P-AuGKF%Ew5KUTmj$+zFKMK3R*maCj^hWW6Wjq@KsB*8?~}0$nwK_HI1#vB zXg{S#vd}p-M}Y}?OkHi#dehzdWc$17aUHSi0S{%?cx@_mSmzD=udKnLo2yLA0;hx0 z1_a2HrJwwk^E#%A^5l()EE>ghc zmuacy)@g6c`RRC?JUBn#-?#d>7NE6Pq=vkIy?Fa+mmsXSFq8$MY6ZoT5_9JGmxqc$ZvJFBmh<|?TdzI7Wt F@jsn(`se@v From 6c6c1060b16d74952e05701fcdd3cbb6784c005b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 1 Oct 2012 22:32:56 +0200 Subject: [PATCH 034/124] Undo 1.9.4 changed --- main/install/version.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/install/version.php b/main/install/version.php index a81660b4af..0f16eac241 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -11,10 +11,10 @@ /** * Variables used from the main/install/index.php */ -$new_version = '1.9.4'; +$new_version = '1.9.2'; $new_version_status = 'Stable'; -$new_version_last_id = 1; -$new_version_stable = false; +$new_version_last_id = 2; +$new_version_stable = true; $new_version_major = false; $software_name = 'Chamilo'; $software_url = 'http://www.chamilo.org/'; From f73fd1d0bd83ce8d9a06986e4ac644ca8a3d273e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 2 Oct 2012 11:48:13 +0200 Subject: [PATCH 036/124] Minor adding static --- main/inc/lib/document.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 259f2c7195..aa4d09f942 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2182,7 +2182,7 @@ class DocumentManager { return $return; } - public function export_to_pdf($document_id, $course_code) { + public static function export_to_pdf($document_id, $course_code) { require_once api_get_path(LIBRARY_PATH).'pdf.lib.php'; $course_data = api_get_course_info($course_code); $document_data = self::get_document_data_by_id($document_id, $course_code); From 2cc59f86881adf3cf821f96f3f5d09b850510ffc Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 2 Oct 2012 18:00:48 -0500 Subject: [PATCH 037/124] Improved LDAP data checking in case there is no status or password - refs BT#4995 --- main/auth/external_login/functions.inc.php | 4 ++++ main/auth/external_login/login.ldap.php | 3 ++- main/auth/external_login/newUser.ldap.php | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main/auth/external_login/functions.inc.php b/main/auth/external_login/functions.inc.php index 6d306e2e10..5b85785d97 100644 --- a/main/auth/external_login/functions.inc.php +++ b/main/auth/external_login/functions.inc.php @@ -97,6 +97,10 @@ function external_get_user_info($login, $password){ **/ function external_add_user($u){ //Setting default + if (empty($u['password']) ) + $u['password'] = null; + if (empty($u['status']) ) + $u['status'] = 5; if (! isset($u['official_code']) ) $u['official_code'] = ''; if (! isset($u['language']) ) diff --git a/main/auth/external_login/login.ldap.php b/main/auth/external_login/login.ldap.php index 8e01546699..5c462aa12f 100644 --- a/main/auth/external_login/login.ldap.php +++ b/main/auth/external_login/login.ldap.php @@ -55,6 +55,7 @@ if ($ldap_user !== false) { $loginFailed = false; $_user['user_id'] = $chamilo_user['user_id']; + $_user['status'] = (isset($chamilo_user['status'])?$chamilo_user['status']:5); $_user['uidReset'] = true; Session::write('_user',$_user); $uidReset=true; @@ -64,4 +65,4 @@ if ($ldap_user !== false) { $loginFailed = true; $uidReset = false; unset($_user['user_id']); -} \ No newline at end of file +} diff --git a/main/auth/external_login/newUser.ldap.php b/main/auth/external_login/newUser.ldap.php index cfc504d91f..12f62e9c31 100644 --- a/main/auth/external_login/newUser.ldap.php +++ b/main/auth/external_login/newUser.ldap.php @@ -50,6 +50,7 @@ if ($ldap_user !== false) { if ($chamilo_uid !==false) { $loginFailed = false; $_user['user_id'] = $chamilo_uid; + $_user['status'] = (isset($chamilo_user['status'])?$chamilo_user['status']:5); $_user['uidReset'] = true; Session::write('_user',$_user); $uidReset=true; @@ -64,4 +65,4 @@ if ($ldap_user !== false) { $loginFailed = true; $uidReset = false; unset($_user['user_id']); -} \ No newline at end of file +} From 87239aefe9576f8a395e3dd84f64898b6ed85d01 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 2 Oct 2012 18:03:12 -0500 Subject: [PATCH 038/124] Ignore - EOF --- main/inc/lib/database.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 388835a096..6735d635a4 100644 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -1356,4 +1356,4 @@ class Database { public static function get_last_insert_id() { return mysql_insert_id(); } -} \ No newline at end of file +} From 7939d7aff5ad6cc55d7b90bac52a3345c823de2b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 08:25:30 +0200 Subject: [PATCH 039/124] Fixing var_dump --- main/inc/lib/attendance.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/attendance.lib.php b/main/inc/lib/attendance.lib.php index 40ca1f206c..c9adecce08 100644 --- a/main/inc/lib/attendance.lib.php +++ b/main/inc/lib/attendance.lib.php @@ -120,7 +120,7 @@ class Attendance FROM $tbl_attendance att WHERE c_id = $course_id AND $active_plus $condition_session ORDER BY col$column $direction LIMIT $from,$number_of_items "; - var_dump($sql);exit; + $res = Database::query($sql); $attendances = array (); From ae03146075e9928ae2b0d506489101a5a39caa1b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 11:15:23 +0200 Subject: [PATCH 041/124] Minor adding headers --- main/announcements/announcements.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index 59fcb5c6d9..bad862c0a1 100644 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -37,7 +37,7 @@ if(isset($_GET['id_session'])) { } /* ACCESS RIGHTS */ -api_protect_course_script(); +api_protect_course_script(true); // Configuration settings $display_announcement_list = true; @@ -72,7 +72,6 @@ $course_id = api_get_course_int_id(); /* Tracking */ event_access_tool(TOOL_ANNOUNCEMENT); - /* POST TO */ $safe_emailTitle = $_POST['emailTitle']; $safe_newContent = $_POST['newContent']; @@ -81,7 +80,7 @@ $content_to_modify = $title_to_modify = ''; if (!empty($_POST['To'])) { if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { - api_not_allowed(); + api_not_allowed(true); } $display_form = true; @@ -115,7 +114,7 @@ if (!empty($_POST['To']) and ($select_groupusers_status=="show")) { // display the form if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To'])) { if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { - api_not_allowed(); + api_not_allowed(true); } $display_form = true; } @@ -1063,4 +1062,4 @@ if (isset($_GET['action']) && $_GET['action'] == 'view') { if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { //we are not in learnpath tool Display::display_footer(); -} +} \ No newline at end of file From 82196789bdc8244cdf89f02b7e80e3db72db8cd4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 11:43:53 +0200 Subject: [PATCH 042/124] Adding intval in query --- main/gradebook/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/gradebook/index.php b/main/gradebook/index.php index 6b19370f4a..bdd255dab8 100644 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -386,7 +386,7 @@ $course_id = api_get_course_int_id(); if (isset ($_GET['deletelink'])) { block_students(); - $get_delete_link=Security::remove_XSS($_GET['deletelink']); + $get_delete_link = intval($_GET['deletelink']); //fixing #5229 if (!empty($get_delete_link)) { $link= LinkFactory :: load($get_delete_link); From 46f92abeb612f4f832074d861e2da5017917bfa4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 12:13:40 +0200 Subject: [PATCH 043/124] Minor cosmetic changes --- .../gradebook/lib/gradebook_functions.inc.php | 833 +++++++++--------- 1 file changed, 416 insertions(+), 417 deletions(-) diff --git a/main/gradebook/lib/gradebook_functions.inc.php b/main/gradebook/lib/gradebook_functions.inc.php index 55df90d2b0..de868b0fcc 100644 --- a/main/gradebook/lib/gradebook_functions.inc.php +++ b/main/gradebook/lib/gradebook_functions.inc.php @@ -1,17 +1,18 @@ , Hogeschool Ghent -* @author Julio Montoya adding security functions -* @version april 2007 -*/ -require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php'; + * These are functions used in gradebook + * + * @author Stijn Konings , Hogeschool Ghent + * @author Julio Montoya adding security functions + * @version april 2007 + */ +require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php'; require_once 'gradebook_functions_users.inc.php'; /** @@ -28,33 +29,33 @@ require_once 'gradebook_functions_users.inc.php'; * @param int Session ID (optional or 0 if not defined) * @return boolean True on success, false on failure */ -function add_resource_to_course_gradebook($category_id, $course_code, $resource_type, $resource_id, $resource_name='', $weight=0, $max=0, $resource_description='', $visible = 0, $session_id = 0, $link_id = null) { +function add_resource_to_course_gradebook($category_id, $course_code, $resource_type, $resource_id, $resource_name = '', $weight = 0, $max = 0, $resource_description = '', $visible = 0, $session_id = 0, $link_id = null) { $link = LinkFactory :: create($resource_type); $link->set_user_id(api_get_user_id()); $link->set_course_code($course_code); - + if (empty($category_id)) { - return false; - } + return false; + } $link->set_category_id($category_id); if ($link->needs_name_and_description()) { - $link->set_name($resource_name); + $link->set_name($resource_name); } else { - $link->set_ref_id($resource_id); + $link->set_ref_id($resource_id); } $link->set_weight($weight); if ($link->needs_max()) { - $link->set_max($max); + $link->set_max($max); } if ($link->needs_name_and_description()) { - $link->set_description($resource_description); + $link->set_description($resource_description); } - $link->set_visible(empty ($visible) ? 0 : 1); + $link->set_visible(empty($visible) ? 0 : 1); if (!empty($session_id)) { - $link->set_session_id($session_id); + $link->set_session_id($session_id); } $link->add(); return true; @@ -69,33 +70,34 @@ function update_resource_from_course_gradebook($link_id, $course_code, $weight) $course_code = Database::escape_string($course_code); if (!empty($link_id)) { $link_id = intval($link_id); - $sql = 'UPDATE '.Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK).' - SET weight = '."'".Database::escape_string((float)$weight)."'".' - WHERE course_code = "'.$course_code.'" AND id = '.$link_id; + $sql = 'UPDATE ' . Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK) . ' + SET weight = ' . "'" . Database::escape_string((float) $weight) . "'" . ' + WHERE course_code = "' . $course_code . '" AND id = ' . $link_id; Database::query($sql); - } + } return true; } - /** * Remove a resource from the unique gradebook of a given course * @param int Link/Resource ID * @return bool false on error, true on success */ function remove_resource_from_course_gradebook($link_id) { - if ( empty($link_id) ) { return false; } + if (empty($link_id)) { + return false; + } // TODO find the corresponding category (the first one for this course, ordered by ID) $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - $sql = "DELETE FROM $l WHERE id = ".(int)$link_id; + $sql = "DELETE FROM $l WHERE id = " . (int) $link_id; $res = Database::query($sql); return true; } -function block_students() { - if (!api_is_allowed_to_edit()) { - api_not_allowed(); - } +function block_students() { + if (!api_is_allowed_to_edit()) { + api_not_allowed(); + } } /** @@ -103,12 +105,12 @@ function block_students() { * @param string $code */ function get_course_name_from_code($code) { - $tbl_main_categories= Database :: get_main_table(TABLE_MAIN_COURSE); - $sql= 'SELECT title, code FROM ' . $tbl_main_categories . 'WHERE code = "' . Database::escape_string($code) . '"'; - $result= Database::query($sql); - if ($col= Database::fetch_array($result)) { - return $col['title']; - } + $tbl_main_categories = Database :: get_main_table(TABLE_MAIN_COURSE); + $sql = 'SELECT title, code FROM ' . $tbl_main_categories . 'WHERE code = "' . Database::escape_string($code) . '"'; + $result = Database::query($sql); + if ($col = Database::fetch_array($result)) { + return $col['title']; + } } /** @@ -116,60 +118,60 @@ function get_course_name_from_code($code) { * @param string $type value returned by a gradebookitem's get_icon_name() */ function build_type_icon_tag($kind, $attributes = array()) { - return Display::return_icon(get_icon_file_name($kind), ' ', $attributes, ICON_SIZE_SMALL); + return Display::return_icon(get_icon_file_name($kind), ' ', $attributes, ICON_SIZE_SMALL); } /** * Returns the icon filename for a gradebook item * @param string $type value returned by a gradebookitem's get_icon_name() */ -function get_icon_file_name ($type) { - switch ($type) { - case 'cat': - $icon = 'gradebook.png'; - break; - case 'evalempty': - $icon = 'empty_evaluation.png'; - break; - case 'evalnotempty': - $icon = 'no_empty_evaluation.png'; - break; - case 'exercise': - case LINK_EXERCISE: - $icon = 'quiz.gif'; - break; - case 'learnpath': - case LINK_LEARNPATH: - $icon = 'learnpath.png'; - break; - case 'studentpublication': - case LINK_STUDENTPUBLICATION: - $icon = 'works.gif'; - break; - case 'link': - $icon = 'link.gif'; - break; - case 'forum': - case LINK_FORUM_THREAD: - $icon = 'forum.gif'; - break; - case 'attendance': - case LINK_ATTENDANCE: - $icon = 'attendance.gif'; - break; - case 'survey': - case LINK_SURVEY: - $icon = 'survey.gif'; - break; - case 'dropbox': - case LINK_DROPBOX: - $icon = 'dropbox.gif'; - break; - default: - $icon = 'link.gif'; - break; - } - return $icon; +function get_icon_file_name($type) { + switch ($type) { + case 'cat': + $icon = 'gradebook.png'; + break; + case 'evalempty': + $icon = 'empty_evaluation.png'; + break; + case 'evalnotempty': + $icon = 'no_empty_evaluation.png'; + break; + case 'exercise': + case LINK_EXERCISE: + $icon = 'quiz.gif'; + break; + case 'learnpath': + case LINK_LEARNPATH: + $icon = 'learnpath.png'; + break; + case 'studentpublication': + case LINK_STUDENTPUBLICATION: + $icon = 'works.gif'; + break; + case 'link': + $icon = 'link.gif'; + break; + case 'forum': + case LINK_FORUM_THREAD: + $icon = 'forum.gif'; + break; + case 'attendance': + case LINK_ATTENDANCE: + $icon = 'attendance.gif'; + break; + case 'survey': + case LINK_SURVEY: + $icon = 'survey.gif'; + break; + case 'dropbox': + case LINK_DROPBOX: + $icon = 'dropbox.gif'; + break; + default: + $icon = 'link.gif'; + break; + } + return $icon; } /** @@ -178,151 +180,153 @@ function get_icon_file_name ($type) { * @param int $selectcat id of selected category */ function build_edit_icons_cat($cat, $selectcat) { - $show_message = $cat->show_message_resource_delete($cat->get_course_code()); + $show_message = $cat->show_message_resource_delete($cat->get_course_code()); $grade_model_id = $selectcat->get_grade_model_id(); - + $selectcat = $selectcat->get_id(); - - if ($show_message === false) { - $visibility_icon= ($cat->is_visible() == 0) ? 'invisible' : 'visible'; - $visibility_command= ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; - - $modify_icons .= ''.Display::return_icon('view_more_stats.gif', get_lang('Show'),'',ICON_SIZE_SMALL).''; - + + if ($show_message === false) { + $visibility_icon = ($cat->is_visible() == 0) ? 'invisible' : 'visible'; + $visibility_command = ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; + + $modify_icons .= '' . Display::return_icon('view_more_stats.gif', get_lang('Show'), '', ICON_SIZE_SMALL) . ''; + if (api_is_allowed_to_edit(null, true)) { - + //Locking button - if (api_get_setting('gradebook_locking_enabled') == 'true') { - + if (api_get_setting('gradebook_locking_enabled') == 'true') { + if ($cat->is_locked()) { if (api_is_platform_admin()) { - $modify_icons .= ' '. - Display::return_icon('lock.png', get_lang('UnLockEvaluation'),'',ICON_SIZE_SMALL).''; + $modify_icons .= ' ' . + Display::return_icon('lock.png', get_lang('UnLockEvaluation'), '', ICON_SIZE_SMALL) . ''; } else { - $modify_icons .= ' '.Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'),'',ICON_SIZE_SMALL).''; + $modify_icons .= ' ' . Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'), '', ICON_SIZE_SMALL) . ''; } - $modify_icons .= ' '.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'', ICON_SIZE_SMALL).''; + $modify_icons .= ' ' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . ''; } else { - $modify_icons .= ' '. - Display::return_icon('unlock.png', get_lang('LockEvaluation'),'',ICON_SIZE_SMALL).''; - $modify_icons .= ' '.Display::return_icon('pdf_na.png', get_lang('ExportToPDF'),'',ICON_SIZE_SMALL).''; + $modify_icons .= ' ' . + Display::return_icon('unlock.png', get_lang('LockEvaluation'), '', ICON_SIZE_SMALL) . ''; + $modify_icons .= ' ' . Display::return_icon('pdf_na.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . ''; //$modify_icons .= ' '.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_SMALL).''; - } + } } - + if (empty($grade_model_id) || $grade_model_id == -1) { if ($cat->is_locked() && !api_is_platform_admin()) { - $modify_icons .= Display::return_icon('edit_na.png', get_lang('Modify'),'',ICON_SIZE_SMALL); + $modify_icons .= Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); } else { - $modify_icons .= ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).''; + $modify_icons .= '' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . ''; } } - - $modify_icons .= ''.Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_SMALL).''; - $modify_icons .= ''.Display::return_icon('stats.png', get_lang('FlatView'),'', ICON_SIZE_SMALL).''; - $modify_icons .= ' '.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).''; + + $modify_icons .= '' . Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_SMALL) . ''; + $modify_icons .= '' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_SMALL) . ''; + $modify_icons .= ' ' . Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . ''; //no move ability for root categories if ($cat->is_movable()) { - /*$modify_icons .= '  - ';*/ + /* $modify_icons .= '  + '; */ } else { //$modify_icons .= ' '; } - + if ($cat->is_locked() && !api_is_platform_admin()) { - $modify_icons .= Display::return_icon('delete_na.png', get_lang('DeleteAll'),'',ICON_SIZE_SMALL); + $modify_icons .= Display::return_icon('delete_na.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL); } else { - $modify_icons .= ' '.Display::return_icon('delete.png', get_lang('DeleteAll'),'',ICON_SIZE_SMALL).''; - } + $modify_icons .= ' ' . Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL) . ''; + } } - return $modify_icons; - } + return $modify_icons; + } } + /** * Builds the course or platform admin icons to edit an evaluation * @param object $eval evaluation object * @param int $selectcat id of selected category */ function build_edit_icons_eval($eval, $selectcat) { - $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); - $is_locked = $eval->is_locked(); - $eval->get_course_code(); - $cat=new Category(); - $message_eval=$cat->show_message_resource_delete($eval->get_course_code()); - - if ($message_eval===false && api_is_allowed_to_edit(null, true)) { - $visibility_icon= ($eval->is_visible() == 0) ? 'invisible' : 'visible'; - $visibility_command= ($eval->is_visible() == 0) ? 'set_visible' : 'set_invisible'; + $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); + $is_locked = $eval->is_locked(); + $eval->get_course_code(); + $cat = new Category(); + $message_eval = $cat->show_message_resource_delete($eval->get_course_code()); + + if ($message_eval === false && api_is_allowed_to_edit(null, true)) { + $visibility_icon = ($eval->is_visible() == 0) ? 'invisible' : 'visible'; + $visibility_command = ($eval->is_visible() == 0) ? 'set_visible' : 'set_invisible'; if ($is_locked && !api_is_platform_admin()) { - $modify_icons= Display::return_icon('edit_na.png', get_lang('Modify'),'',ICON_SIZE_SMALL); + $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); } else { - $modify_icons= ''.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).''; + $modify_icons = '' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . ''; + } + + $modify_icons .= ' ' . Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . ''; + if (api_is_allowed_to_edit(null, true)) { + $modify_icons .= ' ' . Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . ''; } - $modify_icons .= ' '.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).''; - if (api_is_allowed_to_edit(null, true)){ - $modify_icons .= ' '.Display::return_icon('history.png', get_lang('GradebookQualifyLog'),'',ICON_SIZE_SMALL).''; - } - /* - if ($locked_status == 0){ - $modify_icons .= " ".Display::return_icon('unlock.png',get_lang('LockEvaluation'), array(), ICON_SIZE_SMALL).""; - } else { - if (api_is_platform_admin()){ - $modify_icons .= " ".Display::return_icon('lock.png',get_lang('UnLockEvaluation'), array(), ICON_SIZE_SMALL).""; - } else { - $modify_icons .= ' '; - } - }*/ + if ($locked_status == 0){ + $modify_icons .= " ".Display::return_icon('unlock.png',get_lang('LockEvaluation'), array(), ICON_SIZE_SMALL).""; + } else { + if (api_is_platform_admin()){ + $modify_icons .= " ".Display::return_icon('lock.png',get_lang('UnLockEvaluation'), array(), ICON_SIZE_SMALL).""; + } else { + $modify_icons .= ' '; + } + } */ if ($is_locked && !api_is_platform_admin()) { - $modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'),'',ICON_SIZE_SMALL); + $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); } else { - $modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).''; + $modify_icons .= ' ' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . ''; } - return $modify_icons; - } + return $modify_icons; + } } + /** * Builds the course or platform admin icons to edit a link * @param object $linkobject * @param int $selectcat id of selected category */ -function build_edit_icons_link($link, $selectcat) { - $cat = new Category(); - $message_link = $cat->show_message_resource_delete($link->get_course_code()); +function build_edit_icons_link($link, $selectcat) { + $cat = new Category(); + $message_link = $cat->show_message_resource_delete($link->get_course_code()); $is_locked = $link->is_locked(); - + $modify_icons = null; - + if (!api_is_allowed_to_edit(null, true)) { return null; } - - if ($message_link === false) { - $visibility_icon = ($link->is_visible() == 0) ? 'invisible' : 'visible'; - $visibility_command = ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible'; - + + if ($message_link === false) { + $visibility_icon = ($link->is_visible() == 0) ? 'invisible' : 'visible'; + $visibility_command = ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible'; + if ($is_locked && !api_is_platform_admin()) { - $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'),'',ICON_SIZE_SMALL); - } else { - $modify_icons = ''. - Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).''; + $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); + } else { + $modify_icons = '' . + Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . ''; } - //$modify_icons .= ' '; - $modify_icons .= ' '.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).''; - $modify_icons .= ' '.Display::return_icon('history.png', get_lang('GradebookQualifyLog'),'',ICON_SIZE_SMALL).''; - - //If a work is added in a gradebook you can only delete the link in the work tool - + //$modify_icons .= ' '; + $modify_icons .= ' ' . Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . ''; + $modify_icons .= ' ' . Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . ''; + + //If a work is added in a gradebook you can only delete the link in the work tool + if ($is_locked && !api_is_platform_admin()) { - $modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'),'',ICON_SIZE_SMALL); + $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); } else { - $modify_icons .= ' '.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).''; - } - return $modify_icons; - } + $modify_icons .= ' ' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . ''; + } + return $modify_icons; + } } /** @@ -337,25 +341,25 @@ function is_resource_in_course_gradebook($course_code, $resource_type, $resource // TODO find the corresponding category (the first one for this course, ordered by ID) $t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - /*$sql = "SELECT * FROM $t WHERE course_code = '".Database::escape_string($course_code)."' "; - if (!empty($session_id)) { - $sql .= " AND session_id = ".(int)$session_id; - } else { - $sql .= " AND (session_id IS NULL OR session_id = 0) "; - } - $sql .= " ORDER BY id"; - $res = Database::query($sql); - if (Database::num_rows($res)<1) { - return false; - } - $row = Database::fetch_array($res,'ASSOC'); - $category = $row['id'];*/ - + /* $sql = "SELECT * FROM $t WHERE course_code = '".Database::escape_string($course_code)."' "; + if (!empty($session_id)) { + $sql .= " AND session_id = ".(int)$session_id; + } else { + $sql .= " AND (session_id IS NULL OR session_id = 0) "; + } + $sql .= " ORDER BY id"; + $res = Database::query($sql); + if (Database::num_rows($res)<1) { + return false; + } + $row = Database::fetch_array($res,'ASSOC'); + $category = $row['id']; */ + $course_code = Database::escape_string($course_code); - $sql = "SELECT * FROM $l l WHERE course_code = '$course_code' AND type = ".(int) $resource_type." and ref_id = ".(int) $resource_id; + $sql = "SELECT * FROM $l l WHERE course_code = '$course_code' AND type = " . (int) $resource_type . " and ref_id = " . (int) $resource_id; $res = Database::query($sql); - if (Database::num_rows($res)<1) { - return false; + if (Database::num_rows($res) < 1) { + return false; } $row = Database::fetch_array($res, 'ASSOC'); return $row; @@ -367,10 +371,12 @@ function is_resource_in_course_gradebook($course_code, $resource_type, $resource * @return bool false on error, true on success */ function get_resource_from_course_gradebook($link_id) { - if ( empty($link_id) ) { return false; } + if (empty($link_id)) { + return false; + } // TODO find the corresponding category (the first one for this course, ordered by ID) $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - $sql = "SELECT * FROM $l WHERE id = ".(int)$link_id; + $sql = "SELECT * FROM $l WHERE id = " . (int) $link_id; $res = Database::query($sql); $row = array(); if (Database::num_rows($res) > 0) { @@ -385,109 +391,105 @@ function get_resource_from_course_gradebook($link_id) { * @return String */ function get_database_name_by_link_id($id_link) { - $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - $sql = 'SELECT db_name FROM '.$course_table.' c INNER JOIN '.$tbl_grade_links.' l - ON c.code=l.course_code WHERE l.id='.intval($id_link).' OR l.category_id='.intval($id_link); - $res=Database::query($sql); - $my_db_name=Database::fetch_array($res,'ASSOC'); - return $my_db_name['db_name']; + $course_table = Database::get_main_table(TABLE_MAIN_COURSE); + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); + $sql = 'SELECT db_name FROM ' . $course_table . ' c INNER JOIN ' . $tbl_grade_links . ' l + ON c.code=l.course_code WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); + $res = Database::query($sql); + $my_db_name = Database::fetch_array($res, 'ASSOC'); + return $my_db_name['db_name']; } /** -* Return the course id -* @param int -* @return String -*/ + * Return the course id + * @param int + * @return String + */ function get_course_id_by_link_id($id_link) { - $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - $sql = 'SELECT c.id FROM '.$course_table.' c INNER JOIN '.$tbl_grade_links.' l - ON c.code = l.course_code WHERE l.id='.intval($id_link).' OR l.category_id='.intval($id_link); - $res = Database::query($sql); - $array = Database::fetch_array($res,'ASSOC'); - return $array['id']; + $course_table = Database::get_main_table(TABLE_MAIN_COURSE); + $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); + $sql = 'SELECT c.id FROM ' . $course_table . ' c INNER JOIN ' . $tbl_grade_links . ' l + ON c.code = l.course_code WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); + $res = Database::query($sql); + $array = Database::fetch_array($res, 'ASSOC'); + return $array['id']; } -function get_table_type_course($type) { - global $table_evaluated; - return Database::get_course_table($table_evaluated[$type][0]); +function get_table_type_course($type) { + global $table_evaluated; + return Database::get_course_table($table_evaluated[$type][0]); } function get_printable_data($cat, $users, $alleval, $alllinks, $params) { - $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks, $params); - - $offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; - $offset = intval($offset); - + $datagen = new FlatViewDataGenerator($users, $alleval, $alllinks, $params); + + $offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; + $offset = intval($offset); + // step 2: generate rows: students $datagen->category = $cat; - - $count = (($offset + 10) > $datagen->get_total_items_count()) ? ($datagen->get_total_items_count() - $offset) : LIMIT; - $header_names = $datagen->get_header_names($offset, $count, true); - $data_array = $datagen->get_data(FlatViewDataGenerator :: FVDG_SORT_LASTNAME, 0, null, $offset, $count, true, true); - - $newarray = array(); - foreach ($data_array as $data) { - $newarray[] = array_slice($data, 1); - } - $return = array($header_names, $newarray); - return $return; -} + $count = (($offset + 10) > $datagen->get_total_items_count()) ? ($datagen->get_total_items_count() - $offset) : LIMIT; + $header_names = $datagen->get_header_names($offset, $count, true); + $data_array = $datagen->get_data(FlatViewDataGenerator :: FVDG_SORT_LASTNAME, 0, null, $offset, $count, true, true); + + $newarray = array(); + foreach ($data_array as $data) { + $newarray[] = array_slice($data, 1); + } + $return = array($header_names, $newarray); + return $return; +} /** * XML-parser: handle character data */ - function character_data($parser, $data) { - global $current_value; - $current_value= $data; + global $current_value; + $current_value = $data; } /** * XML-parser: handle end of element */ - function element_end($parser, $data) { - global $user; - global $users; - global $current_value; - switch ($data) { - case 'Result' : - $users[]= $user; - break; - default : - $user[$data]= $current_value; - break; - } + global $user; + global $users; + global $current_value; + switch ($data) { + case 'Result' : + $users[] = $user; + break; + default : + $user[$data] = $current_value; + break; + } } /** * XML-parser: handle start of element */ - function element_start($parser, $data) { - global $user; - global $current_tag; - switch ($data) { - case 'Result' : - $user= array (); - break; - default : - $current_tag= $data; - } + global $user; + global $current_tag; + switch ($data) { + case 'Result' : + $user = array(); + break; + default : + $current_tag = $data; + } } function overwritescore($resid, $importscore, $eval_max) { - $result= Result :: load($resid); - if ($importscore > $eval_max) { - header('Location: gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']) . '&overwritemax='); - exit; - } - $result[0]->set_score($importscore); - $result[0]->save(); - unset ($result); + $result = Result :: load($resid); + if ($importscore > $eval_max) { + header('Location: gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '&overwritemax='); + exit; + } + $result[0]->set_score($importscore); + $result[0]->save(); + unset($result); } /** @@ -495,148 +497,145 @@ function overwritescore($resid, $importscore, $eval_max) { * @param string $file Path to the XML-file * @return array All userinformation read from the file */ - function parse_xml_data($file) { - global $current_tag; - global $current_value; - global $user; - global $users; - $users= array (); - $parser= xml_parser_create(); - xml_set_element_handler($parser, 'element_start', 'element_end'); - xml_set_character_data_handler($parser, "character_data"); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); - xml_parse($parser, file_get_contents($file)); - xml_parser_free($parser); - return $users; + global $current_tag; + global $current_value; + global $user; + global $users; + $users = array(); + $parser = xml_parser_create(); + xml_set_element_handler($parser, 'element_start', 'element_end'); + xml_set_character_data_handler($parser, "character_data"); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); + xml_parse($parser, file_get_contents($file)); + xml_parser_free($parser); + return $users; } - - /** -* register user info about certificate -* @param int The category id -* @param int The user id -* @param float The score obtained for certified -* @param Datetime The date when you obtained the certificate -* @return void() -*/ -function register_user_info_about_certificate ($cat_id, $user_id, $score_certificate, $date_certificate) { + * register user info about certificate + * @param int The category id + * @param int The user id + * @param float The score obtained for certified + * @param Datetime The date when you obtained the certificate + * @return void() + */ +function register_user_info_about_certificate($cat_id, $user_id, $score_certificate, $date_certificate) { $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql_exist='SELECT COUNT(*) as count FROM '.$table_certificate.' gc - WHERE gc.cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'" '; - $rs_exist=Database::query($sql_exist); - $row=Database::fetch_array($rs_exist); - if ($row['count']==0) { - $sql='INSERT INTO '.$table_certificate.' (cat_id,user_id,score_certificate,created_at) - VALUES("'.intval($cat_id).'","'.intval($user_id).'","'.Database::escape_string($score_certificate).'","'.Database::escape_string($date_certificate).'")'; - $rs = Database::query($sql); + $sql_exist = 'SELECT COUNT(*) as count FROM ' . $table_certificate . ' gc + WHERE gc.cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '" '; + $rs_exist = Database::query($sql_exist); + $row = Database::fetch_array($rs_exist); + if ($row['count'] == 0) { + $sql = 'INSERT INTO ' . $table_certificate . ' (cat_id,user_id,score_certificate,created_at) + VALUES("' . intval($cat_id) . '","' . intval($user_id) . '","' . Database::escape_string($score_certificate) . '","' . Database::escape_string($date_certificate) . '")'; + $rs = Database::query($sql); } } /** -* Get date of user certificate -* @param int The category id -* @param int The user id -* @return Datetime The date when you obtained the certificate -*/ -function get_certificate_by_user_id ($cat_id,$user_id) { - $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql_get_date='SELECT * FROM '.$table_certificate.' WHERE cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'"'; - $rs_get_date=Database::query($sql_get_date); - $row =Database::fetch_array($rs_get_date,'ASSOC'); - return $row; + * Get date of user certificate + * @param int The category id + * @param int The user id + * @return Datetime The date when you obtained the certificate + */ +function get_certificate_by_user_id($cat_id, $user_id) { + $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); + echo $sql_get_date = 'SELECT * FROM ' . $table_certificate . ' WHERE cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '"'; + $rs_get_date = Database::query($sql_get_date); + $row = Database::fetch_array($rs_get_date, 'ASSOC'); + return $row; } /** -* Get list of users certificates -* @param int The category id -* @return array -*/ -function get_list_users_certificates ($cat_id=null) { + * Get list of users certificates + * @param int The category id + * @return array + */ +function get_list_users_certificates($cat_id = null) { $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $table_user = Database::get_main_table(TABLE_MAIN_USER); $sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username - FROM '.$table_user.' u INNER JOIN '.$table_certificate.' gc ON u.user_id=gc.user_id '; - if (!is_null($cat_id) && $cat_id>0) { - $sql.=' WHERE cat_id='.Database::escape_string($cat_id); + FROM ' . $table_user . ' u INNER JOIN ' . $table_certificate . ' gc ON u.user_id=gc.user_id '; + if (!is_null($cat_id) && $cat_id > 0) { + $sql.=' WHERE cat_id=' . Database::escape_string($cat_id); } $sql.=' ORDER BY u.firstname'; $rs = Database::query($sql); $list_users = array(); - while ($row=Database::fetch_array($rs)) { - $list_users[]=$row; + while ($row = Database::fetch_array($rs)) { + $list_users[] = $row; } return $list_users; } /** -*Gets the certificate list by user id -*@param int The user id -*@param int The category id -*@return array -*/ -function get_list_gradebook_certificates_by_user_id ($user_id,$cat_id=null) { + * Gets the certificate list by user id + * @param int The user id + * @param int The category id + * @return array + */ +function get_list_gradebook_certificates_by_user_id($user_id, $cat_id = null) { $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql='SELECT gc.score_certificate, gc.created_at, gc.path_certificate, gc.cat_id, gc.user_id, gc.id FROM '.$table_certificate.' gc - WHERE gc.user_id="'.Database::escape_string($user_id).'" '; - if (!is_null($cat_id) && $cat_id>0) { - $sql.=' AND cat_id='.Database::escape_string($cat_id); + $sql = 'SELECT gc.score_certificate, gc.created_at, gc.path_certificate, gc.cat_id, gc.user_id, gc.id FROM ' . $table_certificate . ' gc + WHERE gc.user_id="' . Database::escape_string($user_id) . '" '; + if (!is_null($cat_id) && $cat_id > 0) { + $sql.=' AND cat_id=' . Database::escape_string($cat_id); } - + $rs = Database::query($sql); - $list_certificate=array(); - while ($row=Database::fetch_array($rs)) { - $list_certificate[]=$row; + $list_certificate = array(); + while ($row = Database::fetch_array($rs)) { + $list_certificate[] = $row; } return $list_certificate; } function get_user_certificate_content($user_id, $course_code, $is_preview = false) { //generate document HTML - $content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $is_preview); - - $new_content = explode('', $content_html['content']); - $new_content_html = $new_content[1]; - $path_image = api_get_path(WEB_COURSE_PATH).api_get_course_path($course_code).'/document/images/gallery'; - $new_content_html = str_replace('../images/gallery',$path_image,$new_content_html); - - $path_image_in_default_course = api_get_path(WEB_CODE_PATH).'default_course_document'; - $new_content_html = str_replace('/main/default_course_document',$path_image_in_default_course,$new_content_html); - $new_content_html = str_replace('/main/img/', api_get_path(WEB_IMG_PATH), $new_content_html); - + $content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $is_preview); + + $new_content = explode('', $content_html['content']); + $new_content_html = $new_content[1]; + $path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path($course_code) . '/document/images/gallery'; + $new_content_html = str_replace('../images/gallery', $path_image, $new_content_html); + + $path_image_in_default_course = api_get_path(WEB_CODE_PATH) . 'default_course_document'; + $new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html); + $new_content_html = str_replace('/main/img/', api_get_path(WEB_IMG_PATH), $new_content_html); + //add print header - $print = ''; - $print .= '' . get_lang('Print') . ' ' . get_lang('Print') . ''; - + $print = ''; + $print .= '' . get_lang('Print') . ' ' . get_lang('Print') . ''; + //add header - $new_content_html = $new_content[0].$print.''.$new_content_html; - return array('content' => $new_content_html, 'variables'=>$content_html['variables']); + $new_content_html = $new_content[0] . $print . '' . $new_content_html; + return array('content' => $new_content_html, 'variables' => $content_html['variables']); } -function create_default_course_gradebook( $course_code = null, $gradebook_model_id = 0) { +function create_default_course_gradebook($course_code = null, $gradebook_model_id = 0) { if (api_is_allowed_to_edit(true, true)) { if (!isset($course_code) || empty($course_code)) { - $course_code = api_get_course_id(); - } + $course_code = api_get_course_id(); + } $session_id = api_get_session_id(); - + $t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $sql = "SELECT * FROM $t WHERE course_code = '".Database::escape_string($course_code)."' "; + $sql = "SELECT * FROM $t WHERE course_code = '" . Database::escape_string($course_code) . "' "; if (!empty($session_id)) { - $sql .= " AND session_id = ".(int)$session_id; + $sql .= " AND session_id = " . (int) $session_id; } else { $sql .= " AND (session_id IS NULL OR session_id = 0) "; } $sql .= " ORDER BY id"; $res = Database::query($sql); - if (Database::num_rows($res)<1){ + if (Database::num_rows($res) < 1) { //there is no unique category for this course+session combination, $cat = new Category(); if (!empty($session_id)) { - $my_session_id=api_get_session_id(); + $my_session_id = api_get_session_id(); $s_name = api_get_session_name($my_session_id); - $cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name); + $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name); $cat->set_session_id($session_id); } else { $cat->set_name($course_code); @@ -648,14 +647,14 @@ function create_default_course_gradebook( $course_code = null, $gradebook_model_ $default_weight_setting = api_get_setting('gradebook_default_weight'); $default_weight = isset($default_weight_setting) && !empty($default_weight_setting) ? $default_weight_setting : 100; $cat->set_weight($default_weight); - + $cat->set_grade_model_id($gradebook_model_id); - - - $cat->set_visible(0); - $cat->add(); + + + $cat->set_visible(0); + $cat->add(); $category_id = $cat->get_id(); - unset ($cat); + unset($cat); } else { $row = Database::fetch_array($res); $category_id = $row['id']; @@ -663,21 +662,22 @@ function create_default_course_gradebook( $course_code = null, $gradebook_model_ } return $category_id; } -function load_gradebook_select_in_tool($form) { - + +function load_gradebook_select_in_tool($form) { + $course_code = api_get_course_id(); $session_id = api_get_session_id(); - + create_default_course_gradebook(); - + //Cat list - $all_categories = Category :: load(null, null, $course_code, null, null, $session_id, false); + $all_categories = Category :: load(null, null, $course_code, null, null, $session_id, false); $select_gradebook = $form->addElement('select', 'category_id', get_lang('SelectGradebook')); - + if (!empty($all_categories)) { foreach ($all_categories as $my_cat) { - if ($my_cat->get_course_code() == api_get_course_id()) { - $grade_model_id = $my_cat->get_grade_model_id(); + if ($my_cat->get_course_code() == api_get_course_id()) { + $grade_model_id = $my_cat->get_grade_model_id(); if (empty($grade_model_id)) { if ($my_cat->get_parent_id() == 0) { //$default_weight = $my_cat->get_weight(); @@ -690,10 +690,10 @@ function load_gradebook_select_in_tool($form) { } else { $select_gradebook->addoption(get_lang('Select'), 0); } - /*if ($this->evaluation_object->get_category_id() == $my_cat->get_id()) { - $default_weight = $my_cat->get_weight(); - } */ - } + /* if ($this->evaluation_object->get_category_id() == $my_cat->get_id()) { + $default_weight = $my_cat->get_weight(); + } */ + } } } } @@ -704,61 +704,61 @@ function load_gradebook_select_in_tool($form) { function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array()) { global $flatviewtable; //Getting data - $printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks, $params); + $printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks, $params); // HTML report creation first $course_code = trim($cat[0]->get_course_code()); - + $displayscore = ScoreDisplay :: instance(); $customdisplays = $displayscore->get_custom_score_display_settings(); - + $total = array(); - if (is_array($customdisplays) && count(($customdisplays))) { - foreach($customdisplays as $custom) { - $total[$custom['display']] = 0; - } + if (is_array($customdisplays) && count(($customdisplays))) { + foreach ($customdisplays as $custom) { + $total[$custom['display']] = 0; + } $user_results = $flatviewtable->datagen->get_data_to_graph2(); - foreach($user_results as $user_result) { - $total[$user_result[count($user_result)-1][1]]++; + foreach ($user_results as $user_result) { + $total[$user_result[count($user_result) - 1][1]]++; } } - - $parent_id = $cat[0]->get_parent_id(); + + $parent_id = $cat[0]->get_parent_id(); if (isset($cat[0]) && isset($parent_id)) { if ($parent_id == 0) { - $grade_model_id = $cat[0]->get_grade_model_id(); + $grade_model_id = $cat[0]->get_grade_model_id(); } else { - $parent_cat = Category::load($parent_id); - $grade_model_id = $parent_cat[0]->get_grade_model_id(); + $parent_cat = Category::load($parent_id); + $grade_model_id = $parent_cat[0]->get_grade_model_id(); } } - + $use_grade_model = true; if (empty($grade_model_id) || $grade_model_id == -1) { - $use_grade_model = false; + $use_grade_model = false; } - - if ($use_grade_model) { - if ($parent_id == 0) { - $title = api_strtoupper(get_lang('Average')).'
'.get_lang('Detailed'); + + if ($use_grade_model) { + if ($parent_id == 0) { + $title = api_strtoupper(get_lang('Average')) . '
' . get_lang('Detailed'); } else { - $title = api_strtoupper(get_lang('Average')).'
'.$cat[0]->get_description().' - ('.$cat[0]->get_name().')'; + $title = api_strtoupper(get_lang('Average')) . '
' . $cat[0]->get_description() . ' - (' . $cat[0]->get_name() . ')'; } } else { if ($parent_id == 0) { - $title = api_strtoupper(get_lang('Average')).'
'.get_lang('Detailed'); + $title = api_strtoupper(get_lang('Average')) . '
' . get_lang('Detailed'); } else { $title = api_strtoupper(get_lang('Average')); } } - - $columns = count($printable_data[0]); + + $columns = count($printable_data[0]); $has_data = is_array($printable_data[1]) && count($printable_data[1]) > 0; - + $table = new HTML_Table(array('class' => 'data_table')); $row = 0; - $column = 0; - + $column = 0; + $table->setHeaderContents($row, $column, get_lang('NumberAbbreviation')); $column++; foreach ($printable_data[0] as $printable_data_cell) { @@ -767,27 +767,27 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array( $column++; } $row++; - + if ($has_data) { $counter = 1; //var_dump($printable_data);exit; foreach ($printable_data[1] as &$printable_data_row) { $column = 0; - $table->setCellContents($row, $column, $counter); + $table->setCellContents($row, $column, $counter); $table->updateCellAttributes($row, $column, 'align="center"'); - $column++; - $counter++; - + $column++; + $counter++; + foreach ($printable_data_row as $key => &$printable_data_cell) { $attributes = array(); - $attributes['align'] = 'center'; + $attributes['align'] = 'center'; $attributes['style'] = null; - + if ($key === 'name') { $attributes['align'] = 'left'; } if ($key === 'total') { - $attributes['style'] = 'font-weight:bold'; + $attributes['style'] = 'font-weight:bold'; } //var_dump($key, $printable_data_cell, $attributes); $table->setCellContents($row, $column, $printable_data_cell); @@ -796,24 +796,24 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array( } $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true); $row++; - } + } } else { $column = 0; $table->setCellContents($row, $column, get_lang('NoResults')); - $table->updateCellAttributes($row, $column, 'colspan="'.$columns.'" align="center" class="row_odd"'); + $table->updateCellAttributes($row, $column, 'colspan="' . $columns . '" align="center" class="row_odd"'); } - $params = array( - 'filename' => get_lang('FlatView').'_'.api_get_utc_datetime(), + $params = array( + 'filename' => get_lang('FlatView') . '_' . api_get_utc_datetime(), 'pdf_title' => $title, 'course_code' => $course_code, 'add_signatures' => true ); - - $page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4'; - $pdf = new PDF($page_format, $params['orientation'], $params); + + $page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4'; + $pdf = new PDF($page_format, $params['orientation'], $params); $pdf->html_to_pdf_with_template($table->toHtml()); - exit; + exit; } function score_badges($list_values) { @@ -822,11 +822,10 @@ function score_badges($list_values) { foreach ($list_values as $value) { $class = 'info'; if ($counter == 1) { - $class = 'success'; - } + $class = 'success'; + } $counter++; - $badges[] = Display::badge($value, $class); - + $badges[] = Display::badge($value, $class); } return Display::badge_group($badges); } \ No newline at end of file From 7eb3eeb6be1ff9ea4c957bca4824a932ca375c9a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 13:39:11 +0200 Subject: [PATCH 044/124] Validating setting allow_user_course_subscription_by_course_admin see BT#5020 --- main/user/subscribe_user.php | 8 +++++++- main/user/user.php | 11 +++++++++-- main/user/user_import.php | 6 ++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/main/user/subscribe_user.php b/main/user/subscribe_user.php index 090e039772..b0de3b1df3 100644 --- a/main/user/subscribe_user.php +++ b/main/user/subscribe_user.php @@ -19,6 +19,12 @@ $this_section = SECTION_COURSES; // notice for unauthorized people. api_protect_course_script(true); +if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'false') { + if (!api_is_platform_admin()) { + api_not_allowed(true); + } +} + // access restriction if (!api_is_allowed_to_edit()) { api_not_allowed(true); @@ -644,7 +650,7 @@ function active_filter($active, $url_params, $row) { $image='error'; } if ($row['0']<>$_user['user_id']) { // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. - $result = '
'.Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('border'=>'0', 'style'=>'vertical-align: middle;') , 16).'
'; + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); } return $result; } diff --git a/main/user/user.php b/main/user/user.php index b2e5d945a1..9bc97bffd0 100644 --- a/main/user/user.php +++ b/main/user/user.php @@ -404,11 +404,18 @@ if ( api_is_allowed_to_edit(null, true)) { } $actions .= ''.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).' '; $actions .= ''.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).' '; - $actions .= ''.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).' '; + + if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) { + $actions .= ''.Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).' '; + } + $actions .= ''.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).' '; $actions .= "".Display::return_icon('group.png', get_lang("GroupUserManagement"),'',ICON_SIZE_MEDIUM).""; - $actions .= ' '.get_lang('Classes').''; + if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) { + $actions .= ' '.get_lang('Classes').''; + } + //$actions .= ' '.get_lang('SocialGroups').''; // Build search-form diff --git a/main/user/user_import.php b/main/user/user_import.php index a4afd91ed3..4db6bf895f 100644 --- a/main/user/user_import.php +++ b/main/user/user_import.php @@ -11,6 +11,12 @@ $this_section = SECTION_COURSES; // notice for unauthorized people. api_protect_course_script(true); +if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'false') { + if (!api_is_platform_admin()) { + api_not_allowed(true); + } +} + $tool_name = get_lang('ImportUsersToACourse'); $interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users")); From 2e2d633f611161d16a5e22a77e0125f122efb07a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 14:12:41 +0200 Subject: [PATCH 045/124] Adding new date format only day name: monday, sunday, etc see BT#4939 --- main/inc/lib/internationalization.lib.php | 13 ++++++++--- main/inc/lib/thematic.lib.php | 14 ++++-------- main/lang/spanish/trad4all.inc.php | 27 ++++++++++++----------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 7b4b393237..28cf7e6753 100644 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -29,11 +29,11 @@ define('DATE_FORMAT_LONG', 2); // Aug 25, 09 define('DATE_TIME_FORMAT_LONG', 3); // August 25, 2009 at 03:28 PM define('DATE_FORMAT_NUMBER', 4); // 25.08.09 -define('DATE_TIME_FORMAT_LONG_24H', 5); // August 25, 2009 at 15:28 - +define('DATE_TIME_FORMAT_LONG_24H', 5); // August 25, 2009 at 15:28 define('DATE_TIME_FORMAT_SHORT', 6); // Aug 25, 2009 at 03:28 PM define('DATE_TIME_FORMAT_SHORT_TIME_FIRST', 7); // 03:28 PM, Aug 25 2009 -define('DATE_FORMAT_NUMBER_NO_YEAR', 8); // 25.08 +define('DATE_FORMAT_NUMBER_NO_YEAR', 8); // 25.08 dd-mm +define('DATE_FORMAT_ONLY_DAYNAME', 9); // Monday, Sunday, etc // Formatting person's name. define('PERSON_NAME_COMMON_CONVENTION', 0); // Formatting a person's name using the pattern as it has been @@ -690,6 +690,13 @@ function api_format_date($time, $format = null, $language = null) { if (is_int($format)) { switch ($format) { + case DATE_FORMAT_ONLY_DAYNAME: + $date_format = get_lang('dateFormatOnlyDayName', '', $language); + if (IS_PHP_53 && INTL_INSTALLED) { + $datetype = IntlDateFormatter::SHORT; + $timetype = IntlDateFormatter::NONE; + } + break; case DATE_FORMAT_NUMBER_NO_YEAR: $date_format = get_lang('dateFormatShortNumberNoYear', '', $language); if (IS_PHP_53 && INTL_INSTALLED) { diff --git a/main/inc/lib/thematic.lib.php b/main/inc/lib/thematic.lib.php index f1494b9668..40068947fb 100644 --- a/main/inc/lib/thematic.lib.php +++ b/main/inc/lib/thematic.lib.php @@ -3,15 +3,11 @@ /** * This file contains class used like library, provides functions for thematic option inside attendance tool. It's also used like model to thematic_controller (MVC pattern) + * Thematic class can be used to instanciate objects or as a library for thematic control * @author Christian Fasanando * @author Julio Montoya SQL fixes * @package chamilo.course_progress */ - -/** - * Thematic class can be used to instanciate objects or as a library for thematic control - * @package chamilo.course_progress - */ class Thematic { private $session_id; @@ -45,13 +41,11 @@ class Thematic } $course_id = api_get_course_int_id(); $sql = "SELECT COUNT(id) AS total_number_of_items FROM $tbl_thematic WHERE c_id = $course_id AND active = 1 $condition_session "; - $res = Database::query($sql); - $res = Database::query($sql); + $res = Database::query($sql); $obj = Database::fetch_object($res); return $obj->total_number_of_items; } - /** * Get the thematics to display on the current page (fill the sortable-table) * @param int offset of first user to recover @@ -484,8 +478,8 @@ class Thematic $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']); } } - - $thematic_advance_item = '
'.api_convert_and_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG).$session_star.'
'; + //DATE_TIME_FORMAT_LONG + $thematic_advance_item = '
'.api_convert_and_format_date($thematic_advance['start_date'], DATE_FORMAT_ONLY_DAYNAME).$session_star.'
'; // $thematic_advance_item .= '
'.get_lang('DurationInHours').' : '.$thematic_advance['duration'].'
'; $thematic_advance_item .= '
'.$thematic_advance['duration'].' '.get_lang('HourShort').'
'; $thematic_advance_item .= '
'.Security::remove_XSS($thematic_advance['content'], STUDENT).'
'; diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index 019aa93159..50288ebd6c 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -841,7 +841,7 @@ $AssignSessions = "Asignar sesiones de formación"; $Timezone = "Zona horaria"; $DashboardPluginsHaveBeenUpdatedSucesslly = "Los plugins del panel de control han sido actualizados correctamente"; $LoginEnter = "Entrar"; -$AttendanceSheetDescription = "Las listas de asistencia permiten registrar las faltas de asistencia de los estudiantes. En caso de ausencia de un estudiante, el profesor deberá registrarlo manualmente en la casilla correspondiente. +$AttendanceSheetDescription = "Las listas de asistencia permiten registrar las faltas de asistencia de los estudiantes. En caso de ausencia de un estudiante, el profesor deberá registrarlo manualmente en la casilla correspondiente. Es posible crear más de una lista de asistencia por cada curso; así por ejemplo, podrá registrar separadamente la asistencia a las clases teóricas y prácticas."; $ThereAreNoRegisteredLearnersInsidetheCourse = "No hay estudiantes inscritos en este curso"; $GoToAttendanceCalendarList = "Ir al calendario de asistencia"; @@ -1005,14 +1005,14 @@ $YouMustAcceptLicence = "Debe aceptar la licencia para poder usar este software" $SelectOne = "Seleccione uno"; $ContactInformationHasBeenSent = "Información de contacto enviada"; $UserInactivedSinceX = "Usuario inactivo desde %s"; -$ContactInformationDescription = "Estimado usuario, - -está a punto de instalar una de las mejores plataformas e-learning de código abierto que existen en el mercado. Al igual de muchos otros proyectos de código abierto, Chamilo está respaldado por una amplia comunidad de profesores, estudiantes, desarrolladores y creadores de contenido. - -Si sabemos algo más de quien va a gestionar este sistema e-learning, podremos dar a conocer a otros que nuestro software lo utiliza y a usted podremos informarle sobre eventos que pueden ser de su interés. - -Cumplimentar este formulario, implica la aceptación de que la asociación Chamilo o sus miembros puedan enviarle información por correo electrónico sobre eventos importantes o actualizaciones en el software Chamilo. Esto ayudará a crecer a la comunidad como una entidad organizada, donde el flujo de información, se haga con respeto permanente a su tiempo y su privacidad. - +$ContactInformationDescription = "Estimado usuario, + +está a punto de instalar una de las mejores plataformas e-learning de código abierto que existen en el mercado. Al igual de muchos otros proyectos de código abierto, Chamilo está respaldado por una amplia comunidad de profesores, estudiantes, desarrolladores y creadores de contenido. + +Si sabemos algo más de quien va a gestionar este sistema e-learning, podremos dar a conocer a otros que nuestro software lo utiliza y a usted podremos informarle sobre eventos que pueden ser de su interés. + +Cumplimentar este formulario, implica la aceptación de que la asociación Chamilo o sus miembros puedan enviarle información por correo electrónico sobre eventos importantes o actualizaciones en el software Chamilo. Esto ayudará a crecer a la comunidad como una entidad organizada, donde el flujo de información, se haga con respeto permanente a su tiempo y su privacidad. + De cualquier forma, tenga en cuenta que no tiene la obligación de rellenar este formulario. Si desea permanecer en el anonimato, perderemos la oportunidad de ofrecerle todos los privilegios de ser un administrador de portal registrado, pero respetaremos su decisión. Basta con dejar vacío este formulario y hacer clic en \"Siguiente\" para seguir instalando Chamilo."; $CompanyActivity = "Sector"; $DateUnLock = "Desbloquear fecha"; @@ -1210,11 +1210,11 @@ $CertificateOnlineLink = "Vínculo al certificado en línea"; $NewExercises = "Nuevo ejercicio"; $MyAverage = "Mi promedio"; $AllAttempts = "Todos los intentos"; -$NoCookies = "Las cookies no están activadas en su navegador. +$NoCookies = "Las cookies no están activadas en su navegador. Chamilo utiliza \"cookies\" para almacenar sus datos de conexión, por lo que no le será posible entrar si las cookies no están habilitadas. Por favor, cambie la configuración de su navegador y recargue esta página."; -$NoJavascript = "Su navegador no tiene activado JavaScript. +$NoJavascript = "Su navegador no tiene activado JavaScript. Chamilo se sirve de JavaScript para proporcionar un interfaz más dinámico. Es probable que muchas prestaciones sigan funcionando pero otras no lo harán, especialmente las relacionadas con la usabilidad. Le recomendamos que cambie la configuración de su navegador y recargue esta página."; -$NoFlash = "Su navegador no tiene activado el soporte de Flash. +$NoFlash = "Su navegador no tiene activado el soporte de Flash. Chamilo sólo se apoya en Flash para algunas de sus funciones por lo que su ausencia no le impedirá continuar. Pero si quiere beneficiarse del conjunto de las herramientas de Chamilo, le recomendamos que instale-active el plugin de Flash y reinicialice su navegador."; $Attempt = "Intento"; $SaveForNow = "Guardar y continuar más tarde"; @@ -1294,7 +1294,7 @@ $LoginX = "Nombre de usuario: %s"; $ChatConnected = "Chat (Conectado)"; $ChatDisconnected = "Chat (Desconectado)"; $ThingsToDo = "Actividades por realizar"; -$WamiFlashDialog = "Se mostrará un cuadro de diálogo en el que se le pedirá permiso para poder acceder al micrófono, responda afirmativamente y cierre el cuadro de diálogo (si no desea que vuelva a aparecer, antes de cerrar marque la opción +$WamiFlashDialog = "Se mostrará un cuadro de diálogo en el que se le pedirá permiso para poder acceder al micrófono, responda afirmativamente y cierre el cuadro de diálogo (si no desea que vuelva a aparecer, antes de cerrar marque la opción recordar)"; $WamiStartRecorder = "Inicie la grabación pulsando el micrófono y deténgala pulsándolo de nuevo. Cada vez que haga esto se generará un archivo."; $InputNameHere = "Escriba el nombre aquí"; @@ -1385,4 +1385,5 @@ $DataTableSearch = "Buscar"; $HideColumn = "Ocultar columna"; $DisplayColumn = "Mostrar columna"; $LegalAgreementAccepted = "Condiciones legales aceptadas"; +$dateFormatOnlyDayName = "%A"; ?> \ No newline at end of file From 56c5f0f1bca2dd2d7e011667bd4d3c186a906353 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 16:31:32 +0200 Subject: [PATCH 046/124] Fixes bug when creating groups see #5551 --- main/document/document.inc.php | 30 ++--- main/document/document.php | 2 +- main/forum/forumfunction.inc.php | 30 +++-- main/gradebook/lib/fe/flatviewtable.class.php | 1 - main/group/group.php | 2 +- main/group/group_creation.php | 6 +- main/group/group_space.php | 115 ++++++++++++------ main/inc/lib/document.lib.php | 58 ++++----- main/inc/lib/fileUpload.lib.php | 11 +- main/inc/lib/groupmanager.lib.php | 110 +++++++++-------- main/inc/lib/main_api.lib.php | 9 +- 11 files changed, 220 insertions(+), 154 deletions(-) diff --git a/main/document/document.inc.php b/main/document/document.inc.php index bcccdfc611..17a9526a71 100644 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -67,20 +67,22 @@ function build_directory_selector($folders, $document_id, $group_dir = '', $chan } } } - } else { - foreach ($folders as $folder_id => & $folder) { - $selected = ($document_id == $folder_id) ? ' selected="selected"' : ''; - $label = $folder_titles[$folder]; - if ($folder == $group_dir) { - $label = get_lang('Documents'); - } else { - $path_parts = explode('/', str_replace($group_dir, '', $folder)); - $label = cut($label, 80); - $label = str_repeat('   ', count($path_parts) - 2).' — '.$label; - } - $parent_select -> addOption($label, $folder_id); - if ($selected != '') { - $parent_select->setSelected($folder_id); + } else { + if (!empty($folders)) { + foreach ($folders as $folder_id => & $folder) { + $selected = ($document_id == $folder_id) ? ' selected="selected"' : ''; + $label = $folder_titles[$folder]; + if ($folder == $group_dir) { + $label = get_lang('Documents'); + } else { + $path_parts = explode('/', str_replace($group_dir, '', $folder)); + $label = cut($label, 80); + $label = str_repeat('   ', count($path_parts) - 2).' — '.$label; + } + $parent_select -> addOption($label, $folder_id); + if ($selected != '') { + $parent_select->setSelected($folder_id); + } } } } diff --git a/main/document/document.php b/main/document/document.php index 1c85bc5fe8..d988ab521d 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -90,7 +90,7 @@ $dbl_click_id = 0; // Used for avoiding double-click $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : null; /* Constants and variables */ -$session_id = api_get_session_id(); +$session_id = api_get_session_id(); $course_code = api_get_course_id(); $to_group_id = api_get_group_id(); diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index c3a5c68ee3..ea4d51d5dc 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -507,23 +507,33 @@ function store_forumcategory($values) { * @version february 2006, dokeos 1.8 */ function store_forum($values) { - global $_course; - global $_user; + global $_course; + $course_id = api_get_course_int_id(); + $session_id = api_get_session_id(); + + if (isset($values['group_id']) && !empty($values['group_id'])) { + $group_id = $values['group_id']; + } else { + $group_id = api_get_group_id(); + } + $table_forums = Database::get_course_table(TABLE_FORUM); // Find the max forum_order for the given category. The new forum is added at the end => max cat_order + & if (is_null($values['forum_category'])) { $new_max = null; } else { - $sql = "SELECT MAX(forum_order) as sort_max FROM ".$table_forums." - WHERE c_id = $course_id AND forum_category='".Database::escape_string($values['forum_category'])."'"; + $sql = "SELECT MAX(forum_order) as sort_max + FROM ".$table_forums." + WHERE c_id = $course_id AND + forum_category='".Database::escape_string($values['forum_category'])."'"; $result = Database::query($sql); $row = Database::fetch_array($result); $new_max = $row['sort_max'] + 1; } - $session_id = api_get_session_id(); + $clean_title = Database::escape_string($values['forum_title']); // Forum images @@ -595,8 +605,10 @@ function store_forum($values) { forum_of_group='". Database::escape_string($values['group_forum'])."' WHERE c_id = $course_id AND forum_id='".Database::escape_string($values['forum_id'])."'"; Database::query($sql); - - api_item_property_update($_course, TOOL_FORUM, Database::escape_string($values['forum_id']), 'ForumUpdated', api_get_user_id()); + + + api_item_property_update($_course, TOOL_FORUM, Database::escape_string($values['forum_id']), 'ForumUpdated', api_get_user_id(), $group_id); + $return_message = get_lang('ForumEdited'); } else { $sql_image = ''; @@ -626,8 +638,8 @@ function store_forum($values) { Database::query($sql); $last_id = Database::insert_id(); if ($last_id > 0) { - api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id()); - api_set_default_visibility($last_id, TOOL_FORUM); + api_item_property_update($_course, TOOL_FORUM, $last_id, 'ForumAdded', api_get_user_id(), $group_id); + api_set_default_visibility($last_id, TOOL_FORUM, $group_id); } $return_message = get_lang('ForumAdded'); } diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index e0f56ffb4f..5a83e9f592 100644 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -488,7 +488,6 @@ class FlatViewTable extends SortableTable $column++; } - //$this->set_header($column++, get_lang('Total')); $data_array = $this->datagen->get_data($users_sorting, $from, $this->per_page, $this->offset, $selectlimit); $table_data = array(); diff --git a/main/group/group.php b/main/group/group.php index 371e65a238..d5be82149a 100644 --- a/main/group/group.php +++ b/main/group/group.php @@ -250,7 +250,7 @@ foreach ($group_cats as $index => $category) { GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_WIKI)) && !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) { $orig = isset($origin) ? $origin : null; - $group_name = ''.stripslashes($this_group['name']).''; + $group_name = ''.Security::remove_XSS($this_group['name']).''; if (!empty($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) { $group_name .= ' ('.get_lang('OneMyGroups').')'; } elseif ($this_group['is_member']) { diff --git a/main/group/group_creation.php b/main/group/group_creation.php index eb95bb1870..799471565b 100644 --- a/main/group/group_creation.php +++ b/main/group/group_creation.php @@ -17,8 +17,6 @@ $current_course_tool = TOOL_GROUP; // Notice for unauthorized people. api_protect_course_script(true); -require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; -require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php'; /* Create the groups */ @@ -288,6 +286,7 @@ EOT; /* * Show form to generate groups from classes subscribed to the course */ + /* $classes = ClassManager :: get_classes_in_course($_course['sysCode']); if (count($classes) > 0) { echo ''.get_lang('GroupsFromClasses').''; @@ -324,7 +323,8 @@ EOT; $create_class_groups_form->setDefaults($defaults); $create_class_groups_form->display(); echo ''; - } + }*/ + } /* FOOTER */ diff --git a/main/group/group_space.php b/main/group/group_space.php index 2ff27a6e8c..1af8e33611 100644 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -123,7 +123,7 @@ $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course $edit_url = ''; if (api_is_allowed_to_edit(false, true) or GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $my_origin = isset($origin) ? $origin : ''; - $edit_url = ''.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).''; + $edit_url = ''.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).''; } echo Display::page_header(Security::remove_XSS($current_group['name']).' '.$edit_url.' '.$subscribe_group.' '.$unsubscribe_group); @@ -136,9 +136,8 @@ if (!empty($current_group['description'])) { * Group Tools */ // If the user is subscribed to the group or the user is a tutor of the group then -if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_get_user_id(), $current_group['id'])) { - echo '
    '; - $tools = ''; +if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_get_user_id(), $current_group['id'])) { + $actions_array = array(); // Link to the forum of this group $forums_of_groups = get_forums_of_group($current_group['id']); @@ -146,93 +145,141 @@ if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_ if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE ) { foreach ($forums_of_groups as $key => $value) { if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false, true)) { - $tools .= '
  • '.Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&origin=group', + 'content' => Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32) + ); } } } } if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE ) { - // Link to the documents area of this group - $tools .= '
  • '.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'
  • '; + // Link to the documents area of this group + $actions_array[] = array( + 'url' => '../document/document.php?'.api_get_cidreq(), + 'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32) + ); } if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to a group-specific part of agenda - $tools .= '
  • '.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../calendar/agenda.php?'.api_get_cidreq(), + 'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32) + ); } if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to the works area of this group - $tools .= '
  • '.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../work/work.php?'.api_get_cidreq(), + 'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), 32) + ); + } if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to a group-specific part of announcements - $tools .= '
  • '.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../announcements/announcements.php?'.api_get_cidreq(), + 'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32) + ); } + if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to the wiki area of this group - $tools .= '
  • '.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../wiki/index.php?'.api_get_cidreq().'&action=show&title=index&session_id='.api_get_session_id().'&group_id='.$current_group['id'], + 'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32) + ); } if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to the chat area of this group if (api_get_course_setting('allow_open_chat_window')) { - $tools .= "
  • ".Display::return_icon('chat.png', get_lang('Chat'),'',ICON_SIZE_MEDIUM)."
  • "; + $actions_array[] = array( + 'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"", + 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) + ); } else { - $tools .= "
  • ".Display::return_icon('chat.png', get_lang('Chat'), array(), 32)."
  • "; + $actions_array[] = array( + 'url' => "../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id'], + 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) + ); } } -echo '
'; - echo Display::page_subheader(get_lang('Tools')); - if (!empty($tools)) { - echo $tools; + + if (!empty($actions_array)) { + echo Display::page_subheader(get_lang('Tools')); + echo Display::actions($actions_array); } } else { - echo '
    '; - - $tools = ''; + $actions_array = array(); + // Link to the forum of this group $forums_of_groups = get_forums_of_group($current_group['id']); if (is_array($forums_of_groups)) { if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC ) { foreach ($forums_of_groups as $key => $value) { - if ($value['forum_group_public_private'] == 'public' ) { - $tools.= '
  • '.Display::return_icon('forum.png', get_lang('GroupForum'), array(), 32).'
  • '; + if ($value['forum_group_public_private'] == 'public' ) { + $actions_array[] = array( + 'url' => '../forum/viewforum.php?cidReq='.api_get_course_id().'&forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&origin=group', + 'content' => Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_MEDIUM) + ); } } } } if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) { // Link to the documents area of this group - $tools .= '
  • '.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../document/document.php?cidReq='.api_get_course_id().'&origin='.$origin, + 'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), ICON_SIZE_MEDIUM) + ); } if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) { // Link to a group-specific part of agenda - $tools .= '
  • '.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../calendar/agenda.php?'.api_get_cidreq(), + 'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), ICON_SIZE_MEDIUM) + ); + } if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) { // Link to the works area of this group - $tools .= '
  • '.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../work/work.php?'.api_get_cidreq(), + 'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_MEDIUM) + ); } if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) { // Link to a group-specific part of announcements - $tools .= '
  • '.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../announcements/announcements.php?'.api_get_cidreq(), + 'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), ICON_SIZE_MEDIUM) + ); } if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) { // Link to the wiki area of this group - $tools .= '
  • '.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'
  • '; + $actions_array[] = array( + 'url' => '../wiki/index.php?'.api_get_cidreq().'&action=show&title=index&session_id='.api_get_session_id().'&group_id='.$current_group['id'], + 'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32) + ); } if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC ) { // Link to the chat area of this group if (api_get_course_setting('allow_open_chat_window')) { - $tools .= "
  • ".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."
  • "; + $actions_array[] = array( + 'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"", + 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) + ); } else { - $tools .= "
  • ".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."
  • "; + $actions_array[] = array( + 'url' => "../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id'], + 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) + ); } } - echo '
'; - - echo Display::page_subheader(get_lang('Tools')); - if (!empty($tools)) { - echo $tools; + if (!empty($actions_array)) { + echo Display::page_subheader(get_lang('Tools')); + echo Display::actions($actions_array); } } diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index aa4d09f942..37c3cf3a2c 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -457,8 +457,6 @@ class DocumentManager { $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); - //if to_user_id = NULL -> change query (IS NULL) - //$to_user_id = (is_null($to_user_id)) ? 'IS NULL' : '= '.$to_user_id; if (!is_null($to_user_id)) { $to_field = 'last.to_user_id'; $to_value = $to_user_id; @@ -492,28 +490,28 @@ class DocumentManager { } //condition for search (get ALL folders and documents) - if ($search) { - $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id - FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs - WHERE docs.id = last.ref - AND last.tool = '".TOOL_DOCUMENT."' - AND ".$to_field." = ".$to_value." - AND last.visibility".$visibility_bit . $condition_session." AND - docs.c_id = {$_course['real_id']} AND - last.c_id = {$_course['real_id']} "; - } else { - $sql = "SELECT docs.id, docs.filetype, docs.path, docs.title, docs.comment, docs.size, docs.readonly, docs.session_id, last.id_session item_property_session_id, last.lastedit_date, last.visibility, last.insert_user_id - FROM ".$TABLE_ITEMPROPERTY." AS last, ".$TABLE_DOCUMENT." AS docs - WHERE docs.id = last.ref - AND docs.path LIKE '".$path.$added_slash."%' - AND docs.path NOT LIKE '".$path.$added_slash."%/%' - AND last.tool = '".TOOL_DOCUMENT."' - AND ".$to_field." = ".$to_value." - AND last.visibility".$visibility_bit.$condition_session." AND - docs.c_id = {$_course['real_id']} AND - last.c_id = {$_course['real_id']} "; - } - + + $sql = "SELECT docs.id, + docs.filetype, + docs.path, + docs.title, + docs.comment, + docs.size, + docs.readonly, + docs.session_id, + last.id_session item_property_session_id, + last.lastedit_date, + last.visibility, + last.insert_user_id + FROM ".$TABLE_ITEMPROPERTY." AS last INNER JOIN ".$TABLE_DOCUMENT." AS docs + ON (docs.id = last.ref AND docs.c_id = {$_course['real_id']} AND last.c_id = {$_course['real_id']}) + WHERE + docs.path LIKE '".$path.$added_slash."%' AND + docs.path NOT LIKE '".$path.$added_slash."%/%' AND + last.tool = '".TOOL_DOCUMENT."' AND + ".$to_field." = ".$to_value." AND + last.visibility".$visibility_bit.$condition_session; + $result = Database::query($sql); $doc_list = array(); @@ -522,7 +520,6 @@ class DocumentManager { if ($result !== false && Database::num_rows($result) != 0) { while ($row = Database::fetch_array($result, 'ASSOC')) { - if (api_is_coach()) { //Looking for course items that are invisible to hide it in the session if (in_array($row['id'], array_keys($doc_list))) { @@ -533,7 +530,6 @@ class DocumentManager { } } } - $doc_list[$row['id']] = $row; } @@ -546,9 +542,9 @@ class DocumentManager { //Templates management $table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES); $sql_is_template = "SELECT id FROM $table_template - WHERE course_code='".$_course['id']."' - AND user_id='".api_get_user_id()."' - AND ref_doc='".$row['id']."'"; + WHERE course_code = '".$_course['code']."' + AND user_id = '".api_get_user_id()."' + AND ref_doc = '".$row['id']."'"; $template_result = Database::query($sql_is_template); $row['is_template'] = (Database::num_rows($template_result) > 0) ? 1 : 0; } @@ -556,8 +552,6 @@ class DocumentManager { $document_data[$row['id']] = $row; } - - //Only for the student we filter the results see BT#1652 if (!api_is_coach() && !$is_allowed_to_edit) { $ids_to_remove = array(); @@ -610,7 +604,7 @@ class DocumentManager { //Checking parents visibility $final_document_data = array(); - foreach($document_data as $row) { + foreach ($document_data as $row) { $is_visible = DocumentManager::check_visibility_tree($row['id'], $_course['code'], $current_session_id, api_get_user_id()); if ($is_visible) { $final_document_data[$row['id']]=$row; diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index 5e46ff12e4..c0d6e5ca87 100644 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -839,15 +839,14 @@ function filter_extension(&$filename) { * @param string $title * @return id if inserted document */ -function add_document($_course, $path, $filetype, $filesize, $title, $comment = null, $readonly = 0, $save_visibility = true) { +function add_document($_course, $path, $filetype, $filesize, $title, $comment = null, $readonly = 0, $save_visibility = true, $group_id = null) { $session_id = api_get_session_id(); $readonly = intval($readonly); $comment = Database::escape_string($comment); $path = Database::escape_string($path); $filetype = Database::escape_string($filetype); - $filesize = intval($filesize); - $title = htmlspecialchars($title); - $title = Database::escape_string($title); + $filesize = intval($filesize); + $title = Database::escape_string(htmlspecialchars($title)); $c_id = $_course['real_id']; $table_document = Database::get_course_table(TABLE_DOCUMENT); @@ -858,7 +857,7 @@ function add_document($_course, $path, $filetype, $filesize, $title, $comment = $document_id = Database::insert_id(); if ($document_id) { if ($save_visibility) { - api_set_default_visibility($document_id, TOOL_DOCUMENT); + api_set_default_visibility($document_id, TOOL_DOCUMENT, $group_id); } } return $document_id; @@ -1089,7 +1088,7 @@ function create_unexisting_directory($_course, $user_id, $session_id, $to_group_ $rs = Database::query($sql); if (Database::num_rows($rs) == 0) { - $document_id = add_document($_course, $desired_dir_name.$nb, 'folder', 0, $title); + $document_id = add_document($_course, $desired_dir_name.$nb, 'folder', 0, $title, null, 0, true, $to_group_id); if ($document_id) { // Update document item_property if ($visibility !== '') { diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 86b968ab91..104921115d 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -195,6 +195,7 @@ class GroupManager { } return $groups; } + /** * Create a group * @param string $name The name for this group @@ -202,19 +203,21 @@ class GroupManager { * @param int $places How many people can subscribe to the new group */ public static function create_group ($name, $category_id, $tutor, $places) { - global $_course,$_user; - isset($_SESSION['id_session'])?$my_id_session = intval($_SESSION['id_session']):$my_id_session=0; + global $_course; + $table_group = Database :: get_course_table(TABLE_GROUP); + + $session_id = api_get_session_id(); + $course_id = api_get_course_int_id(); + $currentCourseRepository = $_course['path']; - $table_group = Database :: get_course_table(TABLE_GROUP); - $table_forum = Database :: get_course_table(TABLE_FORUM); - $category = self :: get_category($category_id); - $course_id = api_get_course_int_id(); + $category = self :: get_category($category_id); if (intval($places) == 0) { //if the amount of users per group is not filled in, use the setting from the category $places = $category['max_student']; } + $sql = "INSERT INTO ".$table_group." SET c_id = $course_id , category_id='".Database::escape_string($category_id)."', @@ -228,55 +231,62 @@ class GroupManager { chat_state = '".$category['chat_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', - session_id='".Database::escape_string($my_id_session)."'"; + session_id='".Database::escape_string($session_id)."'"; Database::query($sql); $lastId = Database::insert_id(); + + if ($lastId) { + $desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs'; + $my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document'; + $unique_name = create_unexisting_directory($_course, api_get_user_id(), $session_id, $lastId, NULL, $my_path, $desired_dir_name); + + /* Stores the directory path into the group table */ + $sql = "UPDATE ".$table_group." SET name = '".Database::escape_string($name)."', secret_directory = '".$unique_name."' + WHERE c_id = $course_id AND id ='".$lastId."'"; - $desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs'; - - $my_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository.'/document'; - $unique_name = create_unexisting_directory($_course,$_user['user_id'], api_get_session_id(), $lastId,NULL,$my_path, $desired_dir_name); - /* Stores the directory path into the group table */ - $sql = "UPDATE ".$table_group." SET name = '".Database::escape_string($name)."', secret_directory = '".$unique_name."' - WHERE c_id = $course_id AND id ='".$lastId."'"; - - Database::query($sql); + Database::query($sql); - // create a forum if needed - if ($category['forum_state'] >= 0) { - require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php'; - require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; + // create a forum if needed + if ($category['forum_state'] >= 0) { + require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php'; + require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; - $forum_categories = get_forum_categories(); - $values['forum_title'] = $name; - $counter = 0; - foreach ($forum_categories as $key=>$value) { - if ($counter==0) { - $forum_category_id = $key; - } - $counter++; - } - // A sanity check. - if (empty($forum_category_id)) { - $forum_category_id = 0; - } - $values['forum_category'] = $forum_category_id; - $values['allow_anonymous_group']['allow_anonymous'] = 0; - $values['students_can_edit_group']['students_can_edit'] = 0; - $values['approval_direct_group']['approval_direct'] = 0; - $values['allow_attachments_group']['allow_attachments'] = 1; - $values['allow_new_threads_group']['allow_new_threads'] = 1; - $values['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view'); - $values['group_forum'] = $lastId; - if ($category['forum_state'] == '1') { - $values['public_private_group_forum_group']['public_private_group_forum']='public'; - } elseif ($category['forum_state'] == '2') { - $values['public_private_group_forum_group']['public_private_group_forum']='private'; - } elseif ($category['forum_state'] == '0') { - $values['public_private_group_forum_group']['public_private_group_forum']='unavailable'; - } - store_forum($values); - } + $forum_categories = get_forum_categories(); + + $values = array(); + $values['forum_title'] = $name; + $values['group_id'] = $lastId; + + $counter = 0; + foreach ($forum_categories as $key=>$value) { + if ($counter==0) { + $forum_category_id = $key; + } + $counter++; + } + // A sanity check. + if (empty($forum_category_id)) { + $forum_category_id = 0; + } + $values['forum_category'] = $forum_category_id; + $values['allow_anonymous_group']['allow_anonymous'] = 0; + $values['students_can_edit_group']['students_can_edit'] = 0; + $values['approval_direct_group']['approval_direct'] = 0; + $values['allow_attachments_group']['allow_attachments'] = 1; + $values['allow_new_threads_group']['allow_new_threads'] = 1; + $values['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view'); + $values['group_forum'] = $lastId; + if ($category['forum_state'] == '1') { + $values['public_private_group_forum_group']['public_private_group_forum']='public'; + } elseif ($category['forum_state'] == '2') { + $values['public_private_group_forum_group']['public_private_group_forum']='private'; + } elseif ($category['forum_state'] == '0') { + $values['public_private_group_forum_group']['public_private_group_forum']='unavailable'; + } + store_forum($values); + } + } + return $lastId; } /** diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 85f884e548..df50f84dc9 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -6037,7 +6037,7 @@ function api_is_global_chat_enabled(){ /** * @todo Fix tool_visible_by_default_at_creation labels */ -function api_set_default_visibility($item_id, $tool_id) { +function api_set_default_visibility($item_id, $tool_id, $group_id = null) { $original_tool_id = $tool_id; switch ($tool_id) { @@ -6071,7 +6071,10 @@ function api_set_default_visibility($item_id, $tool_id) { $visibility = 'invisible'; if ($setting[$tool_id] == 'true') { $visibility = 'visible'; - } - api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), api_get_group_id(), null, null, null, api_get_session_id()); + } + if (empty($group_id)) { + $group_id = api_get_group_id(); + } + api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), $group_id, null, null, null, api_get_session_id()); } } \ No newline at end of file From 2b8d62ea7d90d9031f538342806a5516e023d738 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 17:00:56 +0200 Subject: [PATCH 047/124] Fixing query c_id see #5591 Reported by Jose Manuel Abuin Mosquera --- main/survey/survey_invitation.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main/survey/survey_invitation.php b/main/survey/survey_invitation.php index 5d572f4092..b6779d4327 100644 --- a/main/survey/survey_invitation.php +++ b/main/survey/survey_invitation.php @@ -49,6 +49,7 @@ if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])) { $survey_id = Security::remove_XSS($_GET['survey_id']); $survey_data = survey_manager::get_survey($survey_id); + if (empty($survey_data)) { Display :: display_header($tool_name); Display :: display_error_message(get_lang('InvallidSurvey'), false); @@ -107,9 +108,13 @@ echo ' '.get_lang('InvitationDate').''; echo ' '.get_lang('Answered').''; echo ' '; -$sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email FROM $table_survey_invitation survey_invitation - LEFT JOIN $table_user user ON survey_invitation.user = user.user_id - WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."'"; +$course_id = api_get_course_int_id(); + +$sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email + FROM $table_survey_invitation survey_invitation + LEFT JOIN $table_user user ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = $course_id) + WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."' "; + $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { if (!$_GET['view'] || $_GET['view'] == 'invited' || ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))) { From 163c94e71f084edb2a30c74746c3025011fbfb6e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 17:03:04 +0200 Subject: [PATCH 048/124] Sending survey via the chamilo messaging tool + a fix in the URL survey code --- main/survey/survey.lib.php | 55 ++++++++++++++++++----------------- main/survey/survey_invite.php | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index aa608db448..b4fbafb433 100644 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -68,6 +68,7 @@ class survey_manager { } $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); $sql = "SELECT * FROM $table_survey WHERE survey_id='".Database::escape_string($survey_id)."' "; @@ -93,17 +94,13 @@ class survey_manager { $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'] = $return['input_name_list']; - $return['shuffle'] = $return['shuffle']; $return['parent_id'] = $return['parent_id']; $return['survey_version'] = $return['survey_version']; - return $return; - } else { - return $return; - } + } + return $return; } /** @@ -3792,9 +3789,7 @@ class SurveyUtil { // Database table to store the invitations data $table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); - $survey_invitations = array(); - $survey_invitations = SurveyUtil::get_invitations($survey_data['survey_code']); - $already_invited = array(); + $survey_invitations = SurveyUtil::get_invitations($survey_data['survey_code']); $already_invited = SurveyUtil::get_invited_users($survey_data['code']); // Remind unanswered is a special version of remind all reminder @@ -3854,7 +3849,7 @@ class SurveyUtil { static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text) { global $_user, $_course, $_configuration; - $portal_url = api_get_path(WEB_PATH); + $portal_url = api_get_path(WEB_CODE_PATH); if ($_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { @@ -3862,8 +3857,9 @@ class SurveyUtil { $portal_url = $url['url']; } } + // Replacing the **link** part with a valid link for the user - $survey_link = $portal_url.'main/survey/fillsurvey.php?course='.$_course['sysCode'].'&invitationcode='.$invitation_code; + $survey_link = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['code'].'&invitationcode='.$invitation_code; $text_link = ''.get_lang('ClickHereToAnswerTheSurvey')."
\r\n
\r\n".get_lang('OrCopyPasteTheFollowingUrl')."
\r\n ".$survey_link; $replace_count = 0; @@ -3871,6 +3867,22 @@ class SurveyUtil { if ($replace_count < 1) { $full_invitation_text = $full_invitation_text."
\r\n
\r\n".$text_link; } + + // Sending the mail + $sender_name = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); + $sender_email = $_user['mail']; + $sender_user_id = api_get_user_id(); + + $replyto = array(); + if (api_get_setting('survey_email_sender_noreply') == 'noreply') { + $noreply = api_get_setting('noreply_email_address'); + if (!empty($noreply)) { + $replyto['Reply-to'] = $noreply; + $sender_name = $noreply; + $sender_email = $noreply; + $sender_user_id = null; + } + } // Optionally: finding the e-mail of the course user if (is_numeric($invitedUser)) { @@ -3880,25 +3892,14 @@ class SurveyUtil { $row = Database::fetch_array($result); $recipient_email = $row['email']; $recipient_name = api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); + + MessageManager::send_message($invitedUser, $invitation_title, $full_invitation_text, null, null, null, null, null, null, $sender_user_id); + } else { /** @todo check if the address is a valid email */ - $recipient_email = $invitedUser; + $recipient_email = $invitedUser; + @api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto); } - - // Sending the mail - $sender_name = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); - $sender_email = $_user['mail']; - - $replyto = array(); - if (api_get_setting('survey_email_sender_noreply') == 'noreply') { - $noreply = api_get_setting('noreply_email_address'); - if (!empty($noreply)) { - $replyto['Reply-to'] = $noreply; - $sender_name = $noreply; - $sender_email = $noreply; - } - } - @api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto); } /** diff --git a/main/survey/survey_invite.php b/main/survey/survey_invite.php index a8e0e20f2e..f02bb1f5a6 100644 --- a/main/survey/survey_invite.php +++ b/main/survey/survey_invite.php @@ -155,7 +155,7 @@ if ($form->validate()) { SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail'])); // Saving the invitations for the course users $count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], - $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']); + $values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']); // Saving the invitations for the additional users $values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email $temp = str_replace(',', ';', $values['additional_users']); // This is to allow , and ; as email separators From f134536d831aeab7890a840fc4105c5fbe5bfbe3 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 18:10:49 +0200 Subject: [PATCH 049/124] Adding setting for gradebook score results page see BT#4895 (now it works as usual) --- main/gradebook/lib/fe/flatviewtable.class.php | 2 +- .../lib/flatview_data_generator.class.php | 47 ++++++++++++------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index 5a83e9f592..63407b5eef 100644 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -403,7 +403,7 @@ class FlatViewTable extends SortableTable /** * Function used by SortableTable to get total number of items in the table */ - function get_total_number_of_items () { + function get_total_number_of_items() { return $this->datagen->get_total_users_count(); } diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index fff60fba4a..4d1f8fefc4 100644 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -322,15 +322,21 @@ class FlatViewDataGenerator $item_value = $percentage*$item_value; $item_total += $sub_cat->get_weight(); - if ($convert_using_the_global_weight) { - //$score[0] = $main_weight*$score[0]/$sub_cat->get_weight(); + if ($convert_using_the_global_weight) { $score[0] = $score[0]/$main_weight*$sub_cat->get_weight(); $score[1] = $main_weight ; - } - - $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); - $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); - $temp_score = Display::tip($temp_score, $real_score); + } + + if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { + //if (true) { + $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); + $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); + $temp_score = Display::tip($real_score, $temp_score); + } else { + $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); + $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); + $temp_score = Display::tip($temp_score, $real_score); + } if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) { if (!$show_all) { @@ -348,6 +354,7 @@ class FlatViewDataGenerator for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) { $item = $this->evals_links[$count + $items_start]; $score = $item->calc_score($user_id); + $real_score = $score; $divide = ( ($score[1])==0 ) ? 1 : $score[1]; //sub cat weight @@ -359,20 +366,24 @@ class FlatViewDataGenerator if ($this->category->get_parent_id() == 0 ) { $item_value = $score[0]/$divide*$item->get_weight(); } else { - $item_value = $item_value*$item->get_weight(); - //var_dump($item_value.' - '.$item->get_weight()); - //$item_value = $main_weight*$item_value/$item->get_weight(); - //$item_value = $item_value*100/$item->get_weight(); + $item_value = $item_value*$item->get_weight(); } - $item_total += $item->get_weight(); - $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); - //$temp_score = $item_value.' - '.$scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); - //$temp_score = $item_value; - $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); - - $temp_score = Display::tip($temp_score, $complete_score); + $item_total += $item->get_weight(); + /* + $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); + $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); + $temp_score = Display::tip($temp_score, $complete_score);*/ + //if (true) { + if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { + $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); + $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); + $temp_score = Display::tip($real_score, $temp_score); + } else { + $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); + $temp_score = Display::tip($temp_score, $complete_score); + } if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) { if (!$show_all) { From f24a527dd8058f04d39d2d0a94af25a1ea6e488c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 18:37:54 +0200 Subject: [PATCH 050/124] Fixing export to PDF label --- main/course_progress/thematic_controller.php | 694 +++++++++---------- 1 file changed, 347 insertions(+), 347 deletions(-) diff --git a/main/course_progress/thematic_controller.php b/main/course_progress/thematic_controller.php index dfdd9b5b15..375881bd03 100644 --- a/main/course_progress/thematic_controller.php +++ b/main/course_progress/thematic_controller.php @@ -1,4 +1,5 @@ toolname = 'course_progress'; + $this->view = new View($this->toolname); + } + + /** + * This method is used for thematic control (update, insert or listing) + * @param string Action + * render to thematic.php + */ + public function thematic($action) { + $thematic = new Thematic(); + $data = array(); + $error = false; + $msg_add = false; + + $check = Security::check_token('request'); + $thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null; + + if ($check) { + switch ($action) { + case 'thematic_add': + case 'thematic_edit': + // insert or update a thematic + if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { + if (trim($_POST['title']) !== '') { + if (api_is_allowed_to_edit(null, true)) { -class ThematicController -{ - - /** - * Constructor - */ - public function __construct() { - $this->toolname = 'course_progress'; - $this->view = new View($this->toolname); - } - - /** - * This method is used for thematic control (update, insert or listing) - * @param string Action - * render to thematic.php - */ - public function thematic($action) { - $thematic = new Thematic(); - $data = array(); - $error = false; - $msg_add = false; - - $check = Security::check_token('request'); - $thematic_id = isset($_REQUEST['thematic_id'])?intval($_REQUEST['thematic_id']):null; - - if ($check) { - switch ($action) { - case 'thematic_add': - case 'thematic_edit': - // insert or update a thematic - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { - if (trim($_POST['title']) !== '') { - if (api_is_allowed_to_edit(null, true)) { - - $id = $_POST['thematic_id']; - $title = $_POST['title']; - $content = $_POST['content']; - $session_id = api_get_session_id(); - $thematic->set_thematic_attributes($id, $title, $content, $session_id); - $last_id = $thematic->thematic_save(); - if ($_POST['action'] == 'thematic_add') { - $action = 'thematic_details'; - $thematic_id = null; - if ($last_id) { - $data['last_id'] = $last_id; - } - } else { - $action = 'thematic_details'; - $thematic_id = null; - } - } - } else { - $error = true; - $data['error'] = $error; - $data['action'] = $_POST['action']; - $data['thematic_id'] = $_POST['thematic_id']; - // render to the view - $this->view->set_data($data); - $this->view->set_layout('layout'); - $this->view->set_template('thematic'); - $this->view->render(); - } - } - break; - case 'thematic_copy': + $id = $_POST['thematic_id']; + $title = $_POST['title']; + $content = $_POST['content']; + $session_id = api_get_session_id(); + $thematic->set_thematic_attributes($id, $title, $content, $session_id); + $last_id = $thematic->thematic_save(); + if ($_POST['action'] == 'thematic_add') { + $action = 'thematic_details'; + $thematic_id = null; + if ($last_id) { + $data['last_id'] = $last_id; + } + } else { + $action = 'thematic_details'; + $thematic_id = null; + } + } + } else { + $error = true; + $data['error'] = $error; + $data['action'] = $_POST['action']; + $data['thematic_id'] = $_POST['thematic_id']; + // render to the view + $this->view->set_data($data); + $this->view->set_layout('layout'); + $this->view->set_template('thematic'); + $this->view->render(); + } + } + break; + case 'thematic_copy': //Copy a thematic to a session - $thematic->copy($thematic_id); - $thematic_id = null; - $action = 'thematic_details'; - break; - case 'thematic_delete_select': - //Delete many thematics - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { - if (api_is_allowed_to_edit(null, true)) { - $thematic_ids = $_POST['id']; - $affected_rows = $thematic->thematic_destroy($thematic_ids); - } - $action = 'thematic_details'; - } - break; + $thematic->copy($thematic_id); + $thematic_id = null; + $action = 'thematic_details'; + break; + case 'thematic_delete_select': + //Delete many thematics + if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { + if (api_is_allowed_to_edit(null, true)) { + $thematic_ids = $_POST['id']; + $affected_rows = $thematic->thematic_destroy($thematic_ids); + } + $action = 'thematic_details'; + } + break; case 'thematic_delete': // Delete a thematic - if (isset($thematic_id)) { + if (isset($thematic_id)) { if (api_is_allowed_to_edit(null, true)) { - $affected_rows = $thematic->thematic_destroy($thematic_id); + $affected_rows = $thematic->thematic_destroy($thematic_id); } $thematic_id = null; - $action = 'thematic_details'; + $action = 'thematic_details'; } break; case 'thematic_import_select': break; case 'thematic_import': $csv_import_array = Import::csv_to_array($_FILES['file']['tmp_name'], 'horizontal'); - + if (isset($_POST['replace']) && $_POST['replace']) { // Remove current thematic. $list = $thematic->get_thematic_list(); foreach ($list as $i) { $thematic->thematic_destroy($i); - } + } } - + // Import the progress. $current_thematic = null; - + foreach ($csv_import_array as $data) { - foreach ($data as $key => $item) { + foreach ($data as $key => $item) { if ($key == 'title') { - $thematic->set_thematic_attributes(null, $item[0], $item[1], api_get_session_id ()); - $current_thematic = $thematic->thematic_save (); + $thematic->set_thematic_attributes(null, $item[0], $item[1], api_get_session_id()); + $current_thematic = $thematic->thematic_save(); $description_type = 0; } if ($key == 'plan') { @@ -136,9 +135,9 @@ class ThematicController $description_type++; } if ($key == 'progress') { - $thematic->set_thematic_advance_attributes (null, $current_thematic, 0, $item[2], $item[0], $item[1]); - $thematic->thematic_advance_save (); - } + $thematic->set_thematic_advance_attributes(null, $current_thematic, 0, $item[2], $item[0], $item[1]); + $thematic->thematic_advance_save(); + } } } $action = 'thematic_details'; @@ -147,14 +146,14 @@ class ThematicController $list = $thematic->get_thematic_list(); $csv = array(); foreach ($list as $theme) { - $csv[] = array ('title', $theme['title'], $theme['content']); - $data = $thematic->get_thematic_plan_data ($theme['id']); + $csv[] = array('title', $theme['title'], $theme['content']); + $data = $thematic->get_thematic_plan_data($theme['id']); if (!empty($data)) { foreach ($data as $plan) { - $csv[] = array ('plan', $plan['title'], $plan['description']); + $csv[] = array('plan', $plan['title'], $plan['description']); } } - $data = $thematic->get_thematic_advance_by_thematic_id ($theme['id']); + $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); if (!empty($data)) { foreach ($data as $advance) { $csv[] = array('progress', $advance['start_date'], $advance['duration'], $advance['content']); @@ -166,306 +165,307 @@ class ThematicController // Don't continue building a normal page. return; case 'thematic_export_pdf': - $list = $thematic->get_thematic_list(); + $list = $thematic->get_thematic_list(); $table = array(); - $table[] = array (get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance')); - foreach ($list as $theme) { + $table[] = array(get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance')); + foreach ($list as $theme) { $data = $thematic->get_thematic_plan_data($theme['id']); $plan_html = null; if (!empty($data)) { foreach ($data as $plan) { - $plan_html .= ''.$plan['title']. '
'.$plan['description'].'
'; + $plan_html .= '' . $plan['title'] . '
' . $plan['description'] . '
'; } } - $data = $thematic->get_thematic_advance_by_thematic_id ($theme['id']); + $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); $advance_html = null; if (!empty($data)) { - foreach ($data as $advance) { - $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_TIME_FORMAT_LONG).' '.$advance['duration'].'
'.$advance['content'].'
'; + foreach ($data as $advance) { + //DATE_TIME_FORMAT_LONG + $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_ONLY_DAYNAME) . ' ('.$advance['duration'].' '.get_lang('HourShort').')
'.$advance['content'].'
'; } - } + } $table[] = array($theme['title'], $plan_html, $advance_html); - } + } $params = array( - 'filename' => get_lang('Thematic').'-'.api_get_local_time(), + 'filename' => get_lang('Thematic') . '-' . api_get_local_time(), 'pdf_title' => get_lang('Thematic'), 'add_signatures' => true, 'format' => 'A4-L', - 'orientation' => 'L' - ); - + 'orientation' => 'L' + ); Export::export_table_pdf($table, $params); break; case 'moveup': $thematic->move_thematic('up', $thematic_id); - $action = 'thematic_details'; - $thematic_id = null; + $action = 'thematic_details'; + $thematic_id = null; break; case 'movedown': $thematic->move_thematic('down', $thematic_id); - $action = 'thematic_details'; - $thematic_id = null; - break; - } - Security::clear_token(); - } else { - $action = 'thematic_details'; - $thematic_id = null; - } - if (isset($thematic_id)) { - $data['thematic_data'] = $thematic->get_thematic_list($thematic_id); - $data['thematic_id'] = $thematic_id; - } - - if ($action == 'thematic_details') { - if (isset($thematic_id)) { - $thematic_data_result = $thematic->get_thematic_list($thematic_id); - if (!empty($thematic_data_result)) { - $thematic_data[$thematic_id] = $thematic_data_result; - } - $data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id); - } else { - $thematic_data = $thematic->get_thematic_list(null, api_get_course_id(), api_get_session_id()); - $data['max_thematic_item'] = $thematic->get_max_thematic_item(); - $data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance(); - $data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances(); - } - + $action = 'thematic_details'; + $thematic_id = null; + break; + } + Security::clear_token(); + } else { + $action = 'thematic_details'; + $thematic_id = null; + } + if (isset($thematic_id)) { + $data['thematic_data'] = $thematic->get_thematic_list($thematic_id); + $data['thematic_id'] = $thematic_id; + } + + if ($action == 'thematic_details') { + if (isset($thematic_id)) { + $thematic_data_result = $thematic->get_thematic_list($thematic_id); + if (!empty($thematic_data_result)) { + $thematic_data[$thematic_id] = $thematic_data_result; + } + $data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id); + } else { + $thematic_data = $thematic->get_thematic_list(null, api_get_course_id(), api_get_session_id()); + $data['max_thematic_item'] = $thematic->get_max_thematic_item(); + $data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance(); + $data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances(); + } + //Second column - $thematic_plan_data = $thematic->get_thematic_plan_data(); - + $thematic_plan_data = $thematic->get_thematic_plan_data(); + //Third column - $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true); - - $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data); - - $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data); - - - $data['thematic_plan_data'] = $thematic_plan_data; - $data['thematic_advance_data'] = $thematic_advance_data; - $data['thematic_data'] = $thematic_data; - } - - $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); - - $data['action'] = $action; - // render to the view - $this->view->set_data($data); - $this->view->set_layout('layout'); - $this->view->set_template('thematic'); - $this->view->render(); - } - - /** - * This method is used for thematic plan control (update, insert or listing) - * @param string Action - * render to thematic_plan.php - */ - public function thematic_plan($action) { - $thematic= new Thematic(); - - $data = array(); - $error = false; - - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { - if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) { + $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true); + + $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data); + + $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data); + + + $data['thematic_plan_data'] = $thematic_plan_data; + $data['thematic_advance_data'] = $thematic_advance_data; + $data['thematic_data'] = $thematic_data; + } + + $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); + + $data['action'] = $action; + // render to the view + $this->view->set_data($data); + $this->view->set_layout('layout'); + $this->view->set_template('thematic'); + $this->view->render(); + } + + /** + * This method is used for thematic plan control (update, insert or listing) + * @param string Action + * render to thematic_plan.php + */ + public function thematic_plan($action) { + $thematic = new Thematic(); + + $data = array(); + $error = false; + + if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { + if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) { if (isset($_POST['title'])) { if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) { - if (api_is_allowed_to_edit(null, true)) { - - $title_list = $_REQUEST['title']; + if (api_is_allowed_to_edit(null, true)) { + + $title_list = $_REQUEST['title']; //$description_list = $_REQUEST['desc']; - $description_list = $_REQUEST['description']; - $description_type = $_REQUEST['description_type']; - for($i=1;$iset_thematic_plan_attributes($_REQUEST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]); $affected_rows = $thematic->thematic_plan_save(); - } - unset($_SESSION['thematic_plan_token']); + } + unset($_SESSION['thematic_plan_token']); $data['message'] = 'ok'; } $data['action'] = 'thematic_plan_list'; - } - } else { - $error = true; - $action = $_POST['action']; - $data['error'] = $error; - $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']); - $data['thematic_id'] = $_POST['thematic_id']; - $data['description_type'] = $_POST['description_type']; - $data['action'] = $action; - $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); - $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon(); - $data['default_thematic_plan_question'] = $thematic->get_default_question(); - $data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']); - - // render to the view - $this->view->set_data($data); - $this->view->set_layout('layout'); - $this->view->set_template('thematic_plan'); - $this->view->render(); - } + } + } else { + $error = true; + $action = $_POST['action']; + $data['error'] = $error; + $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']); + $data['thematic_id'] = $_POST['thematic_id']; + $data['description_type'] = $_POST['description_type']; + $data['action'] = $action; + $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); + $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon(); + $data['default_thematic_plan_question'] = $thematic->get_default_question(); + $data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']); + + // render to the view + $this->view->set_data($data); + $this->view->set_layout('layout'); + $this->view->set_template('thematic_plan'); + $this->view->render(); + } } - } - - - if ($action == 'thematic_plan_list') { - $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); - } - $thematic_id = intval($_GET['thematic_id']); - $description_type = intval($_GET['description_type']); - - if (!empty($thematic_id) && !empty($description_type)) { - if ($action == 'thematic_plan_delete') { + } + + + if ($action == 'thematic_plan_list') { + $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); + } + $thematic_id = intval($_GET['thematic_id']); + $description_type = intval($_GET['description_type']); + + if (!empty($thematic_id) && !empty($description_type)) { + if ($action == 'thematic_plan_delete') { if (api_is_allowed_to_edit(null, true)) { $affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type); - } - $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); - $action = 'thematic_plan_list'; - } else { - $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type); - } - $data['thematic_id'] = $thematic_id; - $data['description_type'] = $description_type; - } else if (!empty($thematic_id) && $action == 'thematic_plan_list') { - $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); - $data['thematic_id'] = $thematic_id; - } - - $data['thematic_id'] = $thematic_id; - $data['action'] = $action; - $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); - $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon(); - $data['next_description_type'] = $thematic->get_next_description_type($thematic_id); - $data['default_thematic_plan_question'] = $thematic->get_default_question(); - $data['thematic_data'] = $thematic->get_thematic_list($thematic_id); - - //render to the view - $this->view->set_data($data); - $this->view->set_layout('layout'); - $this->view->set_template('thematic_plan'); - $this->view->render(); + } + $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); + $action = 'thematic_plan_list'; + } else { + $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type); + } + $data['thematic_id'] = $thematic_id; + $data['description_type'] = $description_type; + } else if (!empty($thematic_id) && $action == 'thematic_plan_list') { + $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); + $data['thematic_id'] = $thematic_id; + } + + $data['thematic_id'] = $thematic_id; + $data['action'] = $action; + $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); + $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon(); + $data['next_description_type'] = $thematic->get_next_description_type($thematic_id); + $data['default_thematic_plan_question'] = $thematic->get_default_question(); + $data['thematic_data'] = $thematic->get_thematic_list($thematic_id); + + //render to the view + $this->view->set_data($data); + $this->view->set_layout('layout'); + $this->view->set_template('thematic_plan'); + $this->view->render(); exit; } - + /** * This method is used for thematic advance control (update, insert or listing) * @param string Action * render to thematic_advance.php - */ + */ public function thematic_advance($action) { - - $thematic= new Thematic(); - $attendance = new Attendance(); - $data = array(); - - // get data for attendance input select - $attendance_list = $attendance->get_attendances_list(); - $attendance_select = array(); - $attendance_select[0] = get_lang('SelectAnAttendance'); - foreach ($attendance_list as $attendance_id => $attendance_data) { - $attendance_select[$attendance_id] = $attendance_data['name']; - } - - $thematic_id = intval($_REQUEST['thematic_id']); - $thematic_advance_id = intval($_REQUEST['thematic_advance_id']); - - $thematic_advance_data = array(); - - switch ($action) { - case 'thematic_advance_delete': - if (!empty($thematic_advance_id)) { - if (api_is_allowed_to_edit(null, true)) { - $affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id); - } - $action = 'thematic_list'; - header('Location: index.php'); - exit; + + $thematic = new Thematic(); + $attendance = new Attendance(); + $data = array(); + + // get data for attendance input select + $attendance_list = $attendance->get_attendances_list(); + $attendance_select = array(); + $attendance_select[0] = get_lang('SelectAnAttendance'); + foreach ($attendance_list as $attendance_id => $attendance_data) { + $attendance_select[$attendance_id] = $attendance_data['name']; + } + + $thematic_id = intval($_REQUEST['thematic_id']); + $thematic_advance_id = intval($_REQUEST['thematic_advance_id']); + + $thematic_advance_data = array(); + + switch ($action) { + case 'thematic_advance_delete': + if (!empty($thematic_advance_id)) { + if (api_is_allowed_to_edit(null, true)) { + $affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id); } - break; - case 'thematic_advance_list': - if (!api_is_allowed_to_edit(null, true)) { - echo ''; - exit; + $action = 'thematic_list'; + header('Location: index.php'); + exit; + } + break; + case 'thematic_advance_list': + if (!api_is_allowed_to_edit(null, true)) { + echo ''; + exit; + } + + if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) || (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours']))) { + if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) { + $start_date_error = true; + $data['start_date_error'] = $start_date_error; } - if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) || (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) ) { - if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) { - $start_date_error = true; - $data['start_date_error'] = $start_date_error; - } + if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) { + $duration_error = true; + $data['duration_error'] = $duration_error; + } - if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) { - $duration_error = true; - $data['duration_error'] = $duration_error; - } + $data['action'] = $_REQUEST['action']; + $data['thematic_id'] = $_REQUEST['thematic_id']; + $data['attendance_select'] = $attendance_select; + if (isset($_REQUEST['thematic_advance_id'])) { + $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id']; + $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']); + $data['thematic_advance_data'] = $thematic_advance_data; + } + } else { + if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) { - $data['action'] = $_REQUEST['action']; - $data['thematic_id'] = $_REQUEST['thematic_id']; - $data['attendance_select'] = $attendance_select; - if (isset($_REQUEST['thematic_advance_id'])) { - $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id']; - $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']); - $data['thematic_advance_data'] = $thematic_advance_data; - } - } else { - if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) { - - $thematic_advance_id = $_REQUEST['thematic_advance_id']; - $thematic_id = $_REQUEST['thematic_id']; - $content = $_REQUEST['content']; - $duration = $_REQUEST['duration_in_hours']; - if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) { - $start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']); - $attendance_id = 0; - } else { - $start_date = $_REQUEST['start_date_by_attendance']; - $attendance_id = $_REQUEST['attendance_select']; - } - $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration); - $affected_rows = $thematic->thematic_advance_save(); - if ($affected_rows) { - // get last done thematic advance before move thematic list - $last_done_thematic_advance = $thematic->get_last_done_thematic_advance(); - // update done advances with de current thematic list - if (!empty($last_done_thematic_advance)) { - $update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance); - } + $thematic_advance_id = $_REQUEST['thematic_advance_id']; + $thematic_id = $_REQUEST['thematic_id']; + $content = $_REQUEST['content']; + $duration = $_REQUEST['duration_in_hours']; + if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) { + $start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']); + $attendance_id = 0; + } else { + $start_date = $_REQUEST['start_date_by_attendance']; + $attendance_id = $_REQUEST['attendance_select']; + } + $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration); + $affected_rows = $thematic->thematic_advance_save(); + if ($affected_rows) { + // get last done thematic advance before move thematic list + $last_done_thematic_advance = $thematic->get_last_done_thematic_advance(); + // update done advances with de current thematic list + if (!empty($last_done_thematic_advance)) { + $update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance); } } } - break; - default: - $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id); - break; + } + break; + default: + $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id); + break; + } + + + // get calendar select by attendance id + $calendar_select = array(); + if (!empty($thematic_advance_data)) { + if (!empty($thematic_advance_data['attendance_id'])) { + $attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']); + if (!empty($attendance_calendar)) { + foreach ($attendance_calendar as $calendar) { + $calendar_select[$calendar['date_time']] = $calendar['date_time']; + } + } } - - - // get calendar select by attendance id - $calendar_select = array(); - if (!empty($thematic_advance_data)) { - if (!empty($thematic_advance_data['attendance_id'])) { - $attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']); - if (!empty($attendance_calendar)) { - foreach ($attendance_calendar as $calendar) { - $calendar_select[$calendar['date_time']] = $calendar['date_time']; - } - } - } - } - - $data['action'] = $action; - $data['thematic_id'] = $thematic_id; - $data['thematic_advance_id'] = $thematic_advance_id; - $data['attendance_select'] = $attendance_select; - $data['thematic_advance_data'] = $thematic_advance_data; - $data['calendar_select'] = $calendar_select; - - // render to the view - $this->view->set_data($data); - $this->view->set_layout('layout'); - $this->view->set_template('thematic_advance'); - $this->view->render(); - } + } + + $data['action'] = $action; + $data['thematic_id'] = $thematic_id; + $data['thematic_advance_id'] = $thematic_advance_id; + $data['attendance_select'] = $attendance_select; + $data['thematic_advance_data'] = $thematic_advance_data; + $data['calendar_select'] = $calendar_select; + + // render to the view + $this->view->set_data($data); + $this->view->set_layout('layout'); + $this->view->set_template('thematic_advance'); + $this->view->render(); + } + } \ No newline at end of file From c32554fcf7959b65aca963db594f736cd2cde055 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 3 Oct 2012 19:39:18 +0200 Subject: [PATCH 051/124] Adding new tag ((date_certificate_no_time)) for certificates also adding a new time format see BT#5032 --- main/inc/lib/document.lib.php | 4 ++++ main/inc/lib/internationalization.lib.php | 12 ++++++++++-- main/inc/lib/usermanager.lib.php | 10 +++++----- main/lang/english/trad4all.inc.php | 17 +++++++++-------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 37c3cf3a2c..c313020bad 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -1409,10 +1409,12 @@ class DocumentManager { $date_long_certificate = ''; if (!empty($date_certificate)) { $date_long_certificate = api_convert_and_format_date($date_certificate); + $date_no_time = api_convert_and_format_date($date_certificate, DATE_FORMAT_LONG_NO_DAY); } if ($is_preview) { $date_long_certificate = api_convert_and_format_date(api_get_utc_datetime()); + $date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY); } $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$info_grade_certificate['id']; @@ -1427,6 +1429,7 @@ class DocumentManager { $teacher_last_name, $official_code, $date_long_certificate, + $date_no_time, $course_id, $course_info['name'], $info_grade_certificate['grade'], @@ -1443,6 +1446,7 @@ class DocumentManager { '((teacher_lastname))', '((official_code))', '((date_certificate))', + '((date_certificate_no_time))', '((course_code))', '((course_title))', '((gradebook_grade))', diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 28cf7e6753..67bd412333 100644 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -25,8 +25,9 @@ define('SPECIAL_CLOSING_TAG', '=]'); define('TIME_NO_SEC_FORMAT', 0); // 15:23 define('DATE_FORMAT_SHORT', 1); // Aug 25, 09 -define('DATE_FORMAT_LONG', 2); // Aug 25, 09 -define('DATE_TIME_FORMAT_LONG', 3); // August 25, 2009 at 03:28 PM +define('DATE_FORMAT_LONG', 2); // Monday August 25, 09 +define('DATE_FORMAT_LONG_NO_DAY', 10); // August 25, 2009 +define('DATE_TIME_FORMAT_LONG', 3); // Monday August 25, 2009 at 03:28 PM define('DATE_FORMAT_NUMBER', 4); // 25.08.09 define('DATE_TIME_FORMAT_LONG_24H', 5); // August 25, 2009 at 15:28 @@ -739,6 +740,13 @@ function api_format_date($time, $format = null, $language = null) { $timetype = IntlDateFormatter::SHORT; } break; + case DATE_FORMAT_LONG_NO_DAY: + $date_format = get_lang('dateFormatLongNoDay', '', $language); + if (IS_PHP_53 && INTL_INSTALLED) { + $datetype = IntlDateFormatter::FULL; + $timetype = IntlDateFormatter::SHORT; + } + break; case DATE_TIME_FORMAT_SHORT: $date_format = get_lang('dateTimeFormatShort', '', $language); if (IS_PHP_53 && INTL_INSTALLED) { diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 1e60698646..2e464fe5c3 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -3345,12 +3345,12 @@ class UserManager { $category_id = $row['cat_id']; $cat = Category::load($category_id); $displayscore = ScoreDisplay::instance(); - $grade = ''; + $grade = ''; if (isset($cat) && $displayscore->is_custom()) { - $grade = $displayscore->display_score(array($score, $cat[0]->get_weight()), SCORE_DIV_PERCENT_WITH_CUSTOM); - } else { - $grade = $displayscore->display_score(array($score, $cat[0]->get_weight())); - } + $grade = $displayscore->display_score(array($score, $cat[0]->get_weight()), SCORE_DIV_PERCENT_WITH_CUSTOM); + } else { + $grade = $displayscore->display_score(array($score, $cat[0]->get_weight())); + } $row['grade'] = $grade; return $row; } diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 4a1fcdf0b6..bdb49df006 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -1004,13 +1004,13 @@ $YouMustAcceptLicence = "You must accept the licence"; $SelectOne = "Select one"; $ContactInformationHasBeenSent = "Contact information has been sent"; $UserInactivedSinceX = "User inactive since %s"; -$ContactInformationDescription = "Dear user,
-
You are about to start using one of the best open-source e-learning platform on the market. Like many other open-source project, this project is backed up by a large community of students, teachers, developers and content creators who would like to promote the project better.
-
-By knowing a little bit more about you, one of our most important users, who will manage this e-learning system, we will be able to let people know that our software is used and let you know when we organize events that might be relevant to you.
-
-By filling this form, you accept that the Chamilo association or its members might send you information by e-mail about important events or updates in the Chamilo software or community. This will help the community grow as an organized entity where information flow, with a permanent respect of your time and your privacy.
-
+$ContactInformationDescription = "Dear user,
+
You are about to start using one of the best open-source e-learning platform on the market. Like many other open-source project, this project is backed up by a large community of students, teachers, developers and content creators who would like to promote the project better.
+
+By knowing a little bit more about you, one of our most important users, who will manage this e-learning system, we will be able to let people know that our software is used and let you know when we organize events that might be relevant to you.
+
+By filling this form, you accept that the Chamilo association or its members might send you information by e-mail about important events or updates in the Chamilo software or community. This will help the community grow as an organized entity where information flow, with a permanent respect of your time and your privacy.
+
Please note that you are not required to fill this form. If you want to remain anonymous, we will loose the opportunity to offer you all the privileges of being a registered portal administrator, but we will respect your decision. Simply leave this form empty and click \"Next\".

"; $CompanyActivity = "Your company's activity"; $DateUnLock = "Unlock date"; @@ -1216,7 +1216,7 @@ $SaveForNow = "Save and continue later"; $NoQuicktime = "Your browser does not have the QuickTime plugin installed. You can still use the platform, but to run a larger number of media file types, we suggest you might want to install it."; $NoJavaSun = "Your browser doesn't seem to have the Sun Java plugin installed. You can still use the platform, but you will lose a few of its capabilities."; $NoJava = "Your browser does not support Java"; -$JavaSun24 = "Your browser has a Java version not supported by this tool. +$JavaSun24 = "Your browser has a Java version not supported by this tool. To use it you have to install a Java Sun version higher than 24"; $NoMessageAnywere = "If you do not want to see this message again during this session, click here"; $Attempts = "Attempts"; @@ -1380,4 +1380,5 @@ $DataTableSearch = "Search"; $HideColumn = "Hide column"; $DisplayColumn = "Show column"; $LegalAgreementAccepted = "Legal agreement accepted"; +$dateFormatLongNoDay = "%d %B %Y"; ?> \ No newline at end of file From cc134088fd1a544a922a1132817fea465a65d554 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 3 Oct 2012 16:25:24 -0500 Subject: [PATCH 052/124] Added system logs to platform language changes --- main/admin/sub_language.class.php | 1 + main/inc/lib/main_api.lib.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main/admin/sub_language.class.php b/main/admin/sub_language.class.php index e7f8d1f12b..9c93f1bb5e 100644 --- a/main/admin/sub_language.class.php +++ b/main/admin/sub_language.class.php @@ -282,6 +282,7 @@ class SubLanguageManager { $lang=Database::fetch_array($result); $sql_update_2 = "UPDATE ".$tbl_settings_current." SET selected_value='".$lang['english_name']."' WHERE variable='platformLanguage'"; $result_2 = Database::query($sql_update_2); + event_system(LOG_PLATFORM_LANGUAGE_CHANGE, LOG_PLATFORM_LANGUAGE, $lang['english_name']); return $result_2 !== false; } /** diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 85f884e548..20b374a5af 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -149,6 +149,7 @@ define('LOG_SESSION_DELETE', 'session_deleted'); define('LOG_SESSION_CATEGORY_CREATE', 'session_category_created'); define('LOG_SESSION_CATEGORY_DELETE', 'session_category_deleted'); define('LOG_CONFIGURATION_SETTINGS_CHANGE', 'settings_changed'); +define('LOG_PLATFORM_LANGUAGE_CHANGE', 'platform_language_changed'); define('LOG_SUBSCRIBE_USER_TO_COURSE', 'user_subscribed'); define('LOG_UNSUBSCRIBE_USER_FROM_COURSE', 'user_unsubscribed'); @@ -165,6 +166,7 @@ define('LOG_SESSION_ID', 'session_id'); define('LOG_SESSION_CATEGORY_ID', 'session_category_id'); define('LOG_CONFIGURATION_SETTINGS_CATEGORY', 'settings_category'); define('LOG_CONFIGURATION_SETTINGS_VARIABLE', 'settings_variable'); +define('LOG_PLATFORM_LANGUAGE', 'default_platform_language'); define('LOG_CAREER_ID', 'career_id'); define('LOG_PROMOTION_ID', 'promotion_id'); @@ -6074,4 +6076,4 @@ function api_set_default_visibility($item_id, $tool_id) { } api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), api_get_group_id(), null, null, null, api_get_session_id()); } -} \ No newline at end of file +} From 2df9df4900c66e9016cec9b322576204431bbb9d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 4 Oct 2012 15:30:52 +0200 Subject: [PATCH 053/124] Should fix bug when student is a tutor in a course see #5542 --- main/mySpace/myStudents.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index 8ec19af163..ed1b36802a 100644 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -23,8 +23,12 @@ require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php'; api_block_anonymous_users(); -if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) { - api_not_allowed(true); +if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) { + // Check if the user is tutor of the course + $user_course_status = CourseManager::get_tutor_in_course_status(api_get_user_id(), api_get_course_id()); + if ($user_course_status != 1) { + api_not_allowed(true); + } } $htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; if (api_get_setting('show_glossary_in_documents') == 'ismanual' || api_get_setting('show_glossary_in_documents') == 'isautomatic' ) { $htmlHeadXtra[] = ''; // Document API $htmlHeadXtra[] = ''; // Storage API -$htmlHeadXtra[] = ''; - // to correct #4029 Random and number of attempt menu empty added window.onload=advanced_parameters; -$htmlHeadXtra[] = ''; // INIT EXERCISE @@ -194,16 +194,12 @@ if ($form->validate()) { } else { if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){ if (!empty($_POST['lp_id'])){ - $lp_id=Security::remove_XSS($_POST['lp_id']);//TODO:this remains to be implemented after press the first post - } - else{ - $lp_id=Security::remove_XSS($_GET['lp_id']); - } - + $lp_id = Security::remove_XSS($_POST['lp_id']);//TODO:this remains to be implemented after press the first post + } else { + $lp_id = Security::remove_XSS($_GET['lp_id']); + } echo "".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM).""; - } - else{ - + } else { echo '' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).''; } } diff --git a/main/exercice/overview.php b/main/exercice/overview.php index c2e3414f58..028c9021e5 100644 --- a/main/exercice/overview.php +++ b/main/exercice/overview.php @@ -174,11 +174,10 @@ if (!empty($attempts)) { case EXERCISE_FEEDBACK_TYPE_EXAM: $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('Score')); break; - } - $row = 0; + } $column = 0; foreach ($header_names as $item) { - $table->setHeaderContents($row, $column, $item); + $table->setHeaderContents(0, $column, $item); $column++; } $row = 1; diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 918f1d1d71..3ef07442b2 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -6075,7 +6075,24 @@ function api_set_default_visibility($item_id, $tool_id, $group_id = null) { } if (empty($group_id)) { $group_id = api_get_group_id(); - } - api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), $group_id, null, null, null, api_get_session_id()); + } + + api_item_property_update(api_get_course_info(), $original_tool_id, $item_id, $visibility, api_get_user_id(), $group_id, null, null, null, api_get_session_id()); + + //Fixes default visibility for tests + + switch ($original_tool_id) { + case TOOL_QUIZ: + $objExerciseTmp = new Exercise(); + $objExerciseTmp->read($item_id); + if ($visibility == 'visible') { + $objExerciseTmp->enable(); + $objExerciseTmp->save(); + } else { + $objExerciseTmp->disable(); + $objExerciseTmp->save(); + } + break; + } } } From 8f683893ad63150531fa0a37d84ff1e7445c132c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 5 Oct 2012 14:53:08 +0200 Subject: [PATCH 072/124] Fixing session exericse reports see #5589 --- main/mySpace/lp_tracking.php | 1 - main/newscorm/learnpath.class.php | 9 ++-- main/newscorm/lp_stats.php | 84 ++++++++++++++++++------------- 3 files changed, 54 insertions(+), 40 deletions(-) diff --git a/main/mySpace/lp_tracking.php b/main/mySpace/lp_tracking.php index 8b01e16a97..813b5ea7e0 100644 --- a/main/mySpace/lp_tracking.php +++ b/main/mySpace/lp_tracking.php @@ -6,7 +6,6 @@ require_once '../inc/global.inc.php'; // resetting the course id $cidReset = true; - $from_myspace = false; $from_link = ''; if (isset($_GET['from']) && $_GET['from'] == 'myspace') { diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index c0f0db439f..cc1c93de9d 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -354,10 +354,9 @@ class learnpath { $res_ins = Database::query($sql_ins); } } - } - + } - $this->ordered_items = $this->get_flat_ordered_items_list($this->get_id(), 0, $course_id); + $this->ordered_items = self::get_flat_ordered_items_list($this->get_id(), 0, $course_id); $this->max_ordered_items = 0; foreach ($this->ordered_items as $index => $dummy) { if ($index > $this->max_ordered_items && !empty($dummy)) { @@ -2682,7 +2681,7 @@ class learnpath { * @param integer Parent ID of the items to look for * @return mixed Ordered list of item IDs or false on error */ - public function get_flat_ordered_items_list($lp, $parent = 0, $course_id = null) { + public static function get_flat_ordered_items_list($lp, $parent = 0, $course_id = null) { if (empty($course_id)) { $course_id = api_get_course_int_id(); } else { @@ -9075,7 +9074,7 @@ EOD; if (!empty($course_data)) { $scorm_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/scorm/'.$this->path; - $list = $this->get_flat_ordered_items_list($lp_id); + $list = self::get_flat_ordered_items_list($lp_id); if (!empty($list)) { foreach ($list as $item_id) { $item = $this->items[$item_id]; diff --git a/main/newscorm/lp_stats.php b/main/newscorm/lp_stats.php index 143ddb31f6..512e3e1e23 100644 --- a/main/newscorm/lp_stats.php +++ b/main/newscorm/lp_stats.php @@ -16,7 +16,10 @@ require_once 'resourcelinker.inc.php'; require_once '../exercice/exercise.lib.php'; $course_code = api_get_course_id(); -$user_id = api_get_user_id(); + +if (empty($user_id)) { + $user_id = api_get_user_id(); +} // Declare variables to be used in lp_stats.php @@ -26,12 +29,10 @@ if (isset($_GET['lp_id']) && isset($lp_id) && !empty($lp_id)) { } else { if (isset($_SESSION['oLP'])) { $lp_id = $_SESSION['oLP']->get_id(); - $list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id); + $list = learnpath::get_flat_ordered_items_list($lp_id); } } - - $is_allowed_to_edit = api_is_allowed_to_edit(null, true); if (isset($_GET['course'])) { @@ -149,7 +150,6 @@ if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) { } //Show lp items - if (is_array($list) && count($list) > 0) { foreach ($list as $my_item_id) { $extend_this = 0; @@ -161,47 +161,63 @@ if (is_array($list) && count($list) > 0) { // Prepare statement to go through each attempt. if (!empty($view)) { - $sql = "SELECT iv.status as mystatus, v.view_count as mycount, iv.score as myscore, iv.total_time as mytime, i.id as myid, - i.lp_id as mylpid, iv.lp_view_id as mylpviewid, i.title as mytitle, i.max_score as mymaxscore, - iv.max_score as myviewmaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path as path - FROM $TBL_LP_ITEM as i INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id ) - INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id) + $sql = "SELECT + iv.status as mystatus, + v.view_count as mycount, + iv.score as myscore, + iv.total_time as mytime, + i.id as myid, + i.lp_id as mylpid, + iv.lp_view_id as mylpviewid, + i.title as mytitle, + i.max_score as mymaxscore, + iv.max_score as myviewmaxscore, + i.item_type as item_type, + iv.view_count as iv_view_count, + iv.id as iv_id, + path + FROM $TBL_LP_ITEM as i + INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id) + INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id) WHERE - i.c_id = $course_id AND - iv.c_id = $course_id AND - v.c_id = $course_id AND i.id = $my_item_id AND + i.id = $my_item_id AND i.lp_id = $lp_id AND - v.user_id = " . $user_id . " AND + v.user_id = $user_id AND v.view_count = $view AND v.session_id = $session_id ORDER BY iv.view_count $qry_order "; //var_dump($sql); } else { - $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " . - " iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " . - " i.title as mytitle, i.max_score as mymaxscore, " . - " iv.max_score as myviewmaxscore, " . - " i.item_type as item_type, iv.view_count as iv_view_count, " . - " iv.id as iv_id, path as path " . - " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v " . - " WHERE i.id = iv.lp_item_id AND - i.c_id = $course_id AND - iv.c_id = $course_id AND - v.c_id = $course_id AND - i.id = $my_item_id " . - " AND iv.lp_view_id = v.id " . - " AND i.lp_id = $lp_id " . - " AND v.user_id = " . $user_id . " " . - " AND v.session_id = $session_id " . - " ORDER BY iv.view_count $qry_order "; + $sql = "SELECT + iv.status as mystatus, + v.view_count as mycount, + iv.score as myscore, + iv.total_time as mytime, + i.id as myid, + i.lp_id as mylpid, + iv.lp_view_id as mylpviewid, + i.title as mytitle, + i.max_score as mymaxscore, + iv.max_score as myviewmaxscore, + i.item_type as item_type, + iv.view_count as iv_view_count, + iv.id as iv_id, + path + FROM $TBL_LP_ITEM as i + INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id) + INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id) + WHERE + i.id = $my_item_id AND + i.lp_id = $lp_id AND + v.user_id = $user_id AND + v.session_id = $session_id + ORDER BY iv.view_count $qry_order "; } - $result = Database::query($sql); $num = Database :: num_rows($result); $time_for_total = 'NaN'; //Extend all + extend scorm? - if (($extend_this || $extend_all) && $num > 0) { - //var_dump('go'); + if (($extend_this || $extend_all) && $num > 0) { $row = Database :: fetch_array($result); $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { From 67ab82a7e394886c2aa528386919d4b27bb4d9d3 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 5 Oct 2012 16:42:17 +0200 Subject: [PATCH 073/124] Fixing group list see #5608 --- main/announcements/announcements.inc.php | 2 +- main/inc/lib/course.lib.php | 11 ++++++----- main/inc/lib/groupmanager.lib.php | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index 608aa809d4..f2c2130226 100644 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -754,7 +754,7 @@ class AnnouncementManager { public static function get_course_groups() { $session_id = api_get_session_id(); if ($session_id != 0) { - $new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), intval($session_id)); + $new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), $session_id); } else { $new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), 0); } diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index b9c1bb6ce1..e2a0c84def 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1527,16 +1527,17 @@ class CourseManager { $course_id = $course_info['real_id']; $group_list = array(); $session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0'; - $sql = "SELECT g.id, g.name, COUNT(gu.id) userNb + + $sql = "SELECT g.id, g.name FROM ".Database::get_course_table(TABLE_GROUP)." AS g - LEFT JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu + INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id) - $session_condition - GROUP BY g.id + $session_condition ORDER BY g.name"; $result = Database::query($sql); - + while ($group_data = Database::fetch_array($result)) { + $group_data[] = GroupManager::number_of_students($group_data['id'], $course_id); $group_list[$group_data['id']] = $group_data; } return $group_list; diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 104921115d..79f188acbe 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -7,7 +7,6 @@ /** * Code */ -//require_once 'tablesort.lib.php';moved to autoload require_once 'fileManage.lib.php'; require_once 'fileUpload.lib.php'; require_once 'document.lib.php'; @@ -832,7 +831,6 @@ class GroupManager { while ($row = Database::fetch_array($rs)) { $result[] = $row['user_id']; } - return $result; } @@ -966,10 +964,14 @@ class GroupManager { * @param int $group_id * @return int Number of students in the given group. */ - public static function number_of_students ($group_id) { + public static function number_of_students ($group_id, $course_id = null) { $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); $group_id = Database::escape_string($group_id); - $course_id = api_get_course_int_id(); + if (empty($course_id)) { + $course_id = api_get_course_int_id(); + } else { + $course_id = intval($course_id); + } $sql = "SELECT COUNT(*) AS number_of_students FROM $table_group_user WHERE c_id = $course_id AND group_id = $group_id"; $db_result = Database::query($sql); $db_object = Database::fetch_object($db_result); @@ -1117,10 +1119,10 @@ class GroupManager { $course_id = api_get_course_int_id(); $sql = "SELECT ug.id, u.user_id, u.lastname, u.firstname, u.email, u.username - FROM ".$table_user." u, ".$table_group_user." ug - WHERE ug.c_id = $course_id AND - ug.group_id='".$group_id."' AND - ug.user_id=u.user_id". $order_clause; + FROM $table_user u INNER JOIN $table_group_user ug ON (ug.user_id = u.user_id) + WHERE ug.c_id = $course_id AND + ug.group_id = $group_id + $order_clause"; $db_result = Database::query($sql); $users = array (); while ($user = Database::fetch_object($db_result)) { From 5136ffe48c32cba5f457d78182c8b2ac6a31de29 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 5 Oct 2012 17:00:19 +0200 Subject: [PATCH 074/124] hiding copy to files "my files" if social network is off see #5607 --- main/document/document.inc.php | 5 ++--- main/document/document.php | 4 ++-- main/social/home.php | 3 +-- main/social/myfiles.php | 9 ++++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/main/document/document.inc.php b/main/document/document.inc.php index 17a9526a71..8d9eb3a0c1 100644 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -226,9 +226,8 @@ function create_document_link($document_data, $show_as_icon = false, $counter = $force_download_html = ($size==0)?'':''.Display::return_icon($forcedownload_icon, get_lang('Download'), array(),ICON_SIZE_SMALL).''; } - //copy files to users myfiles - - if (api_get_setting('users_copy_files') == 'true' && !api_is_anonymous()){ + //Copy files to users myfiles + if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('users_copy_files') == 'true' && !api_is_anonymous()){ $copy_myfiles_link = ($filetype == 'file') ? api_get_self().'?'.api_get_cidreq().'&action=copytomyfiles&id='.$document_data['id'].$req_gid :api_get_self().'?'.api_get_cidreq(); if ($filetype == 'file') { diff --git a/main/document/document.php b/main/document/document.php index d988ab521d..34a2c234b1 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -200,8 +200,8 @@ switch ($action) { } break; case 'copytomyfiles': - // Copy a file to general my files user's - if (api_get_setting('users_copy_files') == 'true' && api_get_user_id() != 0 && !api_is_anonymous()) { + // Copy a file to general my files user's + if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('users_copy_files') == 'true' && api_get_user_id() != 0 && !api_is_anonymous()) { $document_info = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true); $parent_id = $document_info['parent_id']; $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system'); diff --git a/main/social/home.php b/main/social/home.php index 62dc63aafb..70b3416b06 100644 --- a/main/social/home.php +++ b/main/social/home.php @@ -25,8 +25,7 @@ api_block_anonymous_users(); if (api_get_setting('allow_social_tool') !='true' ) { $url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; header('Location: '.$url); - exit; - + exit; api_not_allowed(); } diff --git a/main/social/myfiles.php b/main/social/myfiles.php index e5b9f18e6d..9ae7209f05 100644 --- a/main/social/myfiles.php +++ b/main/social/myfiles.php @@ -12,6 +12,7 @@ $cidReset=true; require_once '../inc/global.inc.php'; api_block_anonymous_users(); + if (api_get_setting('allow_social_tool') !='true') { api_not_allowed(); } @@ -25,7 +26,7 @@ $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('SocialNetwo $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyFiles')); $htmlHeadXtra[] = ' - -
+ - +
results = $return; + return true; + } + /** + * Exports the complete report as a CSV file + * @param string Document path inside the document tool + * @param integer Optional user ID + * @param boolean Whether to include user fields or not + * @return boolean False on error + */ + public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = false, $export_filter = 0, $exercise_id = 0, $hotpotato_name = null) { + global $charset; + $this->_getExercisesReporting($document_path,$user_id, $export_filter, $exercise_id, $hotpotato_name); + $filename = 'exercise_results_'.date('YmdGis').'.csv'; + if(!empty($user_id)) { + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; + } + $data = ''; + + + if (api_is_western_name_order()) { + if(!empty($this->results[0]['first_name'])) { + $data .= get_lang('FirstName').';'; + } + if(!empty($this->results[0]['last_name'])) { + $data .= get_lang('LastName').';'; + } + } else { + if(!empty($this->results[0]['last_name'])) { + $data .= get_lang('LastName').';'; + } + if(!empty($this->results[0]['first_name'])) { + $data .= get_lang('FirstName').';'; + } + } + $data .= get_lang('Email').';'; + + if ($export_user_fields) { + //show user fields section with a big th colspan that spans over all fields + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); + $num = count($extra_user_fields); + foreach($extra_user_fields as $field) { + $data .= '"'.str_replace("\r\n",' ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";'; + } + } + + $data .= get_lang('Title').';'; + $data .= get_lang('StartDate').';'; + $data .= get_lang('EndDate').';'; + $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;'; + $data .= get_lang('Score').';'; + $data .= get_lang('Total').';'; + $data .= get_lang('Status').';'; + $data .= "\n"; + + //results + foreach($this->results as $row) { + + if (api_is_western_name_order()) { + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; + } else { + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; + } + + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; + + if ($export_user_fields) { + //show user fields data, if any, for this user + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); + foreach($user_fields_values as $value) { + $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";'; + } + } + + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; + $data .= str_replace("\r\n",' ',$row['start_date']).';'; + $data .= str_replace("\r\n",' ',$row['end_date']).';'; + $data .= str_replace("\r\n",' ',$row['duration']).';'; + $data .= str_replace("\r\n",' ',$row['result']).';'; + $data .= str_replace("\r\n",' ',$row['max']).';'; + $data .= str_replace("\r\n",' ',$row['status']).';'; + $data .= "\n"; + } + + //output the results + $len = strlen($data); + header('Content-type: application/octet-stream'); + header('Content-Type: application/force-download'); + header('Content-length: '.$len); + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { + header('Content-Disposition: filename= '.$filename); + } else { + header('Content-Disposition: attachment; filename= '.$filename); + } + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { + header('Pragma: '); + header('Cache-Control: '); + header('Cache-Control: public'); // IE cannot download from sessions without a cache + } + header('Content-Description: '.$filename); + header('Content-transfer-encoding: binary'); + echo $data; + return true; + } + + /** + * Exports the complete report as an XLS file + * @return boolean False on error + */ + public function exportCompleteReportXLS($document_path='',$user_id = null, $export_user_fields= false, $export_filter = 0, $exercise_id=0, $hotpotato_name = null) { + global $charset; + $this->_getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); + $filename = 'exercise_results_'.date('YmdGis').'.xls'; + if (!empty($user_id)) { + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.xls'; + } + $workbook = new Spreadsheet_Excel_Writer(); + $workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH)); + $workbook->setVersion(8); // BIFF8 + + $workbook->send($filename); + $worksheet =& $workbook->addWorksheet('Report '.date('YmdGis')); + $worksheet->setInputEncoding(api_get_system_encoding()); + $line = 0; + $column = 0; //skip the first column (row titles) + + // check if exists column 'user' + $with_column_user = false; + foreach ($this->results as $result) { + if (!empty($result['last_name']) && !empty($result['first_name'])) { + $with_column_user = true; + break; + } + } + + + + if ($with_column_user) { + + $worksheet->write($line,$column,get_lang('Email')); + $column++; + + if (api_is_western_name_order()) { + $worksheet->write($line,$column,get_lang('FirstName')); + $column++; + $worksheet->write($line,$column,get_lang('LastName')); + $column++; + } else { + $worksheet->write($line,$column,get_lang('LastName')); + $column++; + $worksheet->write($line,$column,get_lang('FirstName')); + $column++; + } + } + + if ($export_user_fields) { + //show user fields section with a big th colspan that spans over all fields + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); + + //show the fields names for user fields + foreach ($extra_user_fields as $field) { + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); + $column++; + } + } + + $worksheet->write($line,$column, get_lang('Title')); + $column++; + $worksheet->write($line,$column, get_lang('StartDate')); + $column++; + $worksheet->write($line,$column, get_lang('EndDate')); + $column++; + $worksheet->write($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); + $column++; + $worksheet->write($line,$column, get_lang('Score')); + $column++; + $worksheet->write($line,$column, get_lang('Total')); + $column++; + $worksheet->write($line,$column, get_lang('Status')); + $line++; + + foreach ($this->results as $row) { + $column = 0; + + if ($with_column_user) { + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); + $column++; + + if (api_is_western_name_order()) { + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); + $column++; + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); + $column++; + } else { + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); + $column++; + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); + $column++; + } + } + + if ($export_user_fields) { + //show user fields data, if any, for this user + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); + foreach($user_fields_values as $value) { + $worksheet->write($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); + $column++; + } + } + + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); + $column++; + $worksheet->write($line,$column,$row['start_date']); + $column++; + $worksheet->write($line,$column,$row['end_date']); + $column++; + $worksheet->write($line,$column,$row['duration']); + $column++; + $worksheet->write($line,$column,$row['result']); + $column++; + $worksheet->write($line,$column,$row['max']); + $column++; + $worksheet->write($line,$column,$row['status']); + $line++; + } + //output the results + $workbook->close(); + return true; + } +} +endif; \ No newline at end of file From b72c4a51594b79445fec6b1cbb9c3fe3e840e7ba Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 12:27:05 +0200 Subject: [PATCH 097/124] Adding system tracking to the homepage see #5597 --- main/admin/configure_homepage.php | 9 +++++---- main/inc/lib/main_api.lib.php | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index b4d505f6c2..3b075fadd0 100644 --- a/main/admin/configure_homepage.php +++ b/main/admin/configure_homepage.php @@ -176,8 +176,8 @@ if (!empty($action)) { if (EventsMail::check_if_using_class('portal_homepage_edited')) { EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id())); - } - + } + event_system(LOG_HOMEPAGE_CHANGED, 'edit_top', cut($home_top, 254), api_get_utc_datetime(), api_get_user_id()); break; case 'edit_notice': // Filter @@ -205,6 +205,7 @@ if (!empty($action)) { fputs($fp, "$notice_title
\n$notice_text"); fclose($fp); } + event_system(LOG_HOMEPAGE_CHANGED, 'edit_notice', cut($notice_title, 254), api_get_utc_datetime(), api_get_user_id()); break; case 'edit_news': //Filter @@ -251,6 +252,7 @@ if (!empty($action)) { } } } + event_system(LOG_HOMEPAGE_CHANGED, 'edit_news', cut($home_news, 254), api_get_utc_datetime(), api_get_user_id()); break; case 'insert_tabs': case 'edit_tabs': @@ -388,6 +390,7 @@ if (!empty($action)) { fclose($fp); } } + event_system(LOG_HOMEPAGE_CHANGED, $action, cut($link_name.':'.$link_url, 254), api_get_utc_datetime(), api_get_user_id()); break; } //end of switch($action) @@ -615,8 +618,6 @@ if (!empty($action)) { Display::display_header($tool_name); -//api_display_tool_title($tool_name); - switch ($action) { case 'open_link': if (!empty($link)) { diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index cbc01d4139..1bd9505078 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -153,6 +153,9 @@ define('LOG_PLATFORM_LANGUAGE_CHANGE', 'platform_language_changed'); define('LOG_SUBSCRIBE_USER_TO_COURSE', 'user_subscribed'); define('LOG_UNSUBSCRIBE_USER_FROM_COURSE', 'user_unsubscribed'); + +define('LOG_HOMEPAGE_CHANGED', 'homepage_changed'); + define('LOG_PROMOTION_CREATE', 'promotion_created'); define('LOG_PROMOTION_DELETE', 'promotion_deleted'); define('LOG_CAREER_CREATE', 'career_created'); From ade53f7b51d5fafd58c7f2cd644fb9667ac10082 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 14:25:34 +0200 Subject: [PATCH 098/124] Should fix bug when exporting images in a PDF see BT#5058 --- main/inc/lib/pdf.lib.php | 42 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/main/inc/lib/pdf.lib.php b/main/inc/lib/pdf.lib.php index a622503113..3da5ee5e7b 100644 --- a/main/inc/lib/pdf.lib.php +++ b/main/inc/lib/pdf.lib.php @@ -8,10 +8,7 @@ */ define('_MPDF_PATH', api_get_path(LIBRARY_PATH).'mpdf/'); require_once _MPDF_PATH.'mpdf.php'; -/** - * Class - * @package chamilo.library - */ + class PDF { public $pdf; @@ -45,8 +42,8 @@ class PDF { $this->params['course_code'] = isset($params['course_code']) ? $params['course_code'] : api_get_course_id(); $this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false; - $this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation); - } + $this->pdf = new mPDF('UTF-8', $page_format, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation); + } function html_to_pdf_with_template($content) { Display :: display_no_header(); @@ -207,16 +204,27 @@ class PDF { $elements = $doc->getElementsByTagName('img'); if (!empty($elements)) { foreach ($elements as $item) { - $old_src = $item->getAttribute('src'); - + $old_src = $item->getAttribute('src'); if (strpos($old_src, 'http') === false) { - if (strpos($old_src, '/main/default_course_document') === false) { - $old_src_fixed = str_replace('/courses/'.$course_data['path'].'/document/', '', $old_src); - $old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src_fixed); - $new_path = $document_path.$old_src_fixed; - $document_html= str_replace($old_src, $new_path, $document_html); + if (strpos($old_src, '/main/default_course_document') === false) { + if (api_get_path(REL_PATH) != '/') { + $old_src = str_replace(api_get_path(REL_PATH), '', $old_src); + } + $old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src); + //$old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src_fixed); + $new_path = $document_path.$old_src_fixed; + $document_html= str_replace($old_src, $new_path, $document_html); } - } + } else { + //Check if this is a complete URL + /*if (strpos($old_src, 'courses/'.$course_data['path'].'/document/') === false) { + + } else { + $old_src_fixed = str_replace(api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/', '', $old_src); + $new_path = $document_path.$old_src_fixed; + $document_html= str_replace($old_src, $new_path, $document_html); + }*/ + } } } } @@ -224,11 +232,11 @@ class PDF { api_set_encoding_html($document_html, 'UTF-8'); // The library mPDF expects UTF-8 encoded input data. $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through // $_GET[] too, as it is done with file name. - // At the moment the title is retrieved from the html document itself. + // At the moment the title is retrieved from the html document itself. + //echo $document_html;exit; if (empty($title)) { $title = $filename; // Here file name is expected to contain ASCII symbols only. - } - + } if (!empty($document_html)) { $this->pdf->WriteHTML($document_html.$page_break, 2); } From 2b8a4ff32250bf378ca5388f4577f176a15f6b3c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 14:36:08 +0200 Subject: [PATCH 099/124] Adding strip_tags see #5597 --- main/admin/configure_homepage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index 3b075fadd0..2877dc580f 100644 --- a/main/admin/configure_homepage.php +++ b/main/admin/configure_homepage.php @@ -177,7 +177,7 @@ if (!empty($action)) { if (EventsMail::check_if_using_class('portal_homepage_edited')) { EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id())); } - event_system(LOG_HOMEPAGE_CHANGED, 'edit_top', cut($home_top, 254), api_get_utc_datetime(), api_get_user_id()); + event_system(LOG_HOMEPAGE_CHANGED, 'edit_top', cut(strip_tags($home_top), 254), api_get_utc_datetime(), api_get_user_id()); break; case 'edit_notice': // Filter @@ -205,7 +205,7 @@ if (!empty($action)) { fputs($fp, "$notice_title
\n$notice_text"); fclose($fp); } - event_system(LOG_HOMEPAGE_CHANGED, 'edit_notice', cut($notice_title, 254), api_get_utc_datetime(), api_get_user_id()); + event_system(LOG_HOMEPAGE_CHANGED, 'edit_notice', cut(strip_tags($notice_title), 254), api_get_utc_datetime(), api_get_user_id()); break; case 'edit_news': //Filter @@ -252,7 +252,7 @@ if (!empty($action)) { } } } - event_system(LOG_HOMEPAGE_CHANGED, 'edit_news', cut($home_news, 254), api_get_utc_datetime(), api_get_user_id()); + event_system(LOG_HOMEPAGE_CHANGED, 'edit_news', strip_tags(cut($home_news, 254)), api_get_utc_datetime(), api_get_user_id()); break; case 'insert_tabs': case 'edit_tabs': From 42b2d2b1f0da9e8101fcec3b963abeac9a45869f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 15:26:30 +0200 Subject: [PATCH 100/124] Using & instead of & in the api_get_cidreq() function --- main/inc/lib/main_api.lib.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 1bd9505078..bc6ef2f434 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -1226,11 +1226,17 @@ function api_get_anonymous_id() { * * @see Uri.course_params */ -function api_get_cidreq() { - return empty($GLOBALS['_cid']) ? '' : 'cidReq='.htmlspecialchars($GLOBALS['_cid']). - (api_get_session_id() == 0 ? '&id_session=0' : '&id_session='.api_get_session_id()). - (api_get_group_id() == 0 ? '&gidReq=0' : '&gidReq='.api_get_group_id()); +function api_get_cidreq($add_session_id = true, $add_group_id = true) { + $url = empty($GLOBALS['_cid']) ? '' : 'cidReq='.htmlspecialchars($GLOBALS['_cid']); + if ($add_session_id) { + $url .= api_get_session_id() == 0 ? '&id_session=0' : '&id_session='.api_get_session_id(); + } + if ($add_group_id) { + $url .= api_get_group_id() == 0 ? '&gidReq=0' : '&gidReq='.api_get_group_id(); + } + return $url; } + /** * Returns the current course info array. * Note: this array is only defined if the user is inside a course. From 4a4bbb5bc6c1b979c9bac4cb8447119fd9f44176 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 15:26:59 +0200 Subject: [PATCH 101/124] Setting _gid gidReq (group id) in the session like id_session --- main/inc/local.inc.php | 48 ++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index 236ff21c03..eae071a7d8 100644 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -295,8 +295,7 @@ if (!empty($_SESSION['_user']['user_id']) && !($login || $logout)) { header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=access_url_inactive'); exit; } - } else { //Only admins of the "main" (first) Chamilo portal can login wherever they want - //var_dump($current_access_url_id, $my_url_list); exit; + } else { //Only admins of the "main" (first) Chamilo portal can login wherever they want if (in_array(1, $my_url_list)) { //Check if this admin have the access_url_id = 1 which means the principal ConditionalLogin::check_conditions($uData); $_user['user_id'] = $uData['user_id']; @@ -575,12 +574,6 @@ if (!empty($cidReq) && (!isset($_SESSION['_cid']) or (isset($_SESSION['_cid']) & $gidReset = true; // As groups depend from courses, group id is reset } -// if the requested group is different from the group in session -$gid = isset($_SESSION['_gid']) ? $_SESSION['_gid'] : ''; -if (isset($gidReq) && $gidReq != $gid) { - $gidReset = true; -} - /* USER INIT */ if (isset($uidReset) && $uidReset) { // session data refresh requested @@ -690,6 +683,11 @@ if (isset($cidReset) && $cidReset) { Session::erase('id_session'); } + if (!empty($_GET['gidReq'])) { + $_SESSION['_gid'] = intval($_GET['gidReq']); + } else { + Session::erase('_gid'); + } if (!isset($_SESSION['login_as'])) { //Course login @@ -722,11 +720,11 @@ if (isset($cidReset) && $cidReset) { Session::erase('id_session'); Session::erase('session_name'); } + Session::erase('_gid'); } } else { - // Continue with the previous values - + // Continue with the previous values if (empty($_SESSION['_course']) && !empty($_SESSION['_cid'])) { //Just in case $_course is empty we try to load if the c_id still exists $_course = api_get_course_info($_SESSION['_cid']); @@ -739,16 +737,17 @@ if (isset($cidReset) && $cidReset) { Session::write('_course', $_course); } } - + if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values... $_cid = -1; //set default values that will be caracteristic of being unset $_course = -1; } else { + $_cid = $_SESSION['_cid' ]; $_course = $_SESSION['_course']; - // these lines are usefull for tracking. Indeed we can have lost the id_session and not the cid. - // Moreover, if we want to track a course with another session it can be usefull + // these lines are usefull for tracking. Indeed we can have lost the id_session and not the cid. + // Moreover, if we want to track a course with another session it can be usefull if (!empty($_GET['id_session'])) { $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']). '"'; @@ -756,7 +755,11 @@ if (isset($cidReset) && $cidReset) { list($_SESSION['session_name']) = Database::fetch_array($rs); $_SESSION['id_session'] = intval($_GET['id_session']); } - + + if (!empty($_REQUEST['gidReq'])) { + $_SESSION['_gid'] = intval($_REQUEST['gidReq']); + } + if (!isset($_SESSION['login_as'])) { $save_course_access = true; @@ -818,6 +821,13 @@ if (isset($cidReset) && $cidReset) { } } +// if the requested group is different from the group in session +$gid = isset($_SESSION['_gid']) ? $_SESSION['_gid'] : ''; +var_dump($gid); +if (isset($gidReq) && $gidReq != $gid) { + $gidReset = true; +} + /* COURSE / USER REL. INIT */ $session_id = api_get_session_id(); @@ -832,8 +842,7 @@ $is_courseCoach = false; //course coach //Course - User permissions $is_sessionAdmin = false; -if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { - +if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { if (isset($_cid) && $_cid) { $my_user_id = isset($user_id) ? intval($user_id) : 0; $variable = 'accept_legal_'.$my_user_id.'_'.$_course['real_id'].'_'.$session_id; @@ -870,7 +879,6 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { $is_courseAdmin = (bool) ($cuData['status'] == 1 ); $is_courseTutor = (bool) ($cuData['tutor_id' ] == 1 ); $is_courseMember = true; - $_courseUser['role'] = $cuData['role']; Session::write('_courseUser',$_courseUser); @@ -1051,8 +1059,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { } /* GROUP INIT */ - -if ((isset($gidReset) && $gidReset) || (isset($cidReset) && $cidReset)) { // session data refresh requested +if ((isset($gidReset) && $gidReset) || (isset($cidReset) && $cidReset)) { // session data refresh requested if ($gidReq && $_cid && !empty($_course['real_id'])) { // have keys to search data $group_table = Database::get_course_table(TABLE_GROUP); $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$gidReq'"; @@ -1068,11 +1075,12 @@ if ((isset($gidReset) && $gidReset) || (isset($cidReset) && $cidReset)) { // ses Session::erase('_gid'); } } elseif (isset($_SESSION['_gid'])) { // continue with the previous values - $_gid = $_SESSION ['_gid']; + $_gid = $_SESSION['_gid']; } else { //if no previous value, assign caracteristic undefined value $_gid = -1; } + //set variable according to student_view_enabled choices if (api_get_setting('student_view_enabled') == "true") { if (isset($_GET['isStudentView'])) { From b8e40248593871dc79e915da15ad5d14f1cb1e22 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 15:29:18 +0200 Subject: [PATCH 102/124] Fixing SQL error when editing groups see #5625 --- main/group/group.php | 8 ++++---- main/group/group_edit.php | 7 +++---- main/inc/lib/groupmanager.lib.php | 9 ++++++--- main/inc/local.inc.php | 1 - 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/main/group/group.php b/main/group/group.php index d5be82149a..2734d31c2a 100644 --- a/main/group/group.php +++ b/main/group/group.php @@ -307,10 +307,10 @@ foreach ($group_cats as $index => $category) { // Edit-links if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) { - $edit_actions = ''.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).' '; - $edit_actions .= ''.Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).' '; - $edit_actions .= ''.Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).' '; - $edit_actions .= ''.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).' '; + $edit_actions = ''.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).' '; + $edit_actions .= ''.Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).' '; + $edit_actions .= ''.Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).' '; + $edit_actions .= ''.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).' '; $row[] = $edit_actions; } if (!empty($this_group['nbMember'])) { diff --git a/main/group/group_edit.php b/main/group/group_edit.php index c393c99336..f07e590e3d 100644 --- a/main/group/group_edit.php +++ b/main/group/group_edit.php @@ -113,9 +113,9 @@ function check_group_members($value) { /* MAIN CODE */ // Build form -$form = new FormValidator('group_edit'); +$form = new FormValidator('group_edit', 'post', api_get_self().'?'.api_get_cidreq()); -$form->addElement('header', '', $nameTools); +$form->addElement('header', $nameTools); $form->addElement('hidden', 'action'); $form->addElement('hidden', 'referer'); @@ -137,8 +137,7 @@ foreach ($complete_user_list as $index => $user) { $group_tutor_list = GroupManager :: get_subscribed_tutors($current_group['id']); $selected_users = array(); $selected_tutors = array(); -foreach ($group_tutor_list as $index => $user) { - //$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], .$user['lastname']); +foreach ($group_tutor_list as $index => $user) { $selected_tutors[] = $user['user_id']; } diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 79f188acbe..ef084358f5 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -1111,11 +1111,14 @@ class GroupManager { * @return array An array with information of all users from the given group. * (user_id, firstname, lastname, email) */ - public static function get_subscribed_users ($group_id) { + public static function get_subscribed_users($group_id) { $table_user = Database :: get_main_table(TABLE_MAIN_USER); $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); $order_clause = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname'; - $group_id = Database::escape_string($group_id); + if (empty($group_id)) { + return array(); + } + $group_id = intval($group_id); $course_id = api_get_course_int_id(); $sql = "SELECT ug.id, u.user_id, u.lastname, u.firstname, u.email, u.username @@ -1124,7 +1127,7 @@ class GroupManager { ug.group_id = $group_id $order_clause"; $db_result = Database::query($sql); - $users = array (); + $users = array(); while ($user = Database::fetch_object($db_result)) { $member['user_id'] = $user->user_id; $member['firstname'] = $user->firstname; diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index eae071a7d8..e3e5a49b40 100644 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -823,7 +823,6 @@ if (isset($cidReset) && $cidReset) { // if the requested group is different from the group in session $gid = isset($_SESSION['_gid']) ? $_SESSION['_gid'] : ''; -var_dump($gid); if (isset($gidReq) && $gidReq != $gid) { $gidReset = true; } From bd0c7c8bdcb477a795fd676d04c5216062e86f25 Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Wed, 10 Oct 2012 15:36:59 +0200 Subject: [PATCH 103/124] Fix date bug in hotpotatoes export result - ref #5624 --- .../hotpotatoes_exercise_result.class.php | 70 ++++++++----------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/main/exercice/hotpotatoes_exercise_result.class.php b/main/exercice/hotpotatoes_exercise_result.class.php index 52d975a31a..73682b08aa 100644 --- a/main/exercice/hotpotatoes_exercise_result.class.php +++ b/main/exercice/hotpotatoes_exercise_result.class.php @@ -62,7 +62,7 @@ class HotpotatoesExerciseResult * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null */ // function _getExercisesReporting($document_path, $user_id = null, $filter = 0, $hotpotato_name = null) { - function _getExercisesReporting($document_path, $hotpotato_name = null, $user_id = null, $filter = 0) { + function _getExercisesReporting($document_path, $hotpotato_name) { $return = array(); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); @@ -141,14 +141,12 @@ class HotpotatoesExerciseResult $title = basename($hpresults[$i]['exe_name']); } if(empty($user_id)) { - $return[$i]['email'] = $hpresults[$i]['email']; + $return[$i]['email'] = $hpresults[$i]['email']; $return[$i]['first_name'] = $hpresults[$i]['userpart1']; $return[$i]['last_name'] = $hpresults[$i]['userpart2']; } $return[$i]['title'] = $title; - $return[$i]['start_date'] = api_get_local_time($results[$i]['exstart']); - $return[$i]['end_date'] = api_get_local_time($results[$i]['exdate']); - $return[$i]['duration'] = $results[$i]['duration']; + $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; $return[$i]['result'] = $hpresults[$i]['exe_result']; $return[$i]['max'] = $hpresults[$i]['exe_weighting']; @@ -164,32 +162,31 @@ class HotpotatoesExerciseResult * @param boolean Whether to include user fields or not * @return boolean False on error */ - public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = false, $export_filter = 0, $exercise_id = 0, $hotpotato_name = null) { + public function exportCompleteReportCSV($document_path='', $hotpotato_name) { global $charset; - $this->_getExercisesReporting($document_path,$user_id, $export_filter, $exercise_id, $hotpotato_name); + $this->_getExercisesReporting($document_path, $hotpotato_name); $filename = 'exercise_results_'.date('YmdGis').'.csv'; if(!empty($user_id)) { $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; } $data = ''; - - if (api_is_western_name_order()) { - if(!empty($this->results[0]['first_name'])) { - $data .= get_lang('FirstName').';'; - } - if(!empty($this->results[0]['last_name'])) { - $data .= get_lang('LastName').';'; - } - } else { - if(!empty($this->results[0]['last_name'])) { - $data .= get_lang('LastName').';'; - } - if(!empty($this->results[0]['first_name'])) { - $data .= get_lang('FirstName').';'; - } + if (api_is_western_name_order()) { + if(!empty($this->results[0]['first_name'])) { + $data .= get_lang('FirstName').';'; + } + if(!empty($this->results[0]['last_name'])) { + $data .= get_lang('LastName').';'; + } + } else { + if(!empty($this->results[0]['last_name'])) { + $data .= get_lang('LastName').';'; } - $data .= get_lang('Email').';'; + if(!empty($this->results[0]['first_name'])) { + $data .= get_lang('FirstName').';'; + } + } + $data .= get_lang('Email').';'; if ($export_user_fields) { //show user fields section with a big th colspan that spans over all fields @@ -202,25 +199,23 @@ class HotpotatoesExerciseResult $data .= get_lang('Title').';'; $data .= get_lang('StartDate').';'; - $data .= get_lang('EndDate').';'; - $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;'; $data .= get_lang('Score').';'; $data .= get_lang('Total').';'; - $data .= get_lang('Status').';'; $data .= "\n"; + error_log("HUBC |||".serialize($this->results)."|||"); + //results foreach($this->results as $row) { + if (api_is_western_name_order()) { + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; + } else { + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; + } - if (api_is_western_name_order()) { - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; - } else { - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; - } - - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; if ($export_user_fields) { //show user fields data, if any, for this user @@ -231,12 +226,9 @@ class HotpotatoesExerciseResult } $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; - $data .= str_replace("\r\n",' ',$row['start_date']).';'; - $data .= str_replace("\r\n",' ',$row['end_date']).';'; - $data .= str_replace("\r\n",' ',$row['duration']).';'; + $data .= str_replace("\r\n",' ',$row['exe_date']).';'; $data .= str_replace("\r\n",' ',$row['result']).';'; $data .= str_replace("\r\n",' ',$row['max']).';'; - $data .= str_replace("\r\n",' ',$row['status']).';'; $data .= "\n"; } From 16bb54501da778e413336a602a6aa4a545b2b7a7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 15:51:19 +0200 Subject: [PATCH 104/124] Changing group edition behaviour see #5625 --- main/group/group_category.php | 2 +- main/group/group_edit.php | 47 +++++++++-------------------------- main/group/group_space.php | 3 ++- main/inc/local.inc.php | 6 ++++- 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/main/group/group_category.php b/main/group/group_category.php index d8924acb27..d184bb447e 100644 --- a/main/group/group_category.php +++ b/main/group/group_category.php @@ -74,7 +74,7 @@ if (isset ($_GET['id'])) { // Update settings of existing category $action = 'update_settings'; $form = new FormValidator('group_category', 'post', '?id='.$category['id']); - $form->addElement('header','',$nameTools); + $form->addElement('header', $nameTools); $form->addElement('hidden', 'id'); } else { // Checks if the field was created in the table Category. It creates it if is neccesary diff --git a/main/group/group_edit.php b/main/group/group_edit.php index f07e590e3d..d1e3240152 100644 --- a/main/group/group_edit.php +++ b/main/group/group_edit.php @@ -23,16 +23,12 @@ $current_course_tool = TOOL_GROUP; // Notice for unauthorized people. api_protect_course_script(true); -/* Libraries & settings */ - $group_id = api_get_group_id(); - -/* Constants & variables */ $current_group = GroupManager :: get_group_properties($group_id); -/* Header */ $nameTools = get_lang('EditGroup'); $interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups')); +$interbreadcrumb[] = array ('url' => 'group_space.php?'.api_get_cidReq(), 'name' => $current_group['name']); $is_group_member = GroupManager :: is_tutor_of_group(api_get_user_id(), $group_id); @@ -192,19 +188,6 @@ $group_members_element->setButtonAttributes('add', array('class' => 'btn arrowr' $group_members_element->setButtonAttributes('remove', array('class' => 'btn arrowl')); $form->addFormRule('check_group_members'); - -// Tutors: this has been replaced with the new tutors code -//$tutors = GroupManager :: get_all_tutors(); -//$possible_tutors[0] = get_lang('GroupNoTutor'); -//foreach ($tutors as $index => $tutor) -//{ -// $possible_tutors[$tutor['user_id']] = api_get_person_name($tutor['lastname'], $tutor['firstname']); -//} -//$group = array (); -//$group[] = & $form->createElement('select', 'tutor_id', null, $possible_tutors); -//$group[] = & $form->createElement('static', null, null, '  '.get_lang('AddTutors').''); -//$form->addGroup($group, 'tutor_group', get_lang('GroupTutor'), '', false); - // Members per group $form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT); $group = array(); @@ -234,7 +217,6 @@ $group[] = $form->createElement('radio', 'work_state', null, get_lang('Public'), $group[] = $form->createElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('work.png', get_lang('GroupWork') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWork'), '', false); - // Calendar settings $group = array(); $group[] = $form->createElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); @@ -300,10 +282,11 @@ if ($form->validate()) { //var_dump(count($_POST['group_members']), $max_member, GroupManager::MEMBER_PER_GROUP_NO_LIMIT); $cat = GroupManager :: get_category_from_group($current_group['id']); if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { - header('Location:group_edit.php?show_message='.get_lang('GroupTooMuchMembers')); + header('Location: '.api_get_self().'?'.api_get_cidreq().'&show_message_warning='.get_lang('GroupTooMuchMembers')); } else { - header('Location: '.$values['referer'].'?action=show_msg&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); + header('Location: '.api_get_self().'?'.api_get_cidreq().'&show_message_sucess='.get_lang('GroupSettingsModified').'&category='.$cat['id']); } + exit; } $defaults = $current_group; @@ -317,11 +300,6 @@ if ($defaults['maximum_number_of_students'] == GroupManager::MEMBER_PER_GROUP_NO $defaults['max_member_no_limit'] = 1; $defaults['max_member'] = $defaults['maximum_number_of_students']; } -$referer = parse_url($_SERVER['HTTP_REFERER']); -$referer = basename($referer['path']); -if ($referer != 'group_space.php' && $referer != 'group.php') { - $referer = 'group.php'; -} if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { $keyword_name = Security::remove_XSS($_GET['keyword']); @@ -329,18 +307,17 @@ if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { } Display :: display_header($nameTools, 'Group'); -?> -
- -
-setDefaults($defaults); $form->display(); -/* FOOTER */ Display :: display_footer(); \ No newline at end of file diff --git a/main/group/group_space.php b/main/group/group_space.php index 1af8e33611..e521964978 100644 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -28,12 +28,13 @@ require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php'; /* MAIN CODE */ $group_id = api_get_group_id(); + $user_id = api_get_user_id(); $current_group = GroupManager :: get_group_properties($group_id); if (empty($current_group)) { - api_not_allowed(); + api_not_allowed(true); } $this_section = SECTION_COURSES; diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index e3e5a49b40..ae3ffc4510 100644 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -715,12 +715,16 @@ if (isset($cidReset) && $cidReset) { } } } + //Deleting session info if (api_get_session_id()) { Session::erase('id_session'); Session::erase('session_name'); } - Session::erase('_gid'); + + if (api_get_group_id()) { + Session::erase('_gid'); + } } } else { From b661997a740d20d257a8fed00f8ba2552a3014f2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 16:16:16 +0200 Subject: [PATCH 105/124] Fixing hotpotatoe bug when viewing the exercise list as an student --- main/exercice/exercice.php | 2 +- main/exercice/exercise_report.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index e5a6e965ac..aa34a8f366 100644 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -870,7 +870,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { if ($active == 1) { $nbrActiveTests = $nbrActiveTests +1; $item .= Display::tag('td', ''.$title.''); - $item .= Display::tag('td', ''); + //$item .= Display::tag('td', ''); $actions ='' . Display :: return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_SMALL).''; $item .= Display::tag('td', $actions); echo Display::tag('tr',$item, array('class'=>$class)); diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index e23590e0cb..b6ccc1c19b 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -60,11 +60,11 @@ $filter_user = isset($_REQUEST['filter_by_user']) ? intval($_REQUEST['filter_ $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); if (empty($exercise_id)) { - api_not_allowed(); + api_not_allowed(true); } if (!$is_allowedToEdit) { - api_not_allowed(); + api_not_allowed(true); } if (!empty($exercise_id)) From ddb3e0af93f2daec605d6c7b4bfa1b5c4b9ccf2b Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Wed, 10 Oct 2012 16:34:05 +0200 Subject: [PATCH 106/124] Force utf-8 for csv export file and fix first/lastname order - ref #5624 --- .../hotpotatoes_exercise_result.class.php | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/main/exercice/hotpotatoes_exercise_result.class.php b/main/exercice/hotpotatoes_exercise_result.class.php index 73682b08aa..8f1f5f78eb 100644 --- a/main/exercice/hotpotatoes_exercise_result.class.php +++ b/main/exercice/hotpotatoes_exercise_result.class.php @@ -83,27 +83,27 @@ class HotpotatoesExerciseResult } if (empty($user_id)) { - $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", - email, - tth.exe_name, - tth.exe_result, - tth.exe_weighting, - tth.exe_date - FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu - WHERE tu.user_id=tth.exe_user_id AND - tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND - tth.exe_name = '$hotpotato_name' - ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC"; + $sql="SELECT firstname as userpart1, lastname as userpart2 , + email, + tth.exe_name, + tth.exe_result, + tth.exe_weighting, + tth.exe_date + FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu + WHERE tu.user_id=tth.exe_user_id AND + tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND + tth.exe_name = '$hotpotato_name' + ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC"; } else { - $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; - // get only this user's results - - $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date - FROM $TBL_TRACK_HOTPOTATOES - WHERE exe_user_id = '" . $user_id . "' AND - exe_cours_id = '" . Database :: escape_string($cid) . "' AND - tth.exe_name = '$hotpotato_name' - ORDER BY exe_cours_id ASC, exe_date DESC"; + $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; + // get only this user's results + + $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date + FROM $TBL_TRACK_HOTPOTATOES + WHERE exe_user_id = '" . $user_id . "' AND + exe_cours_id = '" . Database :: escape_string($cid) . "' AND + tth.exe_name = '$hotpotato_name' + ORDER BY exe_cours_id ASC, exe_date DESC"; } $results = array(); @@ -203,8 +203,6 @@ class HotpotatoesExerciseResult $data .= get_lang('Total').';'; $data .= "\n"; - error_log("HUBC |||".serialize($this->results)."|||"); - //results foreach($this->results as $row) { if (api_is_western_name_order()) { @@ -249,6 +247,8 @@ class HotpotatoesExerciseResult } header('Content-Description: '.$filename); header('Content-transfer-encoding: binary'); + // @todo add this utf-8 header for all csv files + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file echo $data; return true; } From 483cf43bbfdd79fe30634b1f16fce9ac5c52456a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 16:41:19 +0200 Subject: [PATCH 107/124] Fixing 'wma' => 'audio/x-ms-wma', 'wmv' => 'video/x-ms-wmv', see #5294 --- main/inc/lib/document.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 077689d880..686670a48b 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -220,8 +220,8 @@ class DocumentManager { 'wmlc' => 'application/vnd.wap.wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', - 'wma' => 'video/x-ms-wma', - 'wmv' => 'audio/x-ms-wmv', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml', 'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml', From 43bd99ee1c9aac9ff1301782f0e9e782c3b979d5 Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Wed, 10 Oct 2012 17:07:50 +0200 Subject: [PATCH 108/124] Minor. Change date sort DESC to ASC to fit screen order for Hotpot export - ref #5624 --- main/exercice/hotpotatoes_exercise_result.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/exercice/hotpotatoes_exercise_result.class.php b/main/exercice/hotpotatoes_exercise_result.class.php index 8f1f5f78eb..09c50270b6 100644 --- a/main/exercice/hotpotatoes_exercise_result.class.php +++ b/main/exercice/hotpotatoes_exercise_result.class.php @@ -93,7 +93,7 @@ class HotpotatoesExerciseResult WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND tth.exe_name = '$hotpotato_name' - ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC"; + ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC"; } else { $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; // get only this user's results @@ -103,7 +103,7 @@ class HotpotatoesExerciseResult WHERE exe_user_id = '" . $user_id . "' AND exe_cours_id = '" . Database :: escape_string($cid) . "' AND tth.exe_name = '$hotpotato_name' - ORDER BY exe_cours_id ASC, exe_date DESC"; + ORDER BY exe_cours_id ASC, exe_date ASC"; } $results = array(); From 7214424d6db98a1ab087f107bd6428982a7499b1 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 10 Oct 2012 17:31:29 +0200 Subject: [PATCH 109/124] Minor - cosmetic changes --- main/admin/course_category.php | 582 ++++++++++++++++----------------- 1 file changed, 274 insertions(+), 308 deletions(-) diff --git a/main/admin/course_category.php b/main/admin/course_category.php index c8bc24f697..dc1bec913b 100644 --- a/main/admin/course_category.php +++ b/main/admin/course_category.php @@ -1,19 +1,19 @@ 'index.php',"name" => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin')); //$interbreadcrumb[]=array('url' => 'configure_homepage.php',"name" => get_lang('ConfigureHomePage')); Display::display_header($tool_name); -if(!empty($category)) { - $myquery = "SELECT * FROM $tbl_category WHERE code ='$category'"; - $result = Database::query($myquery); - if(Database::num_rows($result)==0) { - $category = ''; - } +if (!empty($category)) { + $myquery = "SELECT * FROM $tbl_category WHERE code ='$category'"; + $result = Database::query($myquery); + if (Database::num_rows($result) == 0) { + $category = ''; + } } -if(empty($action)) { - $myquery = "SELECT t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count,COUNT(DISTINCT t3.code) AS nbr_courses +if (empty($action)) { + $myquery = "SELECT t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count,COUNT(DISTINCT t3.code) AS nbr_courses FROM $tbl_category t1 LEFT JOIN $tbl_category t2 ON t1.code=t2.parent_id LEFT JOIN $tbl_course t3 ON t3.category_code=t1.code - WHERE t1.parent_id ".(empty($category)?"IS NULL":"='$category'")." + WHERE t1.parent_id " . (empty($category) ? "IS NULL" : "='$category'") . " GROUP BY t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count ORDER BY t1.tree_pos"; - $result = Database::query($myquery); - $Categories=Database::store_result($result); + $result = Database::query($myquery); + $Categories = Database::store_result($result); } -if($action == 'add' || $action == 'edit') { - ?> -
- -
- addElement('header', '', $form_title); - $form->display(); - ?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
:
:
- /> - /> -
 
-
- - -
-0){ - $parent_id=Database::fetch_array($result); - } +if ($action == 'add' || $action == 'edit') { + ?> +
+ +
+ addElement('header', '', $form_title); + $form->display(); + ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
:
:
+ /> + /> +
 
+
+ + +
+ 0) { + $parent_id = Database::fetch_array($result); + } + + $parent_id['parent_id'] ? $link = ' (' . $parent_id['parent_id'] . ')' : $link = ''; + ?> + + + + + + +
+
    + + 0) { + foreach ($Categories as $enreg) { + ?> +
  • + + + + + + ( - ) +
  • + +
+ + + + +Display::display_footer(); - +/* * ****** Functions ******* */ - - - -
-
    +function deleteNode($node) { + global $tbl_category, $tbl_course; + $node = Database::escape_string($node); -0) -{ - foreach($Categories as $enreg) - { - ?> -
  • - - - - - - ( - ) -
  • - -
+ $result = Database::query("SELECT parent_id,tree_pos FROM $tbl_category WHERE code='$node'"); + if ($row = Database::fetch_array($result)) { + if (!empty($row['parent_id'])) { + Database::query("UPDATE $tbl_course SET category_code='" . $row['parent_id'] . "' WHERE category_code='$node'"); + Database::query("UPDATE $tbl_category SET parent_id='" . $row['parent_id'] . "' WHERE parent_id='$node'"); + } else { + Database::query("UPDATE $tbl_course SET category_code='' WHERE category_code='$node'"); + Database::query("UPDATE $tbl_category SET parent_id=NULL WHERE parent_id='$node'"); + } + Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '" . $row['tree_pos'] . "'"); + Database::query("DELETE FROM $tbl_category WHERE code='$node'"); - '".$row['tree_pos']."'"); - Database::query("DELETE FROM $tbl_category WHERE code='$node'"); - - if(!empty($row['parent_id'])) - { - updateFils($row['parent_id']); - } - } -} +function addNode($code, $name, $canHaveCourses, $parent_id) { + global $tbl_category; -function addNode($code,$name,$canHaveCourses,$parent_id) -{ - global $tbl_category; + $canHaveCourses = $canHaveCourses ? 'TRUE' : 'FALSE'; + $code = Database::escape_string($code); + $name = Database::escape_string($name); + $parent_id = Database::escape_string($parent_id); - $canHaveCourses=$canHaveCourses?'TRUE':'FALSE'; - $code = Database::escape_string($code); - $name = Database::escape_string($name); - $parent_id = Database::escape_string($parent_id); + $result = Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'"); - $result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'"); + if (Database::num_rows($result)) { + return false; + } - if (Database::num_rows($result)) { - return false; - } + $result = Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category"); - $result=Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category"); + $row = Database::fetch_array($result); - $row=Database::fetch_array($result); + $tree_pos = $row['maxTreePos'] + 1; - $tree_pos=$row['maxTreePos']+1; - - $code = generate_course_code($code); - Database::query("INSERT INTO $tbl_category(name,code,parent_id,tree_pos,children_count,auth_course_child) VALUES('$name','$code',".(empty($parent_id)?"NULL":"'$parent_id'").",'$tree_pos','0','$canHaveCourses')"); + $code = generate_course_code($code); + Database::query("INSERT INTO $tbl_category(name,code,parent_id,tree_pos,children_count,auth_course_child) VALUES('$name','$code'," . (empty($parent_id) ? "NULL" : "'$parent_id'") . ",'$tree_pos','0','$canHaveCourses')"); - updateFils($parent_id); + updateFils($parent_id); - return true; + return true; } -function editNode($code,$name,$canHaveCourses,$old_code) -{ - global $tbl_category, $tbl_course; - - $canHaveCourses=$canHaveCourses?'TRUE':'FALSE'; - $code = Database::escape_string($code); - $name = Database::escape_string($name); - $old_code = Database::escape_string($old_code); - - if($code != $old_code) { - $result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'"); - if(Database::num_rows($result)) { - return false; - } - } - $code = generate_course_code($code); - Database::query("UPDATE $tbl_category SET name='$name', code='$code',auth_course_child='$canHaveCourses' WHERE code='$old_code'"); - $sql = "UPDATE $tbl_course SET category_code = '$code' WHERE category_code = '$old_code' "; - Database::query($sql); - - return true; +function editNode($code, $name, $canHaveCourses, $old_code) { + global $tbl_category, $tbl_course; + + $canHaveCourses = $canHaveCourses ? 'TRUE' : 'FALSE'; + $code = Database::escape_string($code); + $name = Database::escape_string($name); + $old_code = Database::escape_string($old_code); + + if ($code != $old_code) { + $result = Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'"); + if (Database::num_rows($result)) { + return false; + } + } + $code = generate_course_code($code); + Database::query("UPDATE $tbl_category SET name='$name', code='$code',auth_course_child='$canHaveCourses' WHERE code='$old_code'"); + $sql = "UPDATE $tbl_course SET category_code = '$code' WHERE category_code = '$old_code' "; + Database::query($sql); + + return true; } -function moveNodeUp($code,$tree_pos,$parent_id) -{ - global $tbl_category; - $code = Database::escape_string($code); - $tree_pos = Database::escape_string($tree_pos); - $parent_id = Database::escape_string($parent_id); +function moveNodeUp($code, $tree_pos, $parent_id) { + global $tbl_category; + $code = Database::escape_string($code); + $tree_pos = Database::escape_string($tree_pos); + $parent_id = Database::escape_string($parent_id); - $result=Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos<'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1"); + $result = Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id " . (empty($parent_id) ? "IS NULL" : "='$parent_id'") . " AND tree_pos<'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1"); - if(!$row=Database::fetch_array($result)) - { - $result=Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos>'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1"); + if (!$row = Database::fetch_array($result)) { + $result = Database::query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id " . (empty($parent_id) ? "IS NULL" : "='$parent_id'") . " AND tree_pos>'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1"); - if(!$row=Database::fetch_array($result)) - { - return false; - } - } + if (!$row = Database::fetch_array($result)) { + return false; + } + } - Database::query("UPDATE $tbl_category SET tree_pos='".$row['tree_pos']."' WHERE code='$code'"); - Database::query("UPDATE $tbl_category SET tree_pos='$tree_pos' WHERE code='$row[code]'"); + Database::query("UPDATE $tbl_category SET tree_pos='" . $row['tree_pos'] . "' WHERE code='$code'"); + Database::query("UPDATE $tbl_category SET tree_pos='$tree_pos' WHERE code='$row[code]'"); } -function updateFils($category) -{ - global $tbl_category; - $category = Database::escape_string($category); - $result=Database::query("SELECT parent_id FROM $tbl_category WHERE code='$category'"); - - if($row=Database::fetch_array($result)) - { - updateFils($row['parent_id']); - } +function updateFils($category) { + global $tbl_category; + $category = Database::escape_string($category); + $result = Database::query("SELECT parent_id FROM $tbl_category WHERE code='$category'"); - $children_count=compterFils($category,0)-1; + if ($row = Database::fetch_array($result)) { + updateFils($row['parent_id']); + } - Database::query("UPDATE $tbl_category SET children_count='$children_count' WHERE code='$category'"); + $children_count = compterFils($category, 0) - 1; + Database::query("UPDATE $tbl_category SET children_count='$children_count' WHERE code='$category'"); } -function compterFils($pere,$cpt) -{ - global $tbl_category; - $pere = Database::escape_string($pere); - $result=Database::query("SELECT code FROM $tbl_category WHERE parent_id='$pere'"); +function compterFils($pere, $cpt) { + global $tbl_category; + $pere = Database::escape_string($pere); + $result = Database::query("SELECT code FROM $tbl_category WHERE parent_id='$pere'"); - while($row=Database::fetch_array($result)) - { - $cpt=compterFils($row['code'],$cpt); - } + while ($row = Database::fetch_array($result)) { + $cpt = compterFils($row['code'], $cpt); + } - return ($cpt+1); + return ($cpt + 1); } \ No newline at end of file From a0ce7fbfbd597751ee8d4a6e3bc76f2a95f5ed6d Mon Sep 17 00:00:00 2001 From: Hubert Borderiou Date: Thu, 11 Oct 2012 10:20:41 +0200 Subject: [PATCH 110/124] Fix bug, so student can view image of HotPotatoes tests --- main/inc/lib/document.lib.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 077689d880..9c518510b6 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -1172,10 +1172,26 @@ class DocumentManager { $condition = "AND id_session IN ('$session_id', '0') "; // The " d.filetype='file' " let the user see a file even if the folder is hidden see #2198 - //When using hotpotatoes files, new files are generated in the hotpotatoe folder, if user_id=1 does the exam a new html file will be generated: hotpotatoe.html.(user_id).t.html - //so we remove that string in order to find correctly the origin file - if (strpos($doc_path, 'HotPotatoes_files')) { -// $doc_path = substr($doc_path, 0, strlen($doc_path) - 8); + /* + When using hotpotatoes files, a new html files are generated in the hotpotatoes folder + to display the test. + The genuine html file is copied to math4.htm(user_id).t.html + Images files are not copied, and keep same name. + To check the html file visibility, we don't have to check file math4.htm(user_id).t.html but file math4.htm + In this case, we have to remove (user_id).t.html to check the visibility of the file + For images, we just check the path of the image file. + + Exemple of hotpotatoes folder : + A.jpg + maths4-consigne.jpg + maths4.htm + maths4.htm1.t.html + maths4.htm52.t.html + maths4.htm654.t.html + omega.jpg + theta.jpg + */ + if (strpos($doc_path, 'HotPotatoes_files') && preg_match("/\.t\.html$/", $doc_path)) { $doc_path = substr($doc_path, 0, strlen($doc_path) - 7 - strlen(api_get_user_id())); } From 2b03581d36fb02f40f7f0a6c0ac2ac63e35580df Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 11 Oct 2012 10:38:16 +0200 Subject: [PATCH 111/124] Minor adding error_logs --- main/newscorm/lp_ajax_save_item.php | 9 +++-- main/newscorm/scorm_api.php | 51 ++++++++++++++++------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/main/newscorm/lp_ajax_save_item.php b/main/newscorm/lp_ajax_save_item.php index c8a2a22619..fda07678a6 100644 --- a/main/newscorm/lp_ajax_save_item.php +++ b/main/newscorm/lp_ajax_save_item.php @@ -37,16 +37,17 @@ require_once 'back_compat.inc.php'; */ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none') { global $_configuration; - $debug = 0; + $debug = 5; $return = ''; if ($debug > 0) { error_log('In save_item('.$lp_id.','.$user_id.','.$view_id.','.$item_id.','.$score.','.$max.','.$min.',"'.$status.'",'.$time.',"'.$suspend.'","'.$location.'","'.(count($interactions) > 0 ? $interactions[0] : '').'","'.$core_exit.'")', 0); } - //$objResponse = new xajaxResponse(); + require_once 'learnpath.class.php'; require_once 'scorm.class.php'; require_once 'aicc.class.php'; require_once 'learnpathItem.class.php'; require_once 'scormItem.class.php'; require_once 'aiccItem.class.php'; + $mylp = ''; if (isset($_SESSION['lpobject'])) { if ($debug > 1) { error_log('////$_SESSION[lpobject] is set', 0); } @@ -142,6 +143,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, //return $objResponse; return $return; } + $mystatus_in_db = $mylpi->get_status(true); if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed' && $mystatus_in_db != 'failed') { $mystatus_in_memory = $mylpi->get_status(false); @@ -157,6 +159,9 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $mycomplete = $mylp->get_complete_items_count(); $myprogress_mode = $mylp->get_progress_bar_mode(); $myprogress_mode = ($myprogress_mode == '' ? '%' : $myprogress_mode); + if ($debug > 1) { error_log("myprogress_mode $myprogress_mode", 0); } + if ($debug > 1) { error_log("mytotal $mytotal", 0); } + if ($debug > 1) { error_log("mycomplete $mycomplete", 0); } //$mylpi->write_to_db(); $_SESSION['lpobject'] = serialize($mylp); if ($mylpi->get_type() != 'sco') { diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index 3e02501b17..96913f22aa 100644 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -1116,8 +1116,8 @@ function logit_scorm(message,priority) { * @param string Message to log * @param integer Priority (0 for top priority, 3 for lowest) */ -function logit_lms(message,priority){ - if(lms_logs>=priority){ +function logit_lms(message, priority){ + if (lms_logs>=priority) { if ($("#lp_log_name") && $("#log_content")) { $("#log_content").append("LMS: " + message + "
"); } @@ -1131,9 +1131,11 @@ function logit_lms(message,priority){ url: "lp_ajax_log.php", dataType: "script", async: true - }); + }); } + console.log(message); } + /** * Update the Table Of Contents frame, by changing CSS styles, mostly * @param string Action to be taken @@ -1255,39 +1257,42 @@ function update_progress_bar(nbr_complete, nbr_total, mode) { logit_lms('update_progress_bar('+nbr_complete+','+nbr_total+','+mode+')',2); logit_lms('could update with data: '+olms.lms_lp_id+','+olms.lms_view_id+','+olms.lms_user_id,2); - if (mode == ''){mode='%';} - if (nbr_total == 0){nbr_total=1;} + if (mode == '') { + mode='%'; + } + + if (nbr_total == 0) { + nbr_total=1; + } + var percentage = (nbr_complete/nbr_total)*100; percentage = Math.round(percentage); - var pr_text = $("#progress_text"); - var progress_bar = $("#progress_bar_value"); - - - progress_bar.css('width', percentage + "%"); + var pr_text = $("#progress_text"); + var progress_bar = $("#progress_bar_value"); + progress_bar.css('width', percentage + "%"); /* var pr_full = $("#progress_img_full"); var pr_empty = $("#progress_img_empty"); pr_full.attr('width',percentage*1.2); - pr_empty.attr('width',(100-percentage)*1.2); - + pr_empty.attr('width',(100-percentage)*1.2); */ - var mytext = ''; - switch(mode){ - case 'abs': - mytext = nbr_complete + '/' + nbr_total; - break; - case '%': - default: - mytext = percentage + '%'; - break; - } + var mytext = ''; + switch(mode){ + case 'abs': + mytext = nbr_complete + '/' + nbr_total; + break; + case '%': + default: + mytext = percentage + '%'; + break; + } pr_text.html(mytext); - return true; } + /** * Analyses the variables that have been modified through this SCO's life and * put them into an array for later shipping to lp_ajax_save_item.php From e9b106aff5758e979dc892e5d7c95ff20e69de81 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 11 Oct 2012 11:18:49 +0200 Subject: [PATCH 112/124] Fixes bug in a quer when getting the status, this causes that the progress is stuck in 0% see BT#5069 --- main/newscorm/lp_ajax_save_item.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main/newscorm/lp_ajax_save_item.php b/main/newscorm/lp_ajax_save_item.php index fda07678a6..0ceb88bc07 100644 --- a/main/newscorm/lp_ajax_save_item.php +++ b/main/newscorm/lp_ajax_save_item.php @@ -67,9 +67,15 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, if (!is_a($mylp, 'learnpath')) { return ''; } $prereq_check = $mylp->prerequisites_match($item_id); - if ($prereq_check === true) { // Launch the prerequisites check and set error if needed. + + $mylpi = $mylp->items[$item_id]; + //This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069 + $mylpi->set_lp_view($view_id); + + if ($prereq_check === true) { + // Launch the prerequisites check and set error if needed - $mylpi =& $mylp->items[$item_id]; + //$mylpi =& $mylp->items[$item_id]; //$mylpi->set_lp_view($view_id); if (isset($max) && $max != -1) { $mylpi->max_score = $max; @@ -156,7 +162,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $mystatus = $mystatus_in_db; } $mytotal = $mylp->get_total_items_count_without_chapters(); - $mycomplete = $mylp->get_complete_items_count(); + $mycomplete = $mylp->get_complete_items_count(); $myprogress_mode = $mylp->get_progress_bar_mode(); $myprogress_mode = ($myprogress_mode == '' ? '%' : $myprogress_mode); if ($debug > 1) { error_log("myprogress_mode $myprogress_mode", 0); } From fa0aae33ad952e57f355da13f012219aee37e7f7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 11 Oct 2012 11:19:09 +0200 Subject: [PATCH 113/124] Minor cosmetic changes --- main/newscorm/learnpath.class.php | 6 ++--- main/newscorm/learnpathItem.class.php | 4 +-- main/newscorm/scorm_api.php | 37 +++++++++++++++------------ 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index df68febf20..1ae60a015e 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -1451,7 +1451,7 @@ class learnpath { $i = 0; foreach ($this->items as $id => $dummy) { // Trying failed and browsed considered "progressed" as well. - if ($this->items[$id]->status_is(array ( + if ($this->items[$id]->status_is(array( 'completed', 'passed', 'succeeded', @@ -1515,12 +1515,12 @@ class learnpath { } $total = 0; foreach ($this->items as $temp2) { - if (!in_array($temp2->get_type(), array ( + if (!in_array($temp2->get_type(), array( 'dokeos_chapter', 'chapter', 'dir' ))) - $total++; + $total++; } return $total; } diff --git a/main/newscorm/learnpathItem.class.php b/main/newscorm/learnpathItem.class.php index 9f084a6bb4..93fed02260 100644 --- a/main/newscorm/learnpathItem.class.php +++ b/main/newscorm/learnpathItem.class.php @@ -1003,7 +1003,7 @@ class learnpathItem { if ($check_db) { if (self::debug > 2) { error_log('New LP - In learnpathItem::get_status(): checking db', 0); } $table = Database::get_course_table(TABLE_LP_ITEM_VIEW); - $sql = "SELECT status FROM $table WHERE c_id = $course_id AND id = '".$this->db_item_view_id."' AND view_count = '".$this->get_attempt_id()."'"; + $sql = "SELECT status FROM $table WHERE c_id = $course_id AND id = '".$this->db_item_view_id."' AND view_count = '".$this->get_attempt_id()."'"; if (self::debug > 2) { error_log('New LP - In learnpathItem::get_status() - Checking DB: '.$sql, 0); } $res = Database::query($sql); @@ -1012,7 +1012,7 @@ class learnpathItem { if ($update_local) { $this->set_status($row['status']); } - if (self::debug > 2) { error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'], 0); } + if (self::debug > 2) { error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'], 0); } return $row['status']; } } else { diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index 96913f22aa..b765342a47 100644 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -1092,32 +1092,35 @@ function chamilo_void_save_asset(myscore,mymax) * @param integer Priority (0 for top priority, 3 for lowest) */ function logit_scorm(message,priority) { - if(scorm_logs == 0) {return false;} - if(scorm_logs>priority){ /* fixed see http://support.chamilo.org/issues/370 */ - if($("#lp_log_name") && $("#log_content")){ + //scorm_logs = 10000; + if (scorm_logs == 0) { return false; } + if (scorm_logs > priority) { + /* fixed see http://support.chamilo.org/issues/370 */ + if ($("#lp_log_name") && $("#log_content")){ $("#log_content").append("SCORM: " + message + "
"); } - params = { - msg: "SCORM: " + message, - debug: scorm_logs - }; - $.ajax({ - type: "POST", - data: params, - url: "lp_ajax_log.php", - dataType: "script", - async: true - }); - + params = { + msg: "SCORM: " + message, + debug: scorm_logs + }; + $.ajax({ + type: "POST", + data: params, + url: "lp_ajax_log.php", + dataType: "script", + async: true + }); + //console.log(message); } } + /** * Logs information about LMS activity into the log frame * @param string Message to log * @param integer Priority (0 for top priority, 3 for lowest) */ function logit_lms(message, priority){ - if (lms_logs>=priority) { + if (lms_logs >= priority) { if ($("#lp_log_name") && $("#log_content")) { $("#log_content").append("LMS: " + message + "
"); } @@ -1133,7 +1136,7 @@ function logit_lms(message, priority){ async: true }); } - console.log(message); + //console.log(message); } /** From c21ede61475e47ac1f7aae1131c144713c81815d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 11 Oct 2012 11:43:45 +0200 Subject: [PATCH 114/124] Fixing group settings redirection see #5625 --- main/group/group.php | 6 ++++++ main/group/group_edit.php | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/main/group/group.php b/main/group/group.php index 2734d31c2a..52d896f7c9 100644 --- a/main/group/group.php +++ b/main/group/group.php @@ -92,6 +92,12 @@ if (isset($_GET['action'])) { case 'show_msg' : Display :: display_confirmation_message($my_msg); break; + case 'warning_message' : + Display :: display_warning_message($my_msg); + break; + case 'success_message' : + Display :: display_confirmation_message($my_msg); + break; } } diff --git a/main/group/group_edit.php b/main/group/group_edit.php index d1e3240152..b7ddb53a13 100644 --- a/main/group/group_edit.php +++ b/main/group/group_edit.php @@ -278,13 +278,12 @@ if ($form->validate()) { GroupManager :: subscribe_users($values['group_members'], $current_group['id']); } - // Returning to the group area (note: this is inconsistent with the rest of chamilo) - //var_dump(count($_POST['group_members']), $max_member, GroupManager::MEMBER_PER_GROUP_NO_LIMIT); + // Returning to the group area (note: this is inconsistent with the rest of chamilo) $cat = GroupManager :: get_category_from_group($current_group['id']); if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { - header('Location: '.api_get_self().'?'.api_get_cidreq().'&show_message_warning='.get_lang('GroupTooMuchMembers')); + header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers')); } else { - header('Location: '.api_get_self().'?'.api_get_cidreq().'&show_message_sucess='.get_lang('GroupSettingsModified').'&category='.$cat['id']); + header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); } exit; } From bd3c1cfef4a47768d0b7433e6c593832c0071f8f Mon Sep 17 00:00:00 2001 From: Yoselyn Castillo Date: Thu, 11 Oct 2012 11:56:16 +0200 Subject: [PATCH 115/124] Fixing message see #5540 --- .../classes/CourseSelectForm.class.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/main/coursecopy/classes/CourseSelectForm.class.php b/main/coursecopy/classes/CourseSelectForm.class.php index b8de02b726..d7c7673f45 100644 --- a/main/coursecopy/classes/CourseSelectForm.class.php +++ b/main/coursecopy/classes/CourseSelectForm.class.php @@ -140,14 +140,7 @@ class CourseSelectForm echo get_lang('DestinationCourse').' : '.$course_infos['title']; echo ''; } - - echo '

'; - echo get_lang('SelectResources'); - echo '

'; - - Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt')); - - echo ''; + echo ''; echo ''; echo '
'; echo ''; @@ -164,6 +157,12 @@ class CourseSelectForm $forums = array(); $forum_topics = array(); + echo '

'; + echo get_lang('SelectResources'); + echo '

'; + + Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt')); + foreach ($course->resources as $type => $resources) { if (count($resources) > 0) { switch ($type) { @@ -609,4 +608,4 @@ class CourseSelectForm echo '
'; echo '
'; } -} +} \ No newline at end of file From 3ae96de86cb17f1c043b817ab15fbaf27caa9eaf Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 12 Oct 2012 00:07:44 -0500 Subject: [PATCH 116/124] Moving to version 1.9.4 again for automated packaging purposes --- documentation/changelog.html | 19 +++++++++++++++++++ main/install/index.php | 2 +- main/install/version.php | 8 ++++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/documentation/changelog.html b/documentation/changelog.html index 03e53732b3..d5340526d4 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -44,6 +44,25 @@

Note: most #wxyz references are issue numbers you can find in our public bug tracking system

 

+

Chamilo 1.9.4 - , 15th of November, 2012

+

Release notes - summary

+

Chamilo 1.9.4 is a minor stable version with a series of improvements on top of 1.9.2.

+ +

Release name

+ +

New Features

+
    +
  • +
+

Improvements

+
    +
  • +
+

Debugging

+
    +
  • +
+

Chamilo 1.9.2 - Hanga Roa, 27th of September, 2012

Release notes - summary

diff --git a/main/install/index.php b/main/install/index.php index 71c0b6f47c..4685f63419 100644 --- a/main/install/index.php +++ b/main/install/index.php @@ -110,7 +110,7 @@ error_reporting(E_ALL); // Upgrading from any subversion of 1.6 is just like upgrading from 1.6.5 $update_from_version_6 = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5'); // Upgrading from any subversion of 1.8 avoids the additional step of upgrading from 1.6 -$update_from_version_8 = array('1.8', '1.8.2', '1.8.3', '1.8.4', '1.8.5', '1.8.6', '1.8.6.1', '1.8.6.2','1.8.7','1.8.7.1','1.8.8','1.8.8.2', '1.8.8.4', '1.8.8.6', '1.9.0'); +$update_from_version_8 = array('1.8', '1.8.2', '1.8.3', '1.8.4', '1.8.5', '1.8.6', '1.8.6.1', '1.8.6.2','1.8.7','1.8.7.1','1.8.8','1.8.8.2', '1.8.8.4', '1.8.8.6', '1.9.0', '1.9.2'); $my_old_version = ''; $tmp_version = get_config_param('dokeos_version'); diff --git a/main/install/version.php b/main/install/version.php index 0f16eac241..e612d688c9 100644 --- a/main/install/version.php +++ b/main/install/version.php @@ -11,10 +11,10 @@ /** * Variables used from the main/install/index.php */ -$new_version = '1.9.2'; -$new_version_status = 'Stable'; -$new_version_last_id = 2; -$new_version_stable = true; +$new_version = '1.9.4'; +$new_version_status = 'Unstable'; +$new_version_last_id = 1; +$new_version_stable = false; $new_version_major = false; $software_name = 'Chamilo'; $software_url = 'http://www.chamilo.org/'; From a3b76ce735640ebb9939f7ae7e81f26be165da62 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 11:01:22 +0200 Subject: [PATCH 117/124] Fixing number of users see #5634 --- main/inc/lib/course.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index e2a0c84def..ce16fe1e07 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1537,7 +1537,7 @@ class CourseManager { $result = Database::query($sql); while ($group_data = Database::fetch_array($result)) { - $group_data[] = GroupManager::number_of_students($group_data['id'], $course_id); + $group_data['userNb'] = GroupManager::number_of_students($group_data['id'], $course_id); $group_list[$group_data['id']] = $group_data; } return $group_list; From acdbe8091c83fd60f58a526624ed274fefd4ce7a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 11:06:22 +0200 Subject: [PATCH 118/124] Adding default row quantity when using jqgrid see #5381 --- main/inc/lib/display.lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 387f76cbbe..8c96f8ca63 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -869,6 +869,11 @@ class Display { $obj->datatype = 'json'; + //Default row quantity + if (!isset($extra_params['rowList'])) { + $extra_params['rowList'] = array(50, 100, 200); + } + $json = ''; if (!empty($extra_params['datatype'])) { $obj->datatype = $extra_params['datatype']; From faaff66a957ceb80845a8260d356413cc9e5074b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 12:06:03 +0200 Subject: [PATCH 119/124] Minor - fixing narrow select multiples --- main/announcements/announcements.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index f2c2130226..d3468b8552 100644 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -604,7 +604,7 @@ class AnnouncementManager { */ public static function construct_not_selected_select_form($group_list = null, $user_list = null, $to_already_selected) { - echo "'; // adding the groups to the select form if ($group_list) { foreach ($group_list as $this_group) { @@ -656,7 +656,7 @@ class AnnouncementManager { $ref_array_users = self::get_course_users(); // we construct the form of the already selected groups / users - echo "'; if (is_array($to_already_selected)) { foreach ($to_already_selected as $groupuser) { list($type, $id) = explode(":", $groupuser); From a425a4bf310e1a1111bd783d98ad8b880cbecbea Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 12:58:35 +0200 Subject: [PATCH 120/124] Fixing $_user array when first login using _api_format_user() function see #5640 + removing UNIX_TIMESTAMP --- main/inc/local.inc.php | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index ae3ffc4510..f70f3d65ed 100644 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -587,7 +587,7 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); $track_e_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); - $sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date + $sql = "SELECT user.*, a.user_id is_admin, login.login_date FROM $user_table LEFT JOIN $admin_table a ON user.user_id = a.user_id @@ -602,37 +602,18 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested // Extracting the user data $uData = Database::fetch_array($result); - - $_user ['firstName'] = $uData ['firstname' ]; - $_user ['lastName' ] = $uData ['lastname' ]; - $_user ['mail' ] = $uData ['email' ]; - $_user ['lastLogin'] = $uData ['login_date']; - $_user ['official_code'] = $uData ['official_code']; - $_user ['picture_uri'] = $uData ['picture_uri']; - $_user ['user_id'] = $uData ['user_id']; - $_user ['language'] = $uData ['language']; - $_user ['auth_source'] = $uData ['auth_source']; - $_user ['theme'] = $uData ['theme']; - $_user ['status'] = $uData ['status']; - + + $_user = _api_format_user($uData, false); + $_user['lastLogin'] = api_strtotime($uData['login_date'], 'UTC'); + $is_platformAdmin = (bool) (! is_null( $uData['is_admin'])); $is_allowedCreateCourse = (bool) (($uData ['status'] == COURSEMANAGER) or (api_get_setting('drhCourseManagerRights') and $uData['status'] == DRH)); ConditionalLogin::check_conditions($uData); Session::write('_user',$_user); UserManager::update_extra_field_value($_user['user_id'], 'already_logged_in', 'true'); - Session::write('is_platformAdmin',$is_platformAdmin); + Session::write('is_platformAdmin', $is_platformAdmin); Session::write('is_allowedCreateCourse',$is_allowedCreateCourse); - - // If request_uri is setted we have to go further to have course permissions - /*if (empty($_SESSION['request_uri']) || !isset($_SESSION['request_uri'])) { - if (isset($_SESSION['noredirection'])) { - //If we just want to reset info without redirecting user - unset($_SESSION['noredirection']); - } else { - LoginRedirection::redirect(); - } - }*/ } else { header('location:'.api_get_path(WEB_PATH)); //exit("WARNING UNDEFINED UID !! "); From 13141cecb9a67c45f7bb94c6d3b7b85371473716 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 14:48:03 +0200 Subject: [PATCH 121/124] Minor - fixing class export --- main/admin/usergroup_export.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/admin/usergroup_export.php b/main/admin/usergroup_export.php index f9784f7111..2073953f15 100644 --- a/main/admin/usergroup_export.php +++ b/main/admin/usergroup_export.php @@ -34,9 +34,9 @@ if ($form->validate()) { $header = array(array('name', 'description')); $data = $user_group->get_all_for_export(); $data = array_merge($header, $data); - $filename = 'export_classes_'.date('Y-m-d_H-i-s'); + $filename = 'export_classes_'.api_get_local_time(); Export::export_table_csv($data,$filename); - + exit; } Display :: display_header($tool_name); $form->display(); From 9f61e5ae639a96de42aeff98b33838b7b78be119 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 15:30:41 +0200 Subject: [PATCH 122/124] Minor - cosmetic changes --- main/exercice/hotspot_admin.inc.php | 1812 ++++++++++++++------------- 1 file changed, 914 insertions(+), 898 deletions(-) diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php index 8b1ee6aa4d..89a62fff56 100644 --- a/main/exercice/hotspot_admin.inc.php +++ b/main/exercice/hotspot_admin.inc.php @@ -6,36 +6,38 @@ * @package chamilo.exercise * @author Toon Keppens */ + /** * Code * ALLOWED_TO_INCLUDE is defined in admin.php */ - use \ChamiloSession as Session; if (!defined('ALLOWED_TO_INCLUDE')) { - exit(); + exit(); } $modifyAnswers = intval($_GET['hotspotadmin']); if (!is_object($objQuestion)) { - $objQuestion = Question :: read($modifyAnswers); + $objQuestion = Question :: read($modifyAnswers); } -$questionName = $objQuestion->selectTitle(); -$answerType = $objQuestion->selectType(); -$pictureName = $objQuestion->selectPicture(); +$questionName = $objQuestion->selectTitle(); +$answerType = $objQuestion->selectType(); +$pictureName = $objQuestion->selectPicture(); $debug = 0; // debug variable to get where we are -$okPicture = empty($pictureName)?false:true; +$okPicture = empty($pictureName) ? false : true; // if we come from the warning box "this question is used in serveral exercises" -if ($modifyIn) { - if($debug>0){echo '$modifyIn was set'."
\n";} +if ($modifyIn) { + if ($debug > 0) { + echo '$modifyIn was set' . "
\n"; + } // if the user has chosed to modify the question only in the current exercise if ($modifyIn == 'thisExercise') { // duplicates the question - $questionId=$objQuestion->duplicate(); + $questionId = $objQuestion->duplicate(); // deletes the old question $objQuestion->delete($exerciseId); @@ -57,943 +59,957 @@ if ($modifyIn) { // construction of the duplicated Answers - $objAnswer=new Answer($questionId); + $objAnswer = new Answer($questionId); } - $color = unserialize($color); - $reponse = unserialize($reponse); - $comment = unserialize($comment); - $weighting = unserialize($weighting); - $hotspot_coordinates= unserialize($hotspot_coordinates); - $hotspot_type = unserialize($hotspot_type); - $destination = unserialize($destination); + $color = unserialize($color); + $reponse = unserialize($reponse); + $comment = unserialize($comment); + $weighting = unserialize($weighting); + $hotspot_coordinates = unserialize($hotspot_coordinates); + $hotspot_type = unserialize($hotspot_type); + $destination = unserialize($destination); unset($buttonBack); } -$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?'.api_get_cidreq().'&exerciseId='.$exerciseId; +$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $exerciseId; // the answer form has been submitted if ($submitAnswers || $buttonBack) { - - if ($answerType==HOT_SPOT) { - - if($debug>0){echo '$submitAnswers or $buttonBack was set'."
\n";} - $questionWeighting=$nbrGoodAnswers=0; - for($i=1;$i <= $nbrAnswers;$i++) { - if($debug>0){echo str_repeat(' ',4).'$answerType is HOT_SPOT'."
\n";} - - $reponse[$i]=trim($reponse[$i]); - $comment[$i]=trim($comment[$i]); - $weighting[$i]=$weighting[$i]; // it can be float - - // checks if field is empty - if(empty($reponse[$i]) && $reponse[$i] != '0') { - $msgErr=get_lang('HotspotGiveAnswers'); - - // clears answers already recorded into the Answer object - $objAnswer->cancel(); - break; - } - - if($weighting[$i] <= 0) { - $msgErr=get_lang('HotspotWeightingError'); - // clears answers already recorded into the Answer object - $objAnswer->cancel(); - break; - } - - if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { - $msgErr=get_lang('HotspotNotDrawn'); - // clears answers already recorded into the Answer object - $objAnswer->cancel(); - break; - } - - } // end for() - - - if (empty($msgErr)) { - for($i=1;$i <= $nbrAnswers;$i++) { - if($debug>0){echo str_repeat(' ',4).'$answerType is HOT_SPOT'."
\n";} - $reponse[$i]=trim($reponse[$i]); - $comment[$i]=trim($comment[$i]); - $weighting[$i]=($weighting[$i]); //it can be float - if($weighting[$i]) { - $questionWeighting+=$weighting[$i]; - } - // creates answer - $objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]); - } // end for() - // saves the answers into the data base - $objAnswer->save(); - - // sets the total weighting of the question - $objQuestion->updateWeighting($questionWeighting); - $objQuestion->save($exerciseId); - - $editQuestion=$questionId; - unset($modifyAnswers); - echo ''; - - } - if($debug>0){echo '$modifyIn was set - end'."
\n";} - } else { - - if($debug>0){echo '$submitAnswers or $buttonBack was set'."
\n";} - $questionWeighting=$nbrGoodAnswers=0; - $select_question=$_POST['select_question']; - $try=$_POST['try']; - $url=$_POST['url']; - $destination=array(); - - $threadhold1 = $_POST['threadhold1']; - $threadhold2 = $_POST['threadhold2']; - $threadhold3 = $_POST['threadhold3']; - - for($i=1;$i <= $nbrAnswers;$i++) { - if($debug>0){echo str_repeat(' ',4).'$answerType is HOT_SPOT'."
\n";} - - $reponse[$i]=trim($reponse[$i]); - $comment[$i]=trim($comment[$i]); - $weighting[$i] = $weighting[$i]; - - if (empty($threadhold1[$i])) - $threadhold1_str=0; - else - $threadhold1_str=intval($threadhold1[$i]); - - if (empty($threadhold2[$i])) - $threadhold2_str=0; - else - $threadhold2_str=intval($threadhold2[$i]); - - if (empty($threadhold3[$i])) - $threadhold3_str=0; - else - $threadhold3_str=intval($threadhold3[$i]); - - $threadhold_total=$threadhold1_str.';'.$threadhold2_str.';'.$threadhold3_str; - //echo '
';print_r($_POST);echo '
'; - - if ($try[$i]=='on') { - $try_str=1; - } else { - $try_str=0; - } - - if (empty($lp[$i])) { - $lp_str=0; - } else { - $lp_str=$lp[$i]; - } - - if ($url[$i]=='') { - $url_str=''; - } else { - $url_str=$url[$i]; - } - - if ($select_question[$i]=='') { - $question_str=0; - } else { - $question_str=$select_question[$i]; - } - $destination[$i]= $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str; - - // the last answer is the IF NO ERROR section witch has not have the reponse, weight and coordinates values - //if ($i!=$nbrAnswers && !($answerType==HOT_SPOT_DELINEATION)) - // { - - // checks if field is empty - if(empty($reponse[$i]) && $reponse[$i] != '0') { - $msgErr=get_lang('HotspotGiveAnswers'); - - // clears answers already recorded into the Answer object - $objAnswer->cancel(); - break; - } - - if($weighting[$i] <= 0 && $_SESSION['tmp_answers']['hotspot_type'][$i] != 'oar') { - $msgErr=get_lang('HotspotWeightingError'); - // clears answers already recorded into the Answer object - $objAnswer->cancel(); - break; - } - - if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { - $msgErr=get_lang('HotspotNotDrawn'); - // clears answers already recorded into the Answer object - $objAnswer->cancel(); - break; - } - } // end for() - - //now the noerror section - $select_question_noerror=$_POST['select_question_noerror']; - $lp_noerror=$_POST['lp_noerror']; - $try_noerror=$_POST['try_noerror']; - $url_noerror=$_POST['url_noerror']; - $comment_noerror=$_POST['comment_noerror']; - $threadhold_total='0;0;0'; - - if ($try_noerror=='on') { - $try_str=1; - } else { - $try_str=0; - } - - if (empty($lp_noerror)) { - $lp_str=0; - } else { - $lp_str=$lp_noerror; - } - - if ($url_noerror=='') { - $url_str=''; - } else { - $url_str=$url_noerror; - } - - if ($select_question_noerror=='') { - $question_str=0; - } else { - $question_str=$select_question_noerror; - } - - $destination_noerror= $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str; - - if(empty($msgErr)) { - for($i=1;$i <= $nbrAnswers;$i++) { - if($debug>0){echo str_repeat(' ',4).'$answerType is HOT_SPOT'."
\n";} - - $reponse[$i]=trim($reponse[$i]); - $comment[$i]=trim($comment[$i]); - $weighting[$i]=($weighting[$i]); //it can be float - if($weighting[$i]) { - $questionWeighting+=$weighting[$i]; - } - // creates answer - $objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i],$destination[$i]); - } // end for() - - // saves the answers into the data base - - $objAnswer->createAnswer('noerror', '',$comment_noerror,'0',$nbrAnswers+1,null,'noerror',$destination_noerror); - $objAnswer->save(); - - // sets the total weighting of the question - $objQuestion->updateWeighting($questionWeighting); - $objQuestion->save($exerciseId); - - $editQuestion=$questionId; - unset($modifyAnswers); - - echo ''; - } - } + + if ($answerType == HOT_SPOT) { + + if ($debug > 0) { + echo '$submitAnswers or $buttonBack was set' . "
\n"; + } + $questionWeighting = $nbrGoodAnswers = 0; + for ($i = 1; $i <= $nbrAnswers; $i++) { + if ($debug > 0) { + echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; + } + + $reponse[$i] = trim($reponse[$i]); + $comment[$i] = trim($comment[$i]); + $weighting[$i] = $weighting[$i]; // it can be float + // checks if field is empty + if (empty($reponse[$i]) && $reponse[$i] != '0') { + $msgErr = get_lang('HotspotGiveAnswers'); + + // clears answers already recorded into the Answer object + $objAnswer->cancel(); + break; + } + + if ($weighting[$i] <= 0) { + $msgErr = get_lang('HotspotWeightingError'); + // clears answers already recorded into the Answer object + $objAnswer->cancel(); + break; + } + + if ($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { + $msgErr = get_lang('HotspotNotDrawn'); + // clears answers already recorded into the Answer object + $objAnswer->cancel(); + break; + } + } // end for() + + + if (empty($msgErr)) { + for ($i = 1; $i <= $nbrAnswers; $i++) { + if ($debug > 0) { + echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; + } + $reponse[$i] = trim($reponse[$i]); + $comment[$i] = trim($comment[$i]); + $weighting[$i] = ($weighting[$i]); //it can be float + if ($weighting[$i]) { + $questionWeighting+=$weighting[$i]; + } + // creates answer + $objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i]); + } // end for() + // saves the answers into the data base + $objAnswer->save(); + + // sets the total weighting of the question + $objQuestion->updateWeighting($questionWeighting); + $objQuestion->save($exerciseId); + + $editQuestion = $questionId; + unset($modifyAnswers); + echo ''; + } + if ($debug > 0) { + echo '$modifyIn was set - end' . "
\n"; + } + } else { + + if ($debug > 0) { + echo '$submitAnswers or $buttonBack was set' . "
\n"; + } + $questionWeighting = $nbrGoodAnswers = 0; + $select_question = $_POST['select_question']; + $try = $_POST['try']; + $url = $_POST['url']; + $destination = array(); + + $threadhold1 = $_POST['threadhold1']; + $threadhold2 = $_POST['threadhold2']; + $threadhold3 = $_POST['threadhold3']; + + for ($i = 1; $i <= $nbrAnswers; $i++) { + if ($debug > 0) { + echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; + } + + $reponse[$i] = trim($reponse[$i]); + $comment[$i] = trim($comment[$i]); + $weighting[$i] = $weighting[$i]; + + if (empty($threadhold1[$i])) + $threadhold1_str = 0; + else + $threadhold1_str = intval($threadhold1[$i]); + + if (empty($threadhold2[$i])) + $threadhold2_str = 0; + else + $threadhold2_str = intval($threadhold2[$i]); + + if (empty($threadhold3[$i])) + $threadhold3_str = 0; + else + $threadhold3_str = intval($threadhold3[$i]); + + $threadhold_total = $threadhold1_str . ';' . $threadhold2_str . ';' . $threadhold3_str; + //echo '
';print_r($_POST);echo '
'; + + if ($try[$i] == 'on') { + $try_str = 1; + } else { + $try_str = 0; + } + + if (empty($lp[$i])) { + $lp_str = 0; + } else { + $lp_str = $lp[$i]; + } + + if ($url[$i] == '') { + $url_str = ''; + } else { + $url_str = $url[$i]; + } + + if ($select_question[$i] == '') { + $question_str = 0; + } else { + $question_str = $select_question[$i]; + } + $destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; + + // the last answer is the IF NO ERROR section witch has not have the reponse, weight and coordinates values + //if ($i!=$nbrAnswers && !($answerType==HOT_SPOT_DELINEATION)) + // { + // checks if field is empty + if (empty($reponse[$i]) && $reponse[$i] != '0') { + $msgErr = get_lang('HotspotGiveAnswers'); + + // clears answers already recorded into the Answer object + $objAnswer->cancel(); + break; + } + + if ($weighting[$i] <= 0 && $_SESSION['tmp_answers']['hotspot_type'][$i] != 'oar') { + $msgErr = get_lang('HotspotWeightingError'); + // clears answers already recorded into the Answer object + $objAnswer->cancel(); + break; + } + + if ($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i])) { + $msgErr = get_lang('HotspotNotDrawn'); + // clears answers already recorded into the Answer object + $objAnswer->cancel(); + break; + } + } // end for() + //now the noerror section + $select_question_noerror = $_POST['select_question_noerror']; + $lp_noerror = $_POST['lp_noerror']; + $try_noerror = $_POST['try_noerror']; + $url_noerror = $_POST['url_noerror']; + $comment_noerror = $_POST['comment_noerror']; + $threadhold_total = '0;0;0'; + + if ($try_noerror == 'on') { + $try_str = 1; + } else { + $try_str = 0; + } + + if (empty($lp_noerror)) { + $lp_str = 0; + } else { + $lp_str = $lp_noerror; + } + + if ($url_noerror == '') { + $url_str = ''; + } else { + $url_str = $url_noerror; + } + + if ($select_question_noerror == '') { + $question_str = 0; + } else { + $question_str = $select_question_noerror; + } + + $destination_noerror = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; + + if (empty($msgErr)) { + for ($i = 1; $i <= $nbrAnswers; $i++) { + if ($debug > 0) { + echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; + } + + $reponse[$i] = trim($reponse[$i]); + $comment[$i] = trim($comment[$i]); + $weighting[$i] = ($weighting[$i]); //it can be float + if ($weighting[$i]) { + $questionWeighting+=$weighting[$i]; + } + // creates answer + $objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i], $destination[$i]); + } // end for() + // saves the answers into the data base + + $objAnswer->createAnswer('noerror', '', $comment_noerror, '0', $nbrAnswers + 1, null, 'noerror', $destination_noerror); + $objAnswer->save(); + + // sets the total weighting of the question + $objQuestion->updateWeighting($questionWeighting); + $objQuestion->save($exerciseId); + + $editQuestion = $questionId; + unset($modifyAnswers); + + echo ''; + } + } } if ($modifyAnswers) { - if($debug>0){echo str_repeat(' ',0).'$modifyAnswers is set'."
\n";} + if ($debug > 0) { + echo str_repeat(' ', 0) . '$modifyAnswers is set' . "
\n"; + } // construction of the Answer object - $objAnswer=new Answer($objQuestion -> id); - Session::write('objAnswer',$objAnswer); - if($debug>0){echo str_repeat(' ',2).'$answerType is HOT_SPOT'."
\n";} - - if ($answerType == HOT_SPOT_DELINEATION) { - $try=$_POST['try']; - - for($i=1;$i <= $nbrAnswers;$i++) { - if ($try[$i]=='on') { - $try[$i]=1; - } else { - $try[$i]=0; - } - } - - if ($_POST['try_noerror']=='on') { - $try_noerror=1; - } else { - $try_noerror=0; - } - } - - if(!$nbrAnswers) { - $nbrAnswers=$objAnswer->selectNbrAnswers(); - if ($answerType == HOT_SPOT_DELINEATION) { - // the magic happens here ... - // we do this to not count the if no error section - if ($nbrAnswers>=2) - $nbrAnswers--; + $objAnswer = new Answer($objQuestion->id); + Session::write('objAnswer', $objAnswer); + if ($debug > 0) { + echo str_repeat(' ', 2) . '$answerType is HOT_SPOT' . "
\n"; + } + + if ($answerType == HOT_SPOT_DELINEATION) { + $try = $_POST['try']; + + for ($i = 1; $i <= $nbrAnswers; $i++) { + if ($try[$i] == 'on') { + $try[$i] = 1; + } else { + $try[$i] = 0; + } } - $reponse=array(); - $comment=array(); - $weighting=array(); - $hotspot_coordinates=array(); - $hotspot_type=array(); - $destination_items = array(); - $destination = array(); + + if ($_POST['try_noerror'] == 'on') { + $try_noerror = 1; + } else { + $try_noerror = 0; + } + } + + if (!$nbrAnswers) { + $nbrAnswers = $objAnswer->selectNbrAnswers(); + if ($answerType == HOT_SPOT_DELINEATION) { + // the magic happens here ... + // we do this to not count the if no error section + if ($nbrAnswers >= 2) + $nbrAnswers--; + } + $reponse = array(); + $comment = array(); + $weighting = array(); + $hotspot_coordinates = array(); + $hotspot_type = array(); + $destination_items = array(); + $destination = array(); - for($i=1;$i <= $nbrAnswers;$i++) { - $reponse[$i]=$objAnswer->selectAnswer($i); + for ($i = 1; $i <= $nbrAnswers; $i++) { + $reponse[$i] = $objAnswer->selectAnswer($i); if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { - $comment[$i]=$objAnswer->selectComment($i); + $comment[$i] = $objAnswer->selectComment($i); + } + $weighting[$i] = $objAnswer->selectWeighting($i); + $hotspot_coordinates[$i] = $objAnswer->selectHotspotCoordinates($i); + $hotspot_type[$i] = $objAnswer->selectHotspotType($i); + + if ($answerType == HOT_SPOT_DELINEATION) { + $destination[$i] = $objAnswer->selectDestination($i); + + $destination_items = explode('@@', $destination[$i]); + $threadhold_total = $destination_items[0]; + $threadhold_items = explode(';', $threadhold_total); + $threadhold1[$i] = $threadhold_items[0]; + $threadhold2[$i] = $threadhold_items[1]; + $threadhold3[$i] = $threadhold_items[2]; + + $try[$i] = $destination_items[1]; + $lp[$i] = $destination_items[2]; + $select_question[$i] = $destination_items[3]; + $url[$i] = $destination_items[4]; } - $weighting[$i]=$objAnswer->selectWeighting($i); - $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i); - $hotspot_type[$i]=$objAnswer->selectHotspotType($i); - - if ($answerType==HOT_SPOT_DELINEATION) { - $destination[$i]=$objAnswer->selectDestination($i); - - $destination_items= explode('@@', $destination[$i]); - $threadhold_total = $destination_items[0]; - $threadhold_items=explode(';',$threadhold_total); - $threadhold1[$i] = $threadhold_items[0]; - $threadhold2[$i] = $threadhold_items[1]; - $threadhold3[$i] = $threadhold_items[2]; - - $try[$i]=$destination_items[1]; - $lp[$i]=$destination_items[2]; - $select_question[$i]=$destination_items[3]; - $url[$i]=$destination_items[4]; - } } } - - if ($answerType==HOT_SPOT_DELINEATION) { - //added the noerror answer - $reponse_noerror='noerror'; - $comment_noerror=$objAnswer->selectComment($nbrAnswers+1); - $destination_noerror_list=$objAnswer->selectDestination($nbrAnswers+1); - $destination_items= explode('@@', $destination_noerror_list); - - $try_noerror=$destination_items[1]; - $lp_noerror=$destination_items[2]; - $select_question_noerror=$destination_items[3]; - $url_noerror=$destination_items[4]; - } + + if ($answerType == HOT_SPOT_DELINEATION) { + //added the noerror answer + $reponse_noerror = 'noerror'; + $comment_noerror = $objAnswer->selectComment($nbrAnswers + 1); + $destination_noerror_list = $objAnswer->selectDestination($nbrAnswers + 1); + $destination_items = explode('@@', $destination_noerror_list); + + $try_noerror = $destination_items[1]; + $lp_noerror = $destination_items[2]; + $select_question_noerror = $destination_items[3]; + $url_noerror = $destination_items[4]; + } $_SESSION['tmp_answers'] = array(); $_SESSION['tmp_answers']['answer'] = $reponse; if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { - $_SESSION['tmp_answers']['comment'] = $comment; + $_SESSION['tmp_answers']['comment'] = $comment; } $_SESSION['tmp_answers']['weighting'] = $weighting; $_SESSION['tmp_answers']['hotspot_coordinates'] = $hotspot_coordinates; $_SESSION['tmp_answers']['hotspot_type'] = $hotspot_type; - if ($answerType==HOT_SPOT_DELINEATION) { - $_SESSION['tmp_answers']['destination'] = $destination; + if ($answerType == HOT_SPOT_DELINEATION) { + $_SESSION['tmp_answers']['destination'] = $destination; } if ($lessAnswers) { - if ($answerType==HOT_SPOT_DELINEATION) { - $lest_answer=1; - // At least 1 answer - if ($nbrAnswers > $lest_answer) { - $nbrAnswers--; - // Remove the last answer - $tmp = array_pop($_SESSION['tmp_answers']['answer']); - $tmp = array_pop($_SESSION['tmp_answers']['comment']); - $tmp = array_pop($_SESSION['tmp_answers']['weighting']); - $tmp = array_pop($_SESSION['tmp_answers']['hotspot_coordinates']); - $tmp = array_pop($_SESSION['tmp_answers']['hotspot_type']); - - if (is_array($_SESSION['tmp_answers']['destination'])) { - $tmp = array_pop($_SESSION['tmp_answers']['destination']); - } - - } else { - $msgErr=get_lang('MinHotspot'); - } - } else { - // At least 1 answer - if ($nbrAnswers > 1) { - $nbrAnswers--; - // Remove the last answer - $tmp = array_pop($_SESSION['tmp_answers']['answer']); - if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { - $tmp = array_pop($_SESSION['tmp_answers']['comment']); - } - $tmp = array_pop($_SESSION['tmp_answers']['weighting']); - $tmp = array_pop($_SESSION['tmp_answers']['hotspot_coordinates']); - $tmp = array_pop($_SESSION['tmp_answers']['hotspot_type']); - } else { - $msgErr=get_lang('MinHotspot'); - } - } + if ($answerType == HOT_SPOT_DELINEATION) { + $lest_answer = 1; + // At least 1 answer + if ($nbrAnswers > $lest_answer) { + $nbrAnswers--; + // Remove the last answer + $tmp = array_pop($_SESSION['tmp_answers']['answer']); + $tmp = array_pop($_SESSION['tmp_answers']['comment']); + $tmp = array_pop($_SESSION['tmp_answers']['weighting']); + $tmp = array_pop($_SESSION['tmp_answers']['hotspot_coordinates']); + $tmp = array_pop($_SESSION['tmp_answers']['hotspot_type']); + + if (is_array($_SESSION['tmp_answers']['destination'])) { + $tmp = array_pop($_SESSION['tmp_answers']['destination']); + } + } else { + $msgErr = get_lang('MinHotspot'); + } + } else { + // At least 1 answer + if ($nbrAnswers > 1) { + $nbrAnswers--; + // Remove the last answer + $tmp = array_pop($_SESSION['tmp_answers']['answer']); + if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { + $tmp = array_pop($_SESSION['tmp_answers']['comment']); + } + $tmp = array_pop($_SESSION['tmp_answers']['weighting']); + $tmp = array_pop($_SESSION['tmp_answers']['hotspot_coordinates']); + $tmp = array_pop($_SESSION['tmp_answers']['hotspot_type']); + } else { + $msgErr = get_lang('MinHotspot'); + } + } } if ($moreAnswers) { - if ($nbrAnswers < 12) { + if ($nbrAnswers < 12) { $nbrAnswers++; // Add a new answer - $_SESSION['tmp_answers']['answer'][]=''; + $_SESSION['tmp_answers']['answer'][] = ''; if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { - $_SESSION['tmp_answers']['comment'][]=''; + $_SESSION['tmp_answers']['comment'][] = ''; } - $_SESSION['tmp_answers']['weighting'][]='1'; - $_SESSION['tmp_answers']['hotspot_coordinates'][]='0;0|0|0'; - $_SESSION['tmp_answers']['hotspot_type'][]='square'; - $_SESSION['tmp_answers']['destination'][]=''; - } else { - $msgErr=get_lang('MaxHotspot'); - } + $_SESSION['tmp_answers']['weighting'][] = '1'; + $_SESSION['tmp_answers']['hotspot_coordinates'][] = '0;0|0|0'; + $_SESSION['tmp_answers']['hotspot_type'][] = 'square'; + $_SESSION['tmp_answers']['destination'][] = ''; + } else { + $msgErr = get_lang('MaxHotspot'); + } } - - if($moreOARAnswers) { - if ($nbrAnswers < 12) { + + if ($moreOARAnswers) { + if ($nbrAnswers < 12) { // Add a new answer $nbrAnswers++; - - $_SESSION['tmp_answers']['answer'][]=''; - $_SESSION['tmp_answers']['comment'][]=''; - $_SESSION['tmp_answers']['weighting'][]='1'; - $_SESSION['tmp_answers']['hotspot_coordinates'][]='0;0|0|0'; - $_SESSION['tmp_answers']['hotspot_type'][]='oar'; - $_SESSION['tmp_answers']['destination'][]=''; - } else { - $msgErr=get_lang('MaxHotspot'); - } + + $_SESSION['tmp_answers']['answer'][] = ''; + $_SESSION['tmp_answers']['comment'][] = ''; + $_SESSION['tmp_answers']['weighting'][] = '1'; + $_SESSION['tmp_answers']['hotspot_coordinates'][] = '0;0|0|0'; + $_SESSION['tmp_answers']['hotspot_type'][] = 'oar'; + $_SESSION['tmp_answers']['destination'][] = ''; + } else { + $msgErr = get_lang('MaxHotspot'); + } } - if($debug>0){echo str_repeat(' ',2).'$usedInSeveralExercises is untrue'."
\n";} - if($debug>0){echo str_repeat(' ',4).'$answerType is HOT_SPOT'."
\n";} - if ($answerType==HOT_SPOT_DELINEATION) { - $hotspot_colors = array("", "#4271B5", "#FE8E16", "#45C7F0", "#BCD631", "#D63173", "#D7D7D7", "#90AFDD", "#AF8640", "#4F9242", "#F4EB24", "#ED2024", "#3B3B3B"); + if ($debug > 0) { + echo str_repeat(' ', 2) . '$usedInSeveralExercises is untrue' . "
\n"; + } + if ($debug > 0) { + echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; + } + if ($answerType == HOT_SPOT_DELINEATION) { + $hotspot_colors = array("", "#4271B5", "#FE8E16", "#45C7F0", "#BCD631", "#D63173", "#D7D7D7", "#90AFDD", "#AF8640", "#4F9242", "#F4EB24", "#ED2024", "#3B3B3B"); } else { $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix) - "#4271B5", - "#FE8E16", - "#45C7F0", - "#BCD631", - "#D63173", - "#D7D7D7", - "#90AFDD", - "#AF8640", - "#4F9242", - "#F4EB24", - "#ED2024", - "#3B3B3B", - "#F7BDE2"); - } - - Display::tag('h3',get_lang('Question').": ".$questionName.' '.strip_tags(get_lang('HotspotChoose')).''); - if(!empty($msgErr)) { + "#4271B5", + "#FE8E16", + "#45C7F0", + "#BCD631", + "#D63173", + "#D7D7D7", + "#90AFDD", + "#AF8640", + "#4F9242", + "#F4EB24", + "#ED2024", + "#3B3B3B", + "#F7BDE2"); + } + + Display::tag('h3', get_lang('Question') . ": " . $questionName . ' ' . strip_tags(get_lang('HotspotChoose')) . ''); + if (!empty($msgErr)) { Display::display_normal_message($msgErr); //main API } -$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin='.$modifyAnswers. '&exerciseId='.$exerciseId; -?> + $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId; + ?> + +
+ + + + + + + + + + + +
+ " id="frm_exercise" name="frm_exercise"> - - - - - - - - - - - -
- " onclick="javascript:if(!confirm('')) return false;" > - * - * */ - //ie6 fix - if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') { - ?> - - - - - - - - - - - - - - - - - -
- - - - - - - - '.get_lang('Thresholds').''; ?> - - - selectFeedbackType()== EXERCISE_FEEDBACK_TYPE_DIRECT) {?> - - '.get_lang('Scenario').''; ?> - - - - - - - - get_flat_list(); //loading list of LPs - - for($i=1;$i <= $nbrAnswers; $i++) { - // is an delineation - if ($answerType==HOT_SPOT_DELINEATION) { - - $select_lp_id=array(); - $option_lp=''; - - // setting the LP - $is_selected = false; - foreach ($flat_list as $id => $details) { - $select_lp_id[$id] = $details['lp_name']; - $selected = ''; - if ($id==$lp[$i]) { - $is_selected = true; - $selected='selected="selected"'; - } - $option_lp.=''; - } - if ($is_selected) { - $option_lp = ''.$option_lp; - } else { - $option_lp = ''.$option_lp; - } - - //Feedback SELECT - $question_list=$objExercise->selectQuestionList(); - $option_feed=''; - $option_feed.=''; - - foreach ($question_list as $key=>$questionid) { - $selected=''; - $question = Question::read($questionid); - $val='Q'.$key.' :'.substrwords($question->selectTitle(),ICON_SIZE_SMALL); - $select_lp_id[$id] = $details['lp_name']; - if ($questionid==$select_question[$i]){ - $selected='selected="selected"'; - } - $option_feed.=''; - } - if ($select_question[$i]==-1) - $option_feed.=''; - else - $option_feed.=''; - - //-------- IF it is a delineation - - if ($_SESSION['tmp_answers']['hotspot_type'][$i]=='delineation') { - for($k=1;$k<=100;$k++) { - $selected1=$selected2=$selected3=''; - if ($k==$threadhold1[$i]) - $selected1='selected="selected"'; - if ($k==$threadhold2[$i]) - $selected2='selected="selected"'; - if ($k==$threadhold3[$i]) - $selected3='selected="selected"'; - $option1.=''; - $option2.=''; - $option3.=''; - } - - ?> - - - - - - - - selectFeedbackType()== EXERCISE_FEEDBACK_TYPE_DIRECT) {?> - - - - - - - - - - - - - - - selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {?> - - - - - - - - - - - selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {?> - - - - - - - - - - - - - - - - - selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> - - - - - - - - - - ToolbarSet = 'TestProposedAnswer'; - $oFCKeditor->Config['ToolbarStartExpanded'] = 'false'; - $oFCKeditor->Width = '100%'; - $oFCKeditor->Height = '100'; - $oFCKeditor->Value = $content; - $return = $oFCKeditor->CreateHtml(); - /**/ - ?> - - - - - - get_flat_list(); - $select_lp_id=array(); - $option_lp=''; - //$option_lp.=''; - foreach ($flat_list as $id => $details) { - $selected = ''; - $select_lp_id[$id] = $details['lp_name']; - if ($id==$lp_noerror) { - $selected='selected="selected"'; - $is_selected = true; - } - $option_lp.=''; - } - - if ($is_selected) { - $option_lp = ''.$option_lp; - } else { - $option_lp = ''.$option_lp; - } - - //Feedback SELECT - - $question_list=$objExercise->selectQuestionList(); - $option_feed=''; - $option_feed.=''; - foreach ($question_list as $key=>$questionid) - { - $selected=''; - $question = Question::read($questionid); - $val='Q'.$key.' :'.substrwords($question->selectTitle(),ICON_SIZE_SMALL); - $select_lp_id[$id] = $details['lp_name']; - if ($questionid==$select_question_noerror){ - $selected='selected="selected"'; - } - $option_feed.=''; - } - if ($select_question_noerror==-1) - $option_feed.=''; - else - $option_feed.=''; - - if ($answerType==HOT_SPOT_DELINEATION) { - ?> - - - selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> - - - - - - - - - - - - selectFeedbackType()== EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> - - - - - - - -
  * *
-
- -
-

-

-

-

-
-

- % -

- % -

- % -
-
-
- - - -
- -
- - - - - -
- /> - -

- -
- - - -

-
- -

-
- - - -
-
 
- - - - - - - - - - - - -
- /> - -

- -
- -

- -
- -

-
- -
-
 
 * 
-
-
- - - - - - - - - - -
- /> - -

- -
- -

-
- -

-
- - -
-
  -
-
- -   - - - - - - - - - -
 
- - - - - - - - -
- /> - -

-
- -

- -
- -

-
- -
-
  
-
- -
- -0){echo str_repeat(' ',0).'$modifyAnswers was set - end'."
\n";} + /* + * + * + * */ + //ie6 fix + if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') { + ?> + + + + + + + + + + + + + + + + + +
+ + + + + + + + ' . get_lang('Thresholds') . ''; ?> + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + ' . get_lang('Scenario') . ''; ?> + + + + + + + + get_flat_list(); //loading list of LPs + + for ($i = 1; $i <= $nbrAnswers; $i++) { + // is an delineation + if ($answerType == HOT_SPOT_DELINEATION) { + + $select_lp_id = array(); + $option_lp = ''; + + // setting the LP + $is_selected = false; + foreach ($flat_list as $id => $details) { + $select_lp_id[$id] = $details['lp_name']; + $selected = ''; + if ($id == $lp[$i]) { + $is_selected = true; + $selected = 'selected="selected"'; + } + $option_lp.=''; + } + if ($is_selected) { + $option_lp = '' . $option_lp; + } else { + $option_lp = '' . $option_lp; + } + + //Feedback SELECT + $question_list = $objExercise->selectQuestionList(); + $option_feed = ''; + $option_feed.=''; + + foreach ($question_list as $key => $questionid) { + $selected = ''; + $question = Question::read($questionid); + $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); + $select_lp_id[$id] = $details['lp_name']; + if ($questionid == $select_question[$i]) { + $selected = 'selected="selected"'; + } + $option_feed.=''; + } + if ($select_question[$i] == -1) + $option_feed.=''; + else + $option_feed.=''; + + //-------- IF it is a delineation + + if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'delineation') { + for ($k = 1; $k <= 100; $k++) { + $selected1 = $selected2 = $selected3 = ''; + if ($k == $threadhold1[$i]) + $selected1 = 'selected="selected"'; + if ($k == $threadhold2[$i]) + $selected2 = 'selected="selected"'; + if ($k == $threadhold3[$i]) + $selected3 = 'selected="selected"'; + $option1.=''; + $option2.=''; + $option3.=''; + } + ?> + + + + + + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + + + + + + + + + + + + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + + + + + + + + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + + + + + + + + + + + + + + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + + + + + + + + + ToolbarSet = 'TestProposedAnswer'; + $oFCKeditor->Config['ToolbarStartExpanded'] = 'false'; + $oFCKeditor->Width = '100%'; + $oFCKeditor->Height = '100'; + $oFCKeditor->Value = $content; + $return = $oFCKeditor->CreateHtml(); + /* */ + ?> + + + + + + get_flat_list(); + $select_lp_id = array(); + $option_lp = ''; + //$option_lp.=''; + foreach ($flat_list as $id => $details) { + $selected = ''; + $select_lp_id[$id] = $details['lp_name']; + if ($id == $lp_noerror) { + $selected = 'selected="selected"'; + $is_selected = true; + } + $option_lp.=''; + } + + if ($is_selected) { + $option_lp = '' . $option_lp; + } else { + $option_lp = '' . $option_lp; + } + + //Feedback SELECT + + $question_list = $objExercise->selectQuestionList(); + $option_feed = ''; + $option_feed.=''; + foreach ($question_list as $key => $questionid) { + $selected = ''; + $question = Question::read($questionid); + $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); + $select_lp_id[$id] = $details['lp_name']; + if ($questionid == $select_question_noerror) { + $selected = 'selected="selected"'; + } + $option_feed.=''; + } + if ($select_question_noerror == -1) + $option_feed.=''; + else + $option_feed.=''; + + if ($answerType == HOT_SPOT_DELINEATION) { + ?> + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + + + + + + + + + + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> + + + + + + + +
  * *
+
+ +
+

+

+

+

+
+

+ % +

+ % +

+ % +
+
+
+ + + +
+ +
+ + + + + +
+ /> + +

+ +
+ + + +

+
+ +

+
+ + + +
+
 
+ + + + + + + + + + + + +
+ /> + +

+ +
+ +

+ +
+ +

+
+ +
+
 
 * 
+
+
+ + + + + + + + + + +
+ /> + +

+ +
+ +

+
+ +

+
+ + +
+
  +
+
+ +   + + + + + + + + + +
 
+ + + + + + + + +
+ /> + +

+
+ +

+ +
+ +

+
+ +
+
  
+
+ +
+ + 0) { + echo str_repeat(' ', 0) . '$modifyAnswers was set - end' . "
\n"; + } } From 507e93671fd51f4168be6dbc1747c9c5aaa96e24 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 15 Oct 2012 15:34:14 +0200 Subject: [PATCH 123/124] Adding security::remove_XSS see #3919 --- main/exercice/hotspot_admin.inc.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php index 89a62fff56..a942669d1a 100644 --- a/main/exercice/hotspot_admin.inc.php +++ b/main/exercice/hotspot_admin.inc.php @@ -86,7 +86,6 @@ if ($submitAnswers || $buttonBack) { if ($debug > 0) { echo str_repeat(' ', 4) . '$answerType is HOT_SPOT' . "
\n"; } - $reponse[$i] = trim($reponse[$i]); $comment[$i] = trim($comment[$i]); $weighting[$i] = $weighting[$i]; // it can be float @@ -114,7 +113,6 @@ if ($submitAnswers || $buttonBack) { } } // end for() - if (empty($msgErr)) { for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { @@ -236,6 +234,7 @@ if ($submitAnswers || $buttonBack) { break; } } // end for() + //now the noerror section $select_question_noerror = $_POST['select_question_noerror']; $lp_noerror = $_POST['lp_noerror']; @@ -560,8 +559,6 @@ if ($modifyAnswers) {   * ' . get_lang('Thresholds') . ''; ?> - - selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> ' . get_lang('Scenario') . ''; ?> @@ -728,7 +725,7 @@ if ($modifyAnswers) { - + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> @@ -789,11 +786,11 @@ if ($modifyAnswers) { - + - + @@ -836,7 +833,7 @@ if ($modifyAnswers) {
- + - + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> @@ -980,7 +977,7 @@ if ($modifyAnswers) { -