diff --git a/documentation/changelog.html b/documentation/changelog.html index 1b0efb83f3..dcf47a4913 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -61,6 +61,119 @@
  • +

    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

    +

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

    + +

    Release name

    +

    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

    + +

    Improvements

    + +

    Debugging

    + +

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

    Release notes - summary

    diff --git a/documentation/credits.html b/documentation/credits.html index 82d84f38a8..04b3a8116d 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

    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 diff --git a/main/admin/add_courses_to_usergroup.php b/main/admin/add_courses_to_usergroup.php index 4b8adc4d71..bce7881345 100644 --- a/main/admin/add_courses_to_usergroup.php +++ b/main/admin/add_courses_to_usergroup.php @@ -102,9 +102,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'].")"; } } } @@ -152,7 +152,7 @@ function search($needle,$type) { foreach ($list as $row ) { if (!in_array($row['id'], array_keys($elements_in))) { - $return .= ''; + $return .= ''; } } $return .= ''; diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index b4d505f6c2..2877dc580f 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(strip_tags($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(strip_tags($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', strip_tags(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/admin/course_category.php b/main/admin/course_category.php index b6f48d9059..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 = ''; + ?> + + + + + + +
    + + + + + +Display::display_footer(); - +/* * ****** Functions ******* */ - - - -
    - + $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 = CourseManager::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 = CourseManager::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 diff --git a/main/admin/index.php b/main/admin/index.php index 3334671628..3d15c58bca 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) ? '?' : ''; diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 987379734f..1bb37e2c81 100644 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -210,19 +210,20 @@ function handle_stylesheets() { echo '
    '; } - $form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=stylesheets&showuploadform=true'); + $form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets&showuploadform=true'); $form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); $form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet')); - $allowed_file_types = array('css', 'zip', 'jpeg', 'jpg', 'png', 'gif'); + $allowed_file_types = array('css', 'zip', 'jpeg', 'jpg', 'png', 'gif', 'ico'); + $form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types); $form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class'=>'save')); if ($form->validate() && is_writable(api_get_path(SYS_CODE_PATH).'css/')) { $values = $form->exportValues(); - $picture_element = & $form->getElement('new_stylesheet'); + $picture_element = $form->getElement('new_stylesheet'); $picture = $picture_element->getValue(); - $result = upload_stylesheet($values, $picture); + $result = upload_stylesheet($values, $picture); // Add event to the system log. $user_id = api_get_user_id(); @@ -351,7 +352,7 @@ function upload_stylesheet($values, $picture) { $file = $zip->statIndex($i); if (substr($file['name'], -1) != '/') { $path_parts = pathinfo($file['name']); - if (!in_array($path_parts['extension'], array('jpg', 'jpeg', 'png', 'gif', 'css'))) { + if (!in_array($path_parts['extension'], array('jpg', 'jpeg', 'png', 'gif', 'css', 'ico'))) { $valid = false; $invalid_files[] = $file['name']; } 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/admin/usergroup_export.php b/main/admin/usergroup_export.php index a8f8f1ec0d..96d78f9cc9 100644 --- a/main/admin/usergroup_export.php +++ b/main/admin/usergroup_export.php @@ -33,9 +33,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(); diff --git a/main/admin/usergroup_user_import.php b/main/admin/usergroup_user_import.php index 231be401c2..9ad5d4104c 100644 --- a/main/admin/usergroup_user_import.php +++ b/main/admin/usergroup_user_import.php @@ -1,69 +1,69 @@ $user_class) { $user_class['line'] = $index + 1; // 1. Check whether mandatory fields are set. - $mandatory_fields = array ('UserName', 'ClassName'); - - foreach ($mandatory_fields as $key => $field) { - if (!isset ($user_class[$field]) || strlen($user_class[$field]) == 0) { - $user_class['error'] = get_lang($field.'Mandatory'); + $mandatory_fields = array('UserName', 'ClassName'); + + foreach ($mandatory_fields as $key => $field) { + if (!isset($user_class[$field]) || strlen($user_class[$field]) == 0) { + $user_class['error'] = get_lang($field . 'Mandatory'); $errors[] = $user_class; } } - + // 2. Check whether classcode exists. - if (isset ($user_class['ClassName']) && strlen($user_class['ClassName']) != 0) { + if (isset($user_class['ClassName']) && strlen($user_class['ClassName']) != 0) { // 2.1 Check whether code has been allready used in this CVS-file. - if (!isset ($classcodes[$user_class['ClassName']])) { + if (!isset($classcodes[$user_class['ClassName']])) { // 2.1.1 Check whether code exists in DB - $exists = $usergroup->usergroup_exists($user_class['ClassName']); + $exists = $usergroup->usergroup_exists($user_class['ClassName']); if (!$exists) { - $user_class['error'] = get_lang('CodeDoesNotExists').': '.$user_class['ClassName']; + $user_class['error'] = get_lang('CodeDoesNotExists') . ': ' . $user_class['ClassName']; $errors[] = $user_class; } else { $classcodes[$user_class['CourseCode']] = 1; } } } - + // 3. Check username, first, check whether it is empty. if (!UserManager::is_username_empty($user_class['UserName'])) { // 3.1. Check whether username is too long. if (UserManager::is_username_too_long($user_class['UserName'])) { - $user_class['error'] = get_lang('UserNameTooLong').': '.$user_class['UserName']; + $user_class['error'] = get_lang('UserNameTooLong') . ': ' . $user_class['UserName']; $errors[] = $user_class; } - - $username = UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames); + + $username = UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames); // 3.2. Check whether username exists. if (UserManager::is_username_available($username)) { - $user_class['error'] = get_lang('UnknownUser').': '.$username; + $user_class['error'] = get_lang('UnknownUser') . ': ' . $username; $errors[] = $user_class; } } @@ -79,21 +79,22 @@ function save_data($users_classes) { global $purification_option_for_usernames; // Table definitions. - $user_table = Database :: get_main_table(TABLE_MAIN_USER); - + $user_table = Database :: get_main_table(TABLE_MAIN_USER); + $usergroup = new UserGroup(); - + // Data parsing: purification + conversion (UserName, ClassName) --> (user_is, class_id) - $csv_data = array (); + $csv_data = array(); if (!empty($users_classes)) { + foreach ($users_classes as $user_class) { - $sql1 = "SELECT user_id FROM $user_table WHERE username = '".Database::escape_string(UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames))."'"; + $sql1 = "SELECT user_id FROM $user_table WHERE username = '" . Database::escape_string(UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames)) . "'"; $res1 = Database::query($sql1); $obj1 = Database::fetch_object($res1); $usergroup = new UserGroup(); - $id = $usergroup->get_id_by_name($user_class['ClassName']); - + $id = $usergroup->get_id_by_name($user_class['ClassName']); + if ($obj1 && $id) { $csv_data[$id]['user_list'][] = $obj1->user_id; $csv_data[$id]['user_list_name'][] = $user_class['UserName']; @@ -101,51 +102,20 @@ function save_data($users_classes) { } } } - + // Logic for processing the request (data + UI options). - - if (!empty($csv_data)) { + $message = null; + if (!empty($csv_data)) { foreach ($csv_data as $class_id => $user_data) { $user_list = $user_data['user_list']; - $class_name = $user_data['class_name']; $user_list_name = $user_data['user_list_name']; - $usergroup->subscribe_users_to_usergroup($class_id, $user_list); - - /* - $sql = "SELECT class_id FROM $class_user_table cu WHERE cu.user_id = $user_id"; - $res = Database::query($sql); - while ($obj = Database::fetch_object($res)) { - $db_subscriptions[$obj->class_id] = 1; - } - $to_subscribe = array_diff(array_keys($csv_subscriptions), array_keys($db_subscriptions)); - $to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csv_subscriptions)); - - // Subscriptions for new classes. - if ($_POST['subscribe']) { - foreach ($to_subscribe as $class_id) { - ClassManager::add_user($user_id, $class_id); - } - } - // Unsubscription from previous classes. - if ($_POST['unsubscribe']) { - foreach ($to_unsubscribe as $class_id) { - ClassManager::unsubscribe_user($user_id, $class_id); - } - }*/ - $message = Display::return_message(get_lang('Class').': '.$class_name.'
    ', 'normal', false); - $message .= Display::return_message(get_lang('Users').': '.implode(', ', $user_list_name)); - - return $message; - + $message .= Display::return_message(get_lang('Class') . ': ' . $class_name . '
    ', 'normal', false); + $message .= Display::return_message(get_lang('Users') . ': ' . implode(', ', $user_list_name)); } - } - - - - - + } + return $message; } /** @@ -166,10 +136,13 @@ require_once '../inc/global.inc.php'; $this_section = SECTION_PLATFORM_ADMIN; api_protect_admin_script(true); -$tool_name = get_lang('AddUsersToAClass').' CSV'; +require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php'; +require_once api_get_path(LIBRARY_PATH) . 'import.lib.php'; + +$tool_name = get_lang('AddUsersToAClass') . ' CSV'; -$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); -$interbreadcrumb[] = array ('url' => 'usergroups.php', 'name' => get_lang('Classes')); +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); // Set this option to true to enforce strict purification for usenames. $purification_option_for_usernames = false; @@ -185,9 +158,9 @@ $form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="s if ($form->validate()) { $users_classes = parse_csv_data($_FILES['import_file']['tmp_name']); - $errors = validate_data($users_classes); - if (count($errors) == 0) { - $return = save_data($users_classes); + $errors = validate_data($users_classes); + if (count($errors) == 0) { + $return = save_data($users_classes); } } @@ -200,7 +173,7 @@ if (isset($return) && $return) { if (count($errors) != 0) { $error_message = "\n"; foreach ($errors as $index => $error_class_user) { - $error_message .= get_lang('Line').' '.$error_class_user['line'].': '.$error_class_user['error'].''; + $error_message .= get_lang('Line') . ' ' . $error_class_user['line'] . ': ' . $error_class_user['error'] . ''; $error_message .= "
    "; } $error_message .= "\n"; @@ -208,7 +181,7 @@ if (count($errors) != 0) { } $form->display(); ?> -

    :

    +

    :

     UserName;ClassName
     jdoe;class01
    diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php
    index 608aa809d4..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);
    @@ -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/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
    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
    +}
    diff --git a/main/auth/profile.php b/main/auth/profile.php
    index 6086c53b7f..954b25dd37 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,11 +34,11 @@ $htmlHeadXtra[] = 'validate()) {
     
     	//change email
     	if ($allow_users_to_change_email_with_no_password) {	    
    -        if (!empty($changeemail) && in_array('email', $available_values_to_modify)) {
    +        if (in_array('email', $available_values_to_modify)) {
                 $sql .= " email = '".Database::escape_string($changeemail)."',";
             }
             if (isset($password) && in_array('password', $available_values_to_modify)) {
    @@ -593,9 +593,7 @@ if ($form->validate()) {
             if (!empty($changeemail) && !isset($password) && in_array('email', $available_values_to_modify)) {
                 $sql .= " email = '".Database::escape_string($changeemail)."'";
             } elseif (isset($password) && isset($changeemail) && in_array('email', $available_values_to_modify) && in_array('password', $available_values_to_modify)) {            
    -            if (!empty($changeemail)) {
    -                $sql .= " email = '".Database::escape_string($changeemail)."',";
    -            }
    +            $sql .= " email = '".Database::escape_string($changeemail)."',";
                 $password = api_get_encrypted_password($password);
                 $sql .= " password = '".Database::escape_string($password)."'";
             } elseif (isset($password) && in_array('password', $available_values_to_modify)) {
    @@ -605,6 +603,9 @@ if ($form->validate()) {
                 // remove trailing , from the query we have so far
                 $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);
    diff --git a/main/course_progress/thematic_controller.php b/main/course_progress/thematic_controller.php
    index dfdd9b5b15..a5c292046b 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,306 @@ 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) { + $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_LONG) . ' ('.$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 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/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 8e64208493..8ae8604e62 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 "; @@ -326,6 +326,7 @@ class CourseBuilder { $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); 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/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 diff --git a/main/css/base.css b/main/css/base.css index a9b5cc2887..ce27eb8100 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -2660,11 +2660,10 @@ div.admin_section h4 { .ribbon h5 { display: block; - height: 30px; - line-height: 1.3; - width: 120px; + height: 30px; + width: 150px; margin: 0; - padding: 15px 10px; + padding: 15px 0px; position: absolute; right: 0px; top: 0px; diff --git a/main/document/document.inc.php b/main/document/document.inc.php index bcccdfc611..8d9eb3a0c1 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); + } } } } @@ -224,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 1c85bc5fe8..e0931aad8c 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(); @@ -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'); @@ -1114,8 +1114,8 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) { // Last edit date - $last_edit_date = api_get_local_time($document_data['lastedit_date']); - $display_date = date_to_str_ago($last_edit_date); + $last_edit_date = api_get_local_time($document_data['lastedit_date']); + $display_date = date_to_str_ago($last_edit_date).'
    '.$last_edit_date."
    "; $row[] = $invisibility_span_open.$display_date.$invisibility_span_close; // Admins get an edit column @@ -1232,7 +1232,7 @@ if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($docs_and $table->set_header($column++, get_lang('Type'), true, array('style' => 'width:30px;')); $table->set_header($column++, get_lang('Name')); $table->set_header($column++, get_lang('Size'), true, array('style' => 'width:50px;')); -$table->set_header($column++, get_lang('Date'), true, array('style' => 'width:105px;')); +$table->set_header($column++, get_lang('Date'), true, array('style' => 'width:150px;')); // Admins get an edit column if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) { $table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions')); 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.class.php b/main/exercice/exercise.class.php index 19267b34d7..a6fe8b2683 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -745,6 +745,7 @@ class Exercise { // insert into the item_property table api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizAdded', api_get_user_id()); api_set_default_visibility($this->id, TOOL_QUIZ); + if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { $this->search_engine_save(); } @@ -1244,7 +1245,7 @@ class Exercise { } $course_id = api_get_course_id(); - require_once api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php'; + require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; @@ -1280,7 +1281,7 @@ class Exercise { $exercise_description = $all_specific_terms .' '. $this->description; $ic_slide->addValue("content", $exercise_description); - $di = new DokeosIndexer(); + $di = new ChamiloIndexer(); isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; $di->connectDb(NULL, NULL, $lang); $di->addChunk($ic_slide); @@ -1310,7 +1311,7 @@ class Exercise { $res = Database::query($sql); if (Database::num_rows($res) > 0) { - require_once(api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php'); + require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'); @@ -1346,7 +1347,7 @@ class Exercise { $exercise_description = $all_specific_terms .' '. $this->description; $ic_slide->addValue("content", $exercise_description); - $di = new DokeosIndexer(); + $di = new ChamiloIndexer(); isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; $di->connectDb(NULL, NULL, $lang); $di->remove_document((int)$se_ref['search_did']); @@ -1381,8 +1382,8 @@ class Exercise { $res = Database::query($sql); if (Database::num_rows($res) > 0) { $row = Database::fetch_array($res); - require_once(api_get_path(LIBRARY_PATH) .'search/DokeosIndexer.class.php'); - $di = new DokeosIndexer(); + require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php'); + $di = new ChamiloIndexer(); $di->remove_document((int)$row['search_did']); unset($di); $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); @@ -3396,7 +3397,7 @@ class Exercise { //Checking visibility in the item_property table $visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id()); - + if ($visibility == 0) { $this->active = 0; } @@ -3457,11 +3458,7 @@ class Exercise { } return array('value' => $is_visible, 'message' => $message); } - - function save_attempt() { - - } - + function added_in_lp() { $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); $sql = "SELECT max_score FROM $TBL_LP_ITEM WHERE c_id = ".$this->course_id." AND item_type = '".TOOL_QUIZ."' AND path = '".$this->id."'"; diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 3688c724e3..2ebb1b4cc0 100644 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -46,7 +46,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu $answerType = $objQuestionTmp->selectType(); $pictureName = $objQuestionTmp->selectPicture(); - $html = ''; if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) { // Question is not a hotspot @@ -388,39 +387,45 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu } elseif ($answerType == FILL_IN_BLANKS) { list($answer) = explode('::', $answer); - - api_preg_match_all('/\[[^]]+\]/', $answer, $teacher_answer_list); - + + //Correct answer + api_preg_match_all('/\[[^]]+\]/', $answer, $correct_answer_list); + + //Student's answezr if (isset($user_choice[0]['answer'])) { api_preg_match_all('/\[[^]]+\]/', $user_choice[0]['answer'], $student_answer_list); $student_answer_list = $student_answer_list[0]; } - if ($debug_mark_answer) { - $student_answer_list = $teacher_answer_list[0]; + //If debug + if ($debug_mark_answer) { + $student_answer_list = $correct_answer_list[0]; } - if (!empty($teacher_answer_list) && !empty($student_answer_list)) { - $teacher_answer_list = $teacher_answer_list[0]; + if (!empty($correct_answer_list) && !empty($student_answer_list)) { + $correct_answer_list = $correct_answer_list[0]; $i = 0; - foreach ($teacher_answer_list as $teacher_item) { + foreach ($correct_answer_list as $correct_item) { $value = null; if (isset($student_answer_list[$i]) && !empty($student_answer_list[$i])) { + //Cleaning student answer list - $value = strip_tags($student_answer_list[$i]); - $value = api_substr($value,1, api_strlen($value)-2); + $value = strip_tags($student_answer_list[$i]); + $value = api_substr($value, 1, api_strlen($value)-2); $value = explode('/', $value); - if (!empty($value[0])) { - $value = trim($value[0]); - $value = str_replace(' ', '', $value); - } - $answer = api_preg_replace('/\['.$teacher_item.'+\]/', Display::input('text', "choice[$questionId][]", $value), $answer); - } + + if (!empty($value[0])) { + $value = str_replace(' ', '', trim($value[0])); + } + $correct_item = preg_quote($correct_item); + $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer); + //$answer = api_preg_replace('/\['.$correct_item.'+\]/', Display::input('text', "choice[$questionId][]", $value), $answer); + } $i++; } - } else { + } else { $answer = api_preg_replace('/\[[^]]+\]/', Display::input('text', "choice[$questionId][]", '', $attributes), $answer); - } + } $s .= ''.$answer.''; } elseif ($answerType == MATCHING) { // matching type, showing suggestions and answers @@ -2089,7 +2094,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu $total_score += $result['score']; $total_weight += $result['weight']; - $question_list_answers[] = array('question' => $result['open_question'], 'answer' => $result['open_answer']); + $question_list_answers[] = array('question' => $result['open_question'], 'answer' => $result['open_answer']); $my_total_score = $result['score']; $my_total_weight = $result['weight']; @@ -2172,10 +2177,8 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu } } - echo $total_score_text; - - echo $exercise_content; - + echo $total_score_text; + echo $exercise_content; if (!$show_only_score) { echo $total_score_text; } diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index aef615e423..5a4ea7648f 100644 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -27,7 +27,7 @@ if(!api_is_allowed_to_edit(null,true)) { api_not_allowed(true); } -$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/exercise_report.php b/main/exercice/exercise_report.php index 8aed804efc..2bc1dfbe2b 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -27,7 +27,6 @@ $htmlHeadXtra[] = api_get_jqgrid_js(); // Access control api_protect_course_script(true, false, true); - // including additional libraries require_once 'exercise.class.php'; require_once 'exercise.lib.php'; @@ -59,11 +58,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)) @@ -108,17 +107,15 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G } $test = $track_exercise_info['title']; $student_id = $track_exercise_info['exe_user_id']; - $session_id = $track_exercise_info['session_id']; $lp_id = $track_exercise_info['orig_lp_id']; //$lp_item_id = $track_exercise_info['orig_lp_item_id']; $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id']; + + $course_info = api_get_course_info(); // Teacher data - $teacher_info = api_get_user_info(api_get_user_id()); - $user_info = api_get_user_info($student_id); - $student_email = $user_info['mail']; - $from = $teacher_info['mail']; + $teacher_info = api_get_user_info(api_get_user_id()); $from_name = api_get_person_name($teacher_info['firstname'], $teacher_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&id_session='.$session_id.'&exerciseId='.$exercise_id; @@ -157,7 +154,7 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G $result =Database::query($sql); Database::result($result,0,"question"); - $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks',teacher_comment = '$my_comments' WHERE question_id = ".$my_questionid." AND exe_id=".$id; + $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks', teacher_comment = '$my_comments' WHERE question_id = ".$my_questionid." AND exe_id=".$id; Database::query($query); //Saving results in the track recording table @@ -175,26 +172,27 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".floatval($tot)."' WHERE exe_id = ".$id; Database::query($totquery); + + if (isset($_POST['send_notification'])) { + //@todo move this somewhere else + $subject = get_lang('ExamSheetVCC'); + + $message = '

    '.get_lang('DearStudentEmailIntroduction') . '

    '.get_lang('AttemptVCC'); + $message .= '

    '.get_lang('CourseName'). '

    '.Security::remove_XSS($course_info['name']).''; + $message .= '

    '.get_lang('Exercise') . '

    '.Security::remove_XSS($test); + + //Only for exercises not in a LP + if ($lp_id == 0) { + $message .= '

    '.get_lang('ClickLinkToViewComment') . ' #url#
    '; + } - //@todo move this somewhere else - $subject = get_lang('ExamSheetVCC'); - - $message = '

    '.get_lang('DearStudentEmailIntroduction') . '

    '.get_lang('AttemptVCC'); - $message .= '

    '.get_lang('CourseName'). '

    '.Security::remove_XSS($course_info['name']).''; - $message .= '

    '.get_lang('Exercise') . '

    '.Security::remove_XSS($test); - - //Only for exercises not in a LP - if ($lp_id == 0) { - $message .= '

    '.get_lang('ClickLinkToViewComment') . ' #url#
    '; + $message .= '

    '.get_lang('Regards').'

    '; + $message .= $from_name; + $message = str_replace("#test#", Security::remove_XSS($test), $message); + $message = str_replace("#url#", $url, $message); + MessageManager::send_message_simple($student_id, $subject, $message, api_get_user_id()); } - - $message .= '

    '.get_lang('Regards').'

    '; - $message .= $from_name; - - $message = str_replace("#test#", Security::remove_XSS($test), $message); - $message = str_replace("#url#", $url, $message); - - @api_mail_html($student_email, $student_email, $subject, $message, $from_name, $from, array('charset'=>api_get_system_encoding())); + //Updating LP score here if (in_array($origin, array ('tracking_course','user_course','correct_exercise_in_lp'))) { @@ -258,7 +256,7 @@ Display :: display_header($nameTools); $actions = Display::div($actions, array('class'=> 'actions')); -$extra = ' -
    + - +
    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='', $hotpotato_name) { + global $charset; + $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').';'; + } + } + $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('Score').';'; + $data .= get_lang('Total').';'; + $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['exe_date']).';'; + $data .= str_replace("\r\n",' ',$row['result']).';'; + $data .= str_replace("\r\n",' ',$row['max']).';'; + $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'); + // @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; + } + + /** + * 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 diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php index 8b1ee6aa4d..bd661b9ef0 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,948 @@ 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 ($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() - 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 ''; - } - } + //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; -?> - -
    - - - - - - - - - - - -
    - " 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";} -} + $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId; + ?> + +
    + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + ' . 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"; + } +} \ No newline at end of file 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/exercice/question.class.php b/main/exercice/question.class.php index f163f66787..bc82dcd9fc 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -781,10 +781,10 @@ abstract class Question $res = Database::query($sql); if (Database::num_rows($res) > 0 || $addQs) { - require_once(api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php'); + require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); - $di = new DokeosIndexer(); + $di = new ChamiloIndexer(); if ($addQs) { $question_exercises = array((int)$exerciseId); } else { @@ -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.''; } @@ -1395,8 +1395,9 @@ abstract class Question } } - $question_title = get_lang("Question").' '.($counter_label).' : '.$this->question; - $header = Display::div('

    '.$score_label.'

    '.$question_title.'

    '.$score['result'].'
    ', array('class'=>'ribbon')); + $question_title = $this->question; + $header = Display::div('

    '.$score_label.'

    '.get_lang("Question").' '.($counter_label).'

    '.$score['result'].'
    ', array('class'=>'ribbon')); + $header .= ''; $header .= Display::div($this->description, array('id'=>'question_description')); return $header; } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index c3a5c68ee3..36d8fed169 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -199,11 +199,9 @@ function show_add_forum_form($inputvalues = array(), $lp_id) { // The title of the forum $form->addElement('text', 'forum_title', get_lang('Title'),'class="input_titles" id="forum_title"'); - //$form->applyFilter('forum_title', 'html_filter'); // The comment of the forum. $form->addElement('html_editor', 'forum_comment', get_lang('Description'), null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200')); - //$form->applyFilter('forum_comment', 'html_filter'); // Dropdown list: Forum categories $forum_categories = get_forum_categories(); foreach ($forum_categories as $key => $value) { @@ -212,74 +210,42 @@ function show_add_forum_form($inputvalues = array(), $lp_id) { $form->addElement('select', 'forum_category', get_lang('InForumCategory'), $forum_categories_titles); $form->applyFilter('forum_category', 'html_filter'); - if ($_course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) { - // This is for vertical - //$form->addElement('radio', 'allow_anonymous', get_lang('AllowAnonymousPosts'), get_lang('Yes'), 1); - //$form->addElement('radio', 'allow_anonymous', '', get_lang('No'), 0); + if ($_course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) { // This is for horizontal - $group = ''; + $group = array(); $group[] =$form->createElement('radio', 'allow_anonymous', null, get_lang('Yes'), 1); $group[] =$form->createElement('radio', 'allow_anonymous', null, get_lang('No'), 0); $form->addGroup($group, 'allow_anonymous_group', get_lang('AllowAnonymousPosts'), ' '); } - - // This is for vertical. - //$form->addElement('radio', 'students_can_edit', get_lang('StudentsCanEdit'), get_lang('Yes'), 1); - //$form->addElement('radio', 'students_can_edit', '', get_lang('No'), 0); - // This is for horizontal. - - /* if (document.getElementById('id_qualify').style.display == 'none') { - document.getElementById('id_qualify').style.display = 'block'; - document.getElementById('plus').innerHTML=' '.Display::return_icon('div_hide.gif').' ".get_lang('AddAnAttachment')."'; - } else { - document.getElementById('options').style.display = 'none'; - document.getElementById('plus').innerHTML=' '.Display::return_icon('div_show.gif').' ".get_lang('AddAnAttachment')."'; - }*/ - + $form->addElement('advanced_settings', ' '.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedParameters').'',''); $form->addElement('html', '