diff --git a/index.php b/index.php index e5edb2fdfa..d6c16d6e68 100644 --- a/index.php +++ b/index.php @@ -26,6 +26,7 @@ if (!api_is_anonymous()) { $header_title = " "; } +$htmlHeadXtra[] = api_get_jquery_ui_js(); $htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider')); $htmlHeadXtra[] =' '; -$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); -$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); +$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); +$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $page=intval($_GET['page']); $action= Security::remove_XSS($_REQUEST['action']); diff --git a/main/admin/session_list.php b/main/admin/session_list.php index ce35633c21..c39f8800de 100644 --- a/main/admin/session_list.php +++ b/main/admin/session_list.php @@ -43,21 +43,38 @@ Display::display_header($tool_name); $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions'; //The order is important you need to check the the $column variable in the model.ajax.php file -$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('SessionCategoryName'), get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Visibility'), get_lang('Actions')); +$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('SessionCategoryName'), + get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions')); +//$activeurl = '?sidx=session_active'; //Column config $column_model = array( - array('name'=>'name', 'index'=>'s.name', 'width'=>'120', 'align'=>'left', 'search' => 'true'), - array('name'=>'nbr_courses', 'index'=>'s.nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'), - array('name'=>'category_name', 'index'=>'sc.name', 'width'=>'80', 'align'=>'left', 'search' => 'true'), - array('name'=>'date_start', 'index'=>'s.date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'), - array('name'=>'date_end', 'index'=>'s.date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'), - array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'80', 'align'=>'left', 'search' => 'false'), + array('name'=>'name', 'index'=>'name', 'width'=>'120', 'align'=>'left', 'search' => 'true'), + array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'), + array('name'=>'category_name', 'index'=>'category_name', 'width'=>'70', 'align'=>'left', 'search' => 'true'), + array('name'=>'date_start', 'index'=>'date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'), + array('name'=>'date_end', 'index'=>'date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'), + array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'80', 'align'=>'left', 'search' => 'false'), + + array('name'=>'status', 'index'=>'session_active', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'stype'=>'select', + + + + //for the bottom bar + 'searchoptions' => array( + 'defaultValue' => '1', + 'value' => '1:'.get_lang('Active').';0:'.get_lang('Inactive')), + + //for the top bar + 'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))), + + array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'), array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false') ); //Autowidth $extra_params['autowidth'] = 'true'; + //height auto $extra_params['height'] = 'auto'; $extra_params['excel'] = 'excel'; @@ -67,7 +84,7 @@ $extra_params['rowList'] = array(10, 20 ,30); //With this function we can add actions to the jgrid (edit, delete, etc) $action_links = 'function action_formatter(cellvalue, options, rowObject) { - return \''.Display::return_icon('edit.png',get_lang('Edit'),'',22).''. + return \''.Display::return_icon('edit.png',get_lang('Edit'),'',22).''. ' '.Display::return_icon('user_subscribe_session.png',get_lang('SubscribeUsersToSession'),'',22).''. ' '.Display::return_icon('courses_to_session.png',get_lang('SubscribeCoursesToSession'),'',22).''. ' '.Display::return_icon('copy.png',get_lang('Copy'),'',22).''. @@ -76,45 +93,75 @@ $action_links = 'function action_formatter(cellvalue, options, rowObject) { }'; ?> +
'.Display::return_icon('new_session.png',get_lang('AddSession'),'','32').''; echo ''.Display::return_icon('session_to_category.png',get_lang('AddSessionsInCategories'),'','32').''; echo ''.Display::return_icon('folder.png',get_lang('ListSessionCategory'),'','32').''; echo '
'; - echo Display::grid_html('sessions'); Display::display_footer(); \ No newline at end of file diff --git a/main/admin/settings.php b/main/admin/settings.php index d6b205e032..a80553a117 100644 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -39,6 +39,14 @@ $_SESSION['this_section'] = $this_section; // Access restrictions. api_protect_admin_script(); +// Settings to avoid +$settings_to_avoid = array( + 'gradebook_enable' => 'false', + 'use_document_title' => 'true', + 'example_material_course_creation' => 'true' // ON by default - now we have this option when we create a course +); + + // Submit stylesheets. if (isset($_POST['submit_stylesheets'])) { $message = store_stylesheets(); @@ -88,7 +96,6 @@ if (isset($_GET['action']) && $_GET['action'] == 'delete_grading') { api_delete_setting_option($id); } - // Build the form. if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', 'stylesheets', 'Search'))) { $form = new FormValidator('settings', 'post', 'settings.php?category='.$_GET['category']); @@ -145,17 +152,6 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' } } - - //Settings to avoid - - // Settings to avoid - $settings_to_avoid = array( - 'gradebook_enable', // - 'use_document_title', // ON by default - 'example_material_course_creation', // ON by default - now we have this option when we create a course - ); - - $default_values = array(); foreach ($settings as $row) { if (in_array($row['variable'], $settings_to_avoid)) { continue; } @@ -490,7 +486,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' if ($form->validate()) { $values = $form->exportValues(); $pdf_export_watermark_path = $_FILES['pdf_export_watermark_path']; - + if (isset($pdf_export_watermark_path) && !empty($pdf_export_watermark_path['name'])) { $pdf_export_watermark_path_result = PDF::upload_watermark($pdf_export_watermark_path['name'], $pdf_export_watermark_path['tmp_name']); if ($pdf_export_watermark_path_result) { @@ -501,21 +497,20 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' unset($update_values['pdf_export_watermark_path']); } - // Set true for allow_message_tool variable if social tool is actived. + // Set true for allow_message_tool variable if social tool is actived - - $values['dropbox_max_filesize'] = $values['dropbox_max_filesize']*1024*1024; + $values['dropbox_max_filesize'] = $values['dropbox_max_filesize']*1024*1024; $values['message_max_upload_filesize'] = $values['message_max_upload_filesize']*1024*1024; - if ($values['allow_social_tool'] == 'true') { $values['allow_message_tool'] = 'true'; } // quick patch to avoid gradebook_enable's value to be blanked + /* if ($my_category == 'Gradebook') { $gb = 'false'; $gb = api_get_setting('gradebook_enable'); - } + }*/ // The first step is to set all the variables that have type=checkbox of the category // to false as the checkbox that is unchecked is not in the $_POST data and can @@ -525,14 +520,21 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' $r = api_set_settings_category($my_category, 'false', $_configuration['access_url'], array('checkbox', 'radio')); // quick patch to avoid gradebook_enable's value to be blanked if ($my_category == 'Gradebook') { - api_set_setting('gradebook_enable', $gb, null, $my_category, $_configuration['access_url']); + //api_set_setting('gradebook_enable', $gb, null, $my_category, $_configuration['access_url']); } - //$sql = "UPDATE $table_settings_current SET selected_value='false' WHERE category='$my_category' AND type='checkbox'"; - //$result = Database::query($sql); + + foreach($settings_to_avoid as $key => $value) { + api_set_setting($key, $value, null, null, $_configuration['access_url']); + } + + + // Save the settings. $keys = array(); - //$gradebook_score_display_custom_values = array(); - foreach ($values as $key => $value) { + + foreach ($values as $key => $value) { + if (in_array($key, $settings_to_avoid)) { continue; } + // Treat gradebook values in separate function. //if (strpos($key, 'gradebook_score_display_custom_values') === false) { if (!is_array($value)) { @@ -603,7 +605,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' $keys[] = $key; break; } - } + } foreach ($value as $subkey => $subvalue) { $result = api_set_setting($key, 'true', $subkey, null, $_configuration['access_url']); } @@ -615,11 +617,11 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' $user_id = api_get_user_id(); $category = $_GET['category']; event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id); - - + // Add event configuration settings variable to the system log. if (is_array($keys) && count($keys) > 0) { foreach ($keys as $variable) { + if (in_array($key, $settings_to_avoid)) { continue; } event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_VARIABLE, $variable, api_get_utc_datetime(), $user_id); } } diff --git a/main/admin/skills_gradebook.php b/main/admin/skills_gradebook.php index 184c329cfa..fddf3f0ee5 100644 --- a/main/admin/skills_gradebook.php +++ b/main/admin/skills_gradebook.php @@ -24,10 +24,10 @@ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'display'; // setting breadcrumbs -$tool_name = get_lang('SkillGradebook'); +$tool_name = get_lang('SkillsAndGradebooks'); $interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); if ($action == 'add_skill') { - $interbreadcrumb[]=array('url' => 'skills_gradebook.php','name' => get_lang('SkillGradebook')); + $interbreadcrumb[]=array('url' => 'skills_gradebook.php','name' => get_lang('SkillsAndGradebooks')); $tool_name = get_lang('Add'); } @@ -42,13 +42,14 @@ Display::display_header($tool_name); $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_gradebooks'; //The order is important you need to check the the $column variable in the model.ajax.php file -$columns = array(get_lang('Name'), get_lang('Skills'), get_lang('Actions')); +$columns = array(get_lang('Name'), get_lang('CertificatesFiles'), get_lang('Skills'), get_lang('Actions')); //Column config $column_model = array( - array('name'=>'name', 'index'=>'name', 'width'=>'200', 'align'=>'left'), - array('name'=>'skills', 'index'=>'skills', 'width'=>'300', 'align'=>'left','sortable'=>'false'), - array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false') + array('name'=>'name', 'index'=>'name', 'width'=>'150', 'align'=>'left'), + array('name'=>'certificate', 'index'=>'certificate', 'width'=>'25', 'align'=>'left', 'sortable'=>'false'), + array('name'=>'skills', 'index'=>'skills', 'width'=>'300', 'align'=>'left', 'sortable'=>'false'), + array('name'=>'actions', 'index'=>'actions', 'width'=>'30', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false') ); //Autowidth $extra_params['autowidth'] = 'true'; @@ -57,15 +58,19 @@ $extra_params['height'] = 'auto'; //With this function we can add actions to the jgrid (edit, delete, etc) $action_links = 'function action_formatter(cellvalue, options, rowObject) { - return \''.Display::return_icon('addd.gif', get_lang('AddSkill'),'',22).''. - '\'; + //certificates + if (rowObject[4] == 1) { + return \''.Display::return_icon('add.png', get_lang('AddSkill'),'',22).''.'\'; + } else { + return \''.Display::return_icon('add_na.png', get_lang('YourGradebookFirstNeedsACertificateInOrderToBeLinkedToASkill'),'',22).''.'\'; + } }'; ?> diff --git a/main/admin/skills_profile.php b/main/admin/skills_profile.php index a6a99a7a0a..42df55cce4 100644 --- a/main/admin/skills_profile.php +++ b/main/admin/skills_profile.php @@ -65,7 +65,7 @@ $user_list = array(); $count_skills = count($skills); $users = $skill_rel_user->get_user_by_skills($skills); - + if (!empty($users)) { foreach($users as $user) { $user_info = api_get_user_info($user['user_id']); @@ -74,6 +74,7 @@ if (!empty($users)) { $user_skills = array(); $found_counts = 0 ; foreach($my_user_skills as $my_skill) { + $found = false; if (in_array($my_skill['skill_id'], $skills)) { $found = true; @@ -94,7 +95,7 @@ if (!empty($users)) { } } -//var_dump($user_list); + //$tpl->assign('user_list', $user_list); $tpl->assign('order_user_list', $ordered_user_list); @@ -116,12 +117,10 @@ if (!empty($skills)) { $total_skills_to_search = $skill->get_skills_info($total_skills_to_search); $skill_list = array(); -foreach($total_skills_to_search as &$skill_info) { +foreach($total_skills_to_search as $skill_info) { $skill_list[$skill_info['id']] = $skill_info; } - - $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null; $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null; diff --git a/main/admin/system_announcements.php b/main/admin/system_announcements.php index 41c706170c..3513353451 100644 --- a/main/admin/system_announcements.php +++ b/main/admin/system_announcements.php @@ -122,8 +122,8 @@ if (isset ($_GET['action']) && $_GET['action'] == 'edit') { $values['visible_guest'] = $announcement->visible_guest ; $values['lang'] = $announcement->lang; $values['action'] = 'edit'; - $groups = SystemAnnouncementManager :: get_announcement_groups($announcement->id); - $values['group'] = isset($groups[0]['group_id']) ? $groups[0]['group_id'] : 0; + $groups = SystemAnnouncementManager :: get_announcement_groups($announcement->id); + $values['group'] = isset($groups[0]['group_id']) ? $groups[0]['group_id'] : 0; $action_todo = true; } diff --git a/main/admin/user_information.php b/main/admin/user_information.php index 35c2cf4747..f7bec76133 100644 --- a/main/admin/user_information.php +++ b/main/admin/user_information.php @@ -216,7 +216,7 @@ if ($_configuration['multiple_access_urls']) { $url_list= UrlManager::get_access_url_from_user($user['user_id']); if (count($url_list) > 0) { $header = array(); - $header[] = array (get_lang('URL'), true); + $header[] = array ('URL', true); $data = array (); foreach ($url_list as $url) { $row = array(); diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index e0bf6aac79..034e0dc12d 100644 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -427,24 +427,25 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed // send to the created 'userlist' $sqlmail = "SELECT user_id, lastname, firstname, email FROM $tbl_user - WHERE user_id IN (".$userlist.")"; + WHERE active = 1 AND user_id IN (".$userlist.")"; } else if (empty($_POST['not_selected_form'])) { if(empty($_SESSION['id_session']) || api_get_setting('use_session_mode')=='false') { // send to everybody $sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname FROM $tbl_course_user, $tbl_user - WHERE course_code='".Database::escape_string($_course['sysCode'])."' - AND course_rel_user.user_id = user.user_id AND relation_type <>".COURSE_RELATION_TYPE_RRHH." "; + WHERE active = 1 AND + course_code='".Database::escape_string($_course['sysCode'])."' AND + course_rel_user.user_id = user.user_id AND + relation_type <>".COURSE_RELATION_TYPE_RRHH." "; } else { $sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname - FROM $tbl_user - INNER JOIN $tbl_session_course_user - ON $tbl_user.user_id = $tbl_session_course_user.id_user - AND $tbl_session_course_user.course_code = '".$_course['id']."' - AND $tbl_session_course_user.id_session = ".api_get_session_id(); + FROM $tbl_user INNER JOIN $tbl_session_course_user + ON $tbl_user.user_id = $tbl_session_course_user.id_user AND + active = 1 AND + $tbl_session_course_user.course_code = '".$_course['id']."' AND + $tbl_session_course_user.id_session = ".api_get_session_id(); } } - if ($sqlmail != '') { $rs_mail = Database::query($sqlmail); @@ -482,7 +483,10 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed $data_file = array('path' => $path_attach,'filename' => $filename_attach); } @api_mail_html($recipient_name, $mailid, stripslashes($emailSubject), $mail_body, $sender_name, $sender_email, null, $data_file, true); + //@todo who uses the $table_reminder?? + + /* if ($_REQUEST['reminder']=="1") { $time=getdate(); $time = $time['yday']; @@ -501,7 +505,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed $time = $time+30; $sql="INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','".addslashes($emailSubject)."','".addslashes($mail_body)."','1','$time','$end_date')"; Database::query($sql); - } + }*/ } AnnouncementManager::update_mail_sent($insert_id); $message = $added_and_sent; @@ -1067,7 +1071,19 @@ if ($display_announcement_list) { if (!isset($_GET['action']) || !in_array($_GET['action'], array('add', 'modify','view'))) if ($num_rows == 0) { - Display::display_warning_message(get_lang('NoAnnouncements')); + if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) { + echo '
'; + echo '

'.get_lang('Announcements').'

'; + echo Display::return_icon('valves.png', '', array(), 64); + echo '
'; + echo Display::url(get_lang('AddAnnouncement'), api_get_self()."?".api_get_cidreq()."&action=add&origin=".(empty($_GET['origin'])?'':$_GET['origin']) , array('class' => 'a_button white')); + echo '
'; + echo '
'; + } else { + //echo "".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'','32').""; + Display::display_warning_message(get_lang('NoAnnouncements')); + } + } else { $iterator = 1; $bottomAnnouncement = $announcement_number; diff --git a/main/auth/courses.php b/main/auth/courses.php index 07ea4636b6..bb31fe1ffb 100644 --- a/main/auth/courses.php +++ b/main/auth/courses.php @@ -19,7 +19,6 @@ require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'auth.lib.php'; require_once api_get_path(LIBRARY_PATH).'app_view.php'; require_once 'courses_controller.php'; -//require_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php'; require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { diff --git a/main/calendar/agenda.lib.php b/main/calendar/agenda.lib.php index dee2a59dae..b6b3354ada 100644 --- a/main/calendar/agenda.lib.php +++ b/main/calendar/agenda.lib.php @@ -41,7 +41,7 @@ class Agenda { * @param string agendaDay, agendaWeek, month * @param string personal, course or global (only works for personal by now) */ - function add_event($start, $end, $all_day, $view, $title, $content, $users_to_send = array()) { + function add_event($start, $end, $all_day, $view, $title, $content, $users_to_send = array(), $add_as_announcement = false) { $start = date('Y-m-d H:i:s', $start); $end = date('Y-m-d H:i:s', $end); @@ -57,7 +57,7 @@ class Agenda { $attributes['title'] = $title; $attributes['text'] = $content; $attributes['date'] = $start; - $attributes['enddate'] = $end; + $attributes['enddate'] = $end; $attributes['all_day'] = $all_day; $id = Database::insert($this->tbl_personal_agenda, $attributes); break; @@ -67,14 +67,14 @@ class Agenda { $attributes['content'] = $content; $attributes['start_date'] = $start; $attributes['end_date'] = $end; - $attributes['all_day'] = $all_day; + $attributes['all_day'] = $all_day; $attributes['session_id'] = api_get_session_id(); $attributes['c_id'] = $this->course['real_id']; //simple course event $id = Database::insert($this->tbl_course_agenda, $attributes); - if ($id) { + if ($id) { //api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id, "AgendaAdded", api_get_user_id(), '','',$start, $end); $group_id = api_get_group_id(); if ((!is_null($users_to_send)) or (!empty($group_id))) { @@ -99,8 +99,11 @@ class Agenda { } } } - } - + + if (isset($add_as_announcement) && !empty($add_as_announcement)) { + self::store_agenda_item_as_announcement($id); + } + } break; case 'admin': @@ -115,6 +118,76 @@ class Agenda { } return $id; } + + + /* copycat of the agenda.inc.php @todo try to fix it */ + + function store_agenda_item_as_announcement($item_id){ + $table_agenda = Database::get_course_table(TABLE_AGENDA); + $table_ann = Database::get_course_table(TABLE_ANNOUNCEMENT); + $course_id = api_get_course_int_id(); + //check params + if(empty($item_id) or $item_id != strval(intval($item_id))) {return -1;} + //get the agenda item + + $item_id = Database::escape_string($item_id); + $sql = "SELECT * FROM $table_agenda WHERE c_id = $course_id AND id = ".$item_id; + $res = Database::query($sql); + + if (Database::num_rows($res)>0) { + $row = Database::fetch_array($res); + + //we have the agenda event, copy it + //get the maximum value for display order in announcement table + $sql_max = "SELECT MAX(display_order) FROM $table_ann WHERE c_id = $course_id "; + $res_max = Database::query($sql_max); + $row_max = Database::fetch_array($res_max); + $max = intval($row_max[0])+1; + //build the announcement text + $content = $row['content']; + //insert announcement + $session_id = api_get_session_id(); + + + $sql_ins = "INSERT INTO $table_ann (c_id, title,content,end_date,display_order,session_id) " . + "VALUES ($course_id, '".Database::escape_string($row['title'])."','".Database::escape_string($content)."','".Database::escape_string($row['end_date'])."','$max','$session_id')"; + $res_ins = Database::query($sql_ins); + if ($res > 0) { + $ann_id = Database::insert_id(); + //Now also get the list of item_properties rows for this agenda_item (calendar_event) + //and copy them into announcement item_properties + $table_props = Database::get_course_table(TABLE_ITEM_PROPERTY); + $sql_props = "SELECT * FROM $table_props WHERE c_id = $course_id AND tool ='calendar_event' AND ref='$item_id'"; + $res_props = Database::query($sql_props); + if(Database::num_rows($res_props)>0) { + while($row_props = Database::fetch_array($res_props)) { + //insert into announcement item_property + $time = api_get_utc_datetime(); + $sql_ins_props = "INSERT INTO $table_props " . + "(c_id, tool, insert_user_id, insert_date, " . + "lastedit_date, ref, lastedit_type," . + "lastedit_user_id, to_group_id, to_user_id, " . + "visibility, start_visible, end_visible)" . + " VALUES " . + "($course_id, 'announcement','".$row_props['insert_user_id']."','".$time."'," . + "'$time','$ann_id','AnnouncementAdded'," . + "'".$row_props['last_edit_user_id']."','".$row_props['to_group_id']."','".$row_props['to_user_id']."'," . + "'".$row_props['visibility']."','".$row_props['start_visible']."','".$row_props['end_visible']."')"; + $res_ins_props = Database::query($sql_ins_props); + if($res_ins_props <= 0){ + return -1; + } else { + //copy was a success + return $ann_id; + } + } + } + } else { + return -1; + } + } + return -1; + } function edit_event($id, $start, $end, $all_day, $view, $title, $content) { $start = date('Y-m-d H:i:s', $start); @@ -190,12 +263,18 @@ class Agenda { break; case 'personal': default: + //Getting personal events $this->get_personal_events($start, $end); + + //Getting platform/admin events $this->get_platform_events($start, $end); + + //Getting course events $my_course_list = array(); + if (!api_is_anonymous()) { $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true); - } + } if (!empty($my_course_list)) { foreach($my_course_list as $course_info_item) { if (isset($course_id) && !empty($course_id)) { @@ -290,6 +369,7 @@ class Agenda { $start = api_get_utc_datetime($start); $end = api_get_utc_datetime($end); $user_id = api_get_user_id(); + $sql = "SELECT * FROM ".$this->tbl_personal_agenda." WHERE date >= '".$start."' AND (enddate <='".$end."' OR enddate IS NULL) AND user = $user_id"; @@ -302,6 +382,9 @@ class Agenda { $event['className'] = 'personal'; $event['borderColor'] = $event['backgroundColor'] = $this->event_personal_color; $event['editable'] = true; + + $event['sent_to'] = get_lang('Me'); + $event['type'] = 'personal'; if (!empty($row['date']) && $row['date'] != '0000-00-00 00:00:00') { $event['start'] = $this->format_event_date($row['date']); @@ -310,7 +393,7 @@ class Agenda { if (!empty($row['enddate']) && $row['enddate'] != '0000-00-00 00:00:00') { $event['end'] = $this->format_event_date($row['enddate']); } - $event['description'] = $row['text']; + $event['description'] = $row['text']; $event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0; $my_events[] = $event; $this->events[]= $event; @@ -323,7 +406,21 @@ class Agenda { $course_id = $course_info['real_id']; - $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id()); + $group_list = GroupManager::get_group_list(null, $course_info['code']); + $group_name_list = array(); + + if (!empty($group_list)) { + foreach($group_list as $group) { + $group_name_list[$group['id']]= $group['name']; + } + } + + if (!api_is_allowed_to_edit()) { + $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id()); + } else { + $group_memberships = array_keys($group_name_list); + } + $tlb_course_agenda = Database::get_course_table(TABLE_AGENDA); $tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY); @@ -334,36 +431,38 @@ class Agenda { } if (is_array($group_memberships) && count($group_memberships) >0 ) { - $sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref - FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip - WHERE agenda.id = ip.ref AND - ip.tool ='".TOOL_CALENDAR_EVENT."' AND - ( ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) AND - ip.visibility = '1' AND - agenda.c_id = $course_id AND - ip.c_id = $course_id"; + if (api_is_allowed_to_edit()) { + $where_condition = "( ip.to_group_id is null OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) "; + } else { + $where_condition = "( ip.to_user_id = $user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) "; + } + + $sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref + FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip + WHERE agenda.id = ip.ref AND + ip.tool ='".TOOL_CALENDAR_EVENT."' AND + $where_condition AND + ip.visibility = '1' AND + agenda.c_id = $course_id AND + ip.c_id = $course_id"; + + + } else { - if (api_is_allowed_to_edit()) { - $sql="SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref - FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip - WHERE agenda.id = ip.ref - AND ip.tool='".TOOL_CALENDAR_EVENT."' - AND ip.visibility='1' AND - agenda.c_id = $course_id AND - ip.c_id = $course_id - "; - } else { - $sql="SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref - FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip - WHERE agenda.id = ip.ref - AND ip.tool='".TOOL_CALENDAR_EVENT."' - AND ( ip.to_user_id=$user_id OR ip.to_group_id='0') - AND ip.visibility='1' AND - agenda.c_id = $course_id AND - ip.c_id = $course_id "; - - - } + if (api_is_allowed_to_edit()) { + $where_condition = ""; + } else { + $where_condition = "( ip.to_user_id=$user_id OR ip.to_group_id='0') AND "; + } + $sql="SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref + FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip + WHERE agenda.id = ip.ref AND + ip.tool='".TOOL_CALENDAR_EVENT."' AND + $where_condition + ip.visibility='1' AND + agenda.c_id = $course_id AND + ip.c_id = $course_id"; + } $result = Database::query($sql); @@ -393,6 +492,7 @@ class Agenda { } $event['editable'] = false; + if (api_is_allowed_to_edit() && $this->type == 'course') { $event['editable'] = true; } @@ -403,6 +503,28 @@ class Agenda { if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') { $event['end'] = $this->format_event_date($row['end_date']); } + + $event['sent_to'] = ''; + $event['type'] = $this->type; + + + //Event Sent to a group? + if (isset($row['to_group_id']) && !empty($row['to_group_id'])) { + $event['sent_to'] = $group_name_list[$row['to_group_id']]; + $event['type'] = 'group'; + } + + //Event sent to a user? + if (isset($row['to_user_id'])) { + $event['sent_to'] = $row['to_user_id']; + } + + //Event sent to everyone! + if (empty($event['sent_to'])) { + $event['sent_to'] = get_lang('Everyone'); + } + + $event['description'] = $row['content']; $event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0; @@ -438,6 +560,8 @@ class Agenda { $event['allDay'] = 'false'; $event['borderColor'] = $event['backgroundColor'] = $this->event_platform_color; $event['editable'] = false; + + $event['type'] = 'admin'; if (api_is_platform_admin() && $this->type == 'admin') { $event['editable'] = true; diff --git a/main/calendar/agenda_js.php b/main/calendar/agenda_js.php index 17a0169e93..4d75931c52 100644 --- a/main/calendar/agenda_js.php +++ b/main/calendar/agenda_js.php @@ -72,7 +72,8 @@ $tpl->assign('button_text', json_encode(array( 'today' => get_lang('Today'), //Calendar Type : course, admin, personal $tpl->assign('type', $type); //Calendar type label -$tpl->assign('type_label', get_lang($type.'Calendar')); + +$tpl->assign('type_label', get_lang(ucfirst($type).'Calendar')); //Current user can add event? $tpl->assign('can_add_events', $can_add_events); diff --git a/main/chat/chat_functions.lib.php b/main/chat/chat_functions.lib.php old mode 100755 new mode 100644 index cc2c979b11..431ec2f7d0 --- a/main/chat/chat_functions.lib.php +++ b/main/chat/chat_functions.lib.php @@ -10,10 +10,11 @@ */ function exit_of_chat($user_id) { $user_id = intval($user_id); + $course_id = api_get_course_int_id(); $list_course = array(); $list_course = CourseManager::get_courses_list_by_user_id($user_id); - $group_id = intval($_SESSION['id_group']); + $group_id = intval($_SESSION['id_group']); $session_id = intval($_SESSION['id_session']); $extra_condition = ''; @@ -22,11 +23,11 @@ function exit_of_chat($user_id) { } else { $extra_condition = api_get_session_condition($session_id); } - + $extra_condition.= " AND course_id = $course_id"; foreach ($list_course as $courses) { - $response = user_connected_in_chat($user_id,$courses['db_name']); + $response = user_connected_in_chat($user_id); if ($response === true) { - $tbl_chat_connected = Database::get_course_chat_connected_table($courses['db_name']); + $tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE); $sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE user_id='.$user_id.$extra_condition; Database::query($sql); } @@ -39,12 +40,14 @@ function exit_of_chat($user_id) { * @param string the database name * @return boolean */ -function user_connected_in_chat ($user_id, $database_name) { - $tbl_chat_connected = Database::get_course_chat_connected_table($database_name); +function user_connected_in_chat ($user_id) { + $tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE); $group_id = intval($_SESSION['id_group']); $session_id = intval($_SESSION['id_session']); $user_id = intval($user_id); + $course_id = api_get_course_int_id(); + $extra_condition = ''; if (!empty($group_id)) { @@ -53,7 +56,7 @@ function user_connected_in_chat ($user_id, $database_name) { $extra_condition = api_get_session_condition($session_id); } - $sql = 'SELECT COUNT(*) AS count FROM '.$tbl_chat_connected .' c WHERE user_id='.$user_id.$extra_condition; + $sql = 'SELECT COUNT(*) AS count FROM '.$tbl_chat_connected .' c WHERE c_id = '.$course_id.' AND user_id='.$user_id.$extra_condition; $result = Database::query($sql); $count = Database::fetch_array($result,'ASSOC'); return $count['count'] == 1; @@ -63,16 +66,12 @@ function user_connected_in_chat ($user_id, $database_name) { * @param string $database_name (optional) * @return void */ -function disconnect_user_of_chat($database_name = '') { - +function disconnect_user_of_chat() { $list_info_user_in_chat = array(); - - if (!empty($database_name)) { - $list_info_user_in_chat = users_list_in_chat($database_name); - } else { - $list_info_user_in_chat = users_list_in_chat(); - } - + $course_id = api_get_course_int_id(); + $list_info_user_in_chat = users_list_in_chat(); + $course_id = api_get_course_int_id(); + $cd_date = date('Y-m-d',time()); $cdate_h = date('H',time()); $cdate_m = date('i',time()); @@ -87,14 +86,9 @@ function disconnect_user_of_chat($database_name = '') { $date_db_s = date('s', strtotime($list_info_user['last_connection'])); $date_count_time_seconds=$date_db_h*3600 + $date_db_m*60 + $date_db_s; if ($cd_date == $date_db_date) { - if (($cd_count_time_seconds - $date_count_time_seconds) > 5) { - - $tbl_chat_connected = Database::get_course_chat_connected_table(); - if (!empty($database_name)) { - $tbl_chat_connected = Database::get_course_chat_connected_table($database_name); - } - - $sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE user_id='.$list_info_user['user_id']; + if (($cd_count_time_seconds - $date_count_time_seconds) > 5) { + $tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE); + $sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course_id.' AND user_id ='.$list_info_user['user_id']; Database::query($sql); } } @@ -106,9 +100,11 @@ function disconnect_user_of_chat($database_name = '') { * @param string $database_name (optional) * @return array user list in chat */ -function users_list_in_chat ($database_name = '') { +function users_list_in_chat() { $list_users_in_chat = array(); - $tbl_chat_connected = Database::get_course_chat_connected_table($database_name); + $tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE); + $course_id = api_get_course_int_id(); + $group_id = intval($_SESSION['id_group']); $session_id = intval($_SESSION['id_session']); $extra_condition = ''; @@ -117,6 +113,7 @@ function users_list_in_chat ($database_name = '') { } else{ $extra_condition = api_get_session_condition($session_id, false); } + $extra_condition.= " AND c_id = $course_id "; $sql = 'SELECT user_id,last_connection FROM '.$tbl_chat_connected.$extra_condition; $result = Database::query($sql); while ($row = Database::fetch_array($result, 'ASSOC')) { diff --git a/main/chat/chat_hidden.php b/main/chat/chat_hidden.php index 4202b799ef..c923560831 100644 --- a/main/chat/chat_hidden.php +++ b/main/chat/chat_hidden.php @@ -16,12 +16,13 @@ define('FRAME', 'hidden'); $language_file = array('chat'); require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'course.lib.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once 'chat_functions.lib.php'; $tbl_user = Database::get_main_table(TABLE_MAIN_USER); -$tbl_chat_connected = Database::get_course_chat_connected_table(); +$tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE); + +$course_id = api_get_course_int_id(); $query = "SELECT username FROM $tbl_user WHERE user_id='".$_user['user_id']."'"; $result = Database::query($query); @@ -31,10 +32,6 @@ list($pseudo_user) = Database::fetch_row($result); $isAllowed = !(empty($pseudo_user) || !$_cid); $isMaster = (bool)$is_courseAdmin; -/*if(!$isAllowed) { - exit(); -}*/ - $date_now = date('Y-m-d'); $group_id = intval($_SESSION['_gid']); @@ -49,6 +46,8 @@ if (!empty($group_id)) { $extra_condition = $session_condition; } +$extra_condition.= " AND c_id = $course_id"; + // get chat path $chat_path = ''; $document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; @@ -83,9 +82,9 @@ $result = Database::query($sql); // The user_id exists so we must do an UPDATE and not a INSERT $current_time = date('Y-m-d H:i:s'); if (Database::num_rows($result) == 0) { - $query = "INSERT INTO $tbl_chat_connected(user_id,last_connection,session_id,to_group_id) VALUES('".$_user['user_id']."','$current_time','$session_id','$group_id')"; + $query = "INSERT INTO $tbl_chat_connected(c_id, user_id,last_connection,session_id,to_group_id) VALUES($course_id, '".$_user['user_id']."','$current_time','$session_id','$group_id')"; } else { - $query = "UPDATE $tbl_chat_connected set last_connection='".$current_time."' WHERE user_id='".$_user['user_id']."' AND session_id='$session_id' AND to_group_id='$group_id'"; + $query = "UPDATE $tbl_chat_connected set last_connection='".$current_time."' WHERE c_id = $course_id AND user_id='".$_user['user_id']."' AND session_id='$session_id' AND to_group_id='$group_id'"; } Database::query($query); @@ -112,12 +111,10 @@ if (api_get_setting('show_navigation_menu') != 'false') { } } ?> -
- ".COURSE_RELATION_TYPE_RRHH." AND t3.course_code = '".$_course['sysCode']."' AND t2.last_connection>'".$date_inter."' $extra_condition - ORDER BY username"; + ORDER BY username"; $result = Database::query($query); $users = Database::store_result($result); } else { diff --git a/main/course_info/legal.php b/main/course_info/legal.php index fbed82bf6b..5cacdcdc9a 100644 --- a/main/course_info/legal.php +++ b/main/course_info/legal.php @@ -32,9 +32,9 @@ $form->addElement('style_submit_button', null, get_lang('Accept'), 'class="save" if ($form->validate()) { $accept_legal = $form->exportValue('accept_legal'); - + if ($accept_legal == 1 ) { - CourseManager::save_user_legal($user_id, $course_code, $session_id); + $result = CourseManager::save_user_legal($user_id, $course_code, $session_id); } } @@ -52,11 +52,13 @@ if (empty($session_id)) { api_not_allowed(); } } else { + if (api_is_platform_admin()) { + header('Location: '.$url); + } $user_session_status = SessionManager::get_user_status_in_session($user_id, $course_code, $session_id); - if (isset($user_session_status)) { - - $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code, $session_id); + if (isset($user_session_status)) { + $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code, $session_id); if ($user_accepted_legal) { //Redirect to course session home header('Location: '.$url); diff --git a/main/create_course/add_course.php b/main/create_course/add_course.php index 6766bcf6fa..b6e94546e6 100644 --- a/main/create_course/add_course.php +++ b/main/create_course/add_course.php @@ -118,8 +118,9 @@ $form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength); $form->addRule('wanted_code', get_lang('ThisFieldIsRequired'), 'required'); }*/ -// The teacher. -$titular = & $form->add_textfield('tutor_name', array(get_lang('Professor'), get_lang('ExplicationTrainers')), null, array('size' => '60', 'disabled' => 'disabled')); +// The teacher +//get_lang('ExplicationTrainers') +$titular = & $form->add_textfield('tutor_name', array(get_lang('Professor'), null), null, array('size' => '60', 'disabled' => 'disabled')); //$form->applyFilter('tutor_name', 'html_filter'); if ($course_validation_feature) { diff --git a/main/css/base.css b/main/css/base.css index b1f203717b..1e7cf3c256 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -1368,9 +1368,9 @@ a.personal_agenda:hover, a.personal_agenda:hover { font-size: 0.8em; margin-right: 10px; overflow: hidden; - padding: 7px 10px; + padding: 13px; text-align: center; - width: 40px; + width: 47px; margin-bottom: 65px; } @@ -1810,8 +1810,8 @@ button:hover { float:left; margin:10px; padding:12px; - width:250px; - min-height:294px; + width:95%; + /* min-height:294px; */ color: #BBBBBB; } @@ -1843,19 +1843,24 @@ button:hover { } .categories-course-description { - margin-left:10px; + margin-left:18px; font-family:arial; font-size:11px; margin-bottom: 10px; + float:left; +} + +.categories-course-links div { + padding-left:10px; } .categories-course-description .course-block-title { font-family: arial; - font-size: large; + font-size: medium; margin-bottom: 10px; color: #222222; - min-height:60px; } + .categories-course-description .course-block-teacher { font-size: large; font-style: italic; @@ -3781,7 +3786,7 @@ form div.error input, form div.error textarea { -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; - width:120px; + width:134px; } .label_tag.personal_event { @@ -3790,10 +3795,17 @@ form div.error input, form div.error textarea { .label_tag.admin_event { background:red; } + .label_tag.course_event { background:#458B00; } +.label_tag.group_event { + background:#A0522D; +} + + + .label_tag.important { background-color: #c43c35; @@ -4050,3 +4062,111 @@ input.liteoption { text-align: left; vertical-align: middle; } + +#no-data-view { + padding: 20px 0 0px; + text-align: center; +} + +div#no-data-view img { + margin-bottom: 25px; +} + + +div#no-data-view h2 { + border: 0 none; + color: #212121; + font-size: 18px; + font-weight: bold; + margin: 0 0 6px; + padding: 0; +} + +div#no-data-view div.controls { + padding-top: 1px; +} + + + + + /* styles for the star rater */ + .star-rating{ + list-style:none; + margin: 0px; + padding:0px; + width: 125px; + height: 25px; + position: relative; + overflow:hidden; + background: url(../img/alt_star.gif) top left repeat-x; + } + .star-rating li{ + padding:0px; + margin:0px; + width:25px; + height:25px; + /*\*/ + float: left; + /* */ + } + .star-rating li a{ + display:block; + width:25px; + height: 25px; + line-height:25px; + text-decoration: none; + text-indent: -9000px; + z-index: 20; + position: absolute; + padding: 0px; + overflow:hidden; + } + .star-rating li a:hover{ + background: url(../img/alt_star.gif) left bottom; + z-index: 2; + left: 0px; + border:none; + } + .star-rating a.one-star{ + left: 0px; + } + .star-rating a.one-star:hover{ + width:25px; + } + .star-rating a.two-stars{ + left:25px; + } + .star-rating a.two-stars:hover{ + width: 50px; + } + .star-rating a.three-stars{ + left: 50px; + } + .star-rating a.three-stars:hover{ + width: 75px; + } + .star-rating a.four-stars{ + left: 75px; + } + .star-rating a.four-stars:hover{ + width: 100px; + } + .star-rating a.five-stars{ + left: 100px; + } + .star-rating a.five-stars:hover{ + width: 125px; + } + .star-rating li.current-rating{ + background: url(../img/alt_star.gif) left center; + position: absolute; + height: 25px; + display: block; + text-indent: -9000px; + z-index: 1; + } + + /* remove halo effect in firefox */ + a:active{ + outline: none; + } \ No newline at end of file diff --git a/main/document/document.php b/main/document/document.php index 16b4e583ca..ad85c8bc7a 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -57,6 +57,11 @@ unset($_SESSION['paint_dir']); DocumentManager::create_directory_certificate_in_course(api_get_course_id()); $course_info = api_get_course_info(); + +if (empty($course_info)) { + api_not_allowed(); +} + $course_dir = $course_info['path'].'/document'; $sys_course_path = api_get_path(SYS_COURSE_PATH); $base_work_dir = $sys_course_path.$course_dir; @@ -944,7 +949,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) { // Size (or total size of a directory) $size = $document_data['filetype'] == 'folder' ? get_total_folder_size($document_data['path'], $is_allowed_to_edit) : $document_data['size']; - // Get the title or the basename depending on what we're using + // Get the title or the basename depending on what we're using if ($use_document_title == 'true' && $document_data['title'] != '') { $document_name = $document_data['title']; } else { diff --git a/main/document/downloadfolder.inc.php b/main/document/downloadfolder.inc.php index f76ac88be0..2297bc3c79 100644 --- a/main/document/downloadfolder.inc.php +++ b/main/document/downloadfolder.inc.php @@ -61,11 +61,12 @@ if (api_is_allowed_to_edit()) { $querypath = Database::escape_string($querypath); // Search for all files that are not deleted => visibility != 2 $sql = "SELECT path FROM $doc_table AS docs, $prop_table AS props - WHERE props.tool='".TOOL_DOCUMENT."' AND + WHERE props.tool ='".TOOL_DOCUMENT."' AND docs.id = props.ref AND docs.path LIKE '".$querypath."/%' AND docs.filetype = 'file' AND props.visibility<>'2' AND props.to_group_id = ".$to_group_id." AND + props.c_id = ".$course_id." AND docs.c_id = ".$course_id." "; $query = Database::query($sql); // Add tem to the zip file diff --git a/main/document/edit_document.php b/main/document/edit_document.php index 111812aa9d..3c354405a3 100644 --- a/main/document/edit_document.php +++ b/main/document/edit_document.php @@ -87,7 +87,7 @@ if (api_is_in_group()) { } if (isset($_GET['id'])) { - $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id()); + $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true); $document_id = $document_data['id']; $file = $document_data['path']; $parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($file)); @@ -96,12 +96,12 @@ if (isset($_GET['id'])) { $doc = basename($file); $my_cur_dir_path = Security::remove_XSS($_GET['curdirpath']); + $readonly = $document_data['readonly']; } if (empty($document_data)) { api_not_allowed(); -} - +} /* //I'm in the certification module? @@ -153,31 +153,6 @@ $noPHP_SELF = true; /* Other initialization code */ -/* Please, do not modify this dirname formatting */ - -if (strstr($dir, '..')) { - $dir = '/'; -} - -if ($dir[0] == '.') { - $dir = substr($dir, 1); -} - -if ($dir[0] != '/') { - $dir = '/'.$dir; -} - -if ($dir[strlen($dir) - 1] != '/') { - $dir .= '/'; -} - -$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; - -if (!is_dir($filepath)) { - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; - $dir = '/'; -} - $dbTable = Database::get_course_table(TABLE_DOCUMENT); $course_id = api_get_course_int_id(); @@ -193,6 +168,19 @@ if (!$is_certificate_mode) else $interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); + +// Interbreadcrumb for the current directory root path +if (empty($document_data['parents'])) { + $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); +} else { + foreach($document_data['parents'] as $document_sub_data) { + if ($document_data['title'] == $document_sub_data['title']) { + continue; + } + $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']); + } +} + if (!is_allowed_to_edit) { api_not_allowed(true); } @@ -208,9 +196,7 @@ if (!is_allowed_to_edit()) { /* MAIN TOOL CODE */ -/* Code to change the comment - Step 2. React on POST data - (Step 1 see below) */ +/* Code to change the comment */ if (isset($_POST['comment'])) { // Fixing the path if it is wrong @@ -222,31 +208,16 @@ if (isset($_POST['comment'])) { $info_message = get_lang('fileModified'); } -/* Code to change the name - Step 2. react on POST data - change the name - (Step 1 see below) */ - +/* Code to rename the file name */ +//var_dump($_POST['renameTo']); if (isset($_POST['renameTo'])) { - $info_message = change_name($baseWorkDir, $_GET['sourceFile'], $_POST['renameTo'], $dir, $doc); -} - -/* Code to change the comment - Step 1. Create dialog box. */ - -/** TODO: Check whether this code is still used **/ -/* Search the old comment */ // RH: metadata: added 'id,' -$result = Database::query("SELECT id, comment, title FROM $dbTable WHERE c_id = $course_id AND id = ".$document_id); - -while ($row = Database::fetch_array($result, 'ASSOC')) { - $oldComment = $row['comment']; - $oldTitle = $row['title']; - $docId = $row['id']; // RH: metadata + $info_message = change_name($baseWorkDir, $_GET['sourceFile'], $_POST['renameTo'], $dir, $doc); } /* WYSIWYG HTML EDITOR - Program Logic */ if ($is_allowed_to_edit) { - if ($_POST['formSent'] == 1) { + if ($_POST['formSent'] == 1) { if (isset($_POST['renameTo'])) { $_POST['filename'] = disable_dangerous_file($_POST['renameTo']); $extension = explode('.', $_POST['filename']); @@ -262,11 +233,7 @@ if ($is_allowed_to_edit) { if (!strstr($content, '/css/frames.css')) { $content=str_replace('', '', $content); } - /* - if (!ctype_alnum($_POST['extension'])) { - header('Location: document.php?msg=WeirdExtensionDeniedInPost'); - exit (); - }*/ + $extension = $_POST['extension']; $file = $dir.$filename.'.'.$extension; $read_only_flag = $_POST['readonly']; @@ -277,16 +244,13 @@ if ($is_allowed_to_edit) { if (empty($filename)) { $msgError = get_lang('NoFileName'); - } else { - if ($document_data['filetype'] == 'file') { - $file_size = filesize($filepath.$filename.'.'.$extension); - } else { - $file_size = filesize($filepath.$filename); - } + } else { + + $file_size = filesize($document_data['absolute_path']); + if ($read_only_flag == 0) { if (!empty($content)) { - if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { - $content = text_filter($content); + if ($fp = @fopen($document_data['absolute_path'], 'w')) { // For flv player, change absolute paht temporarely to prevent from erasing it in the following lines $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content); @@ -300,7 +264,10 @@ if ($is_allowed_to_edit) { fputs($fp, $content); fclose($fp); - if (!is_dir($filepath.'css')) { + + $filepath = $document_data['absolute_parent_path']; + + if (!is_dir($filepath.'css')) { mkdir($filepath.'css', api_get_permissions_for_new_directories()); $doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css'); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id(), null, null, null, null, $current_session_id); @@ -328,9 +295,8 @@ if ($is_allowed_to_edit) { //header('Location: document.php?id='.urlencode($dir)); $my_id = DocumentManager::get_document_id($_course, $dir_modified); - header('Location: document.php?id='.$my_id); - - exit (); + header('Location: document.php?id='.$my_id); + exit; } else { //$msgError = get_lang('Impossible'); } @@ -352,25 +318,24 @@ if ($is_allowed_to_edit) { } // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/') -if (file_exists($filepath.$doc)) { - $extension = explode('.', $doc); - $extension = $extension[sizeof($extension) - 1]; - $filename = str_replace('.'.$extension, '', $doc); - $extension = strtolower($extension); +if (file_exists($document_data['absolute_path'])) { + $path_info = pathinfo($document_data['absolute_path']); + $filename = $path_info['filename']; + $extension = $path_info['extension']; if (in_array($extension, array('html', 'htm'))) { - $content = file($filepath.$doc); + $content = file($document_data['absolute_path']); $content = implode('', $content); $path_to_append = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; - $content = str_replace('="./', '="'.$path_to_append, $content); - $content = str_replace('mp3player.swf?son=.%2F', 'mp3player.swf?son='.urlencode($path_to_append), $content); + // $content = str_replace('="./', '="'.$path_to_append, $content); + //$content = str_replace('mp3player.swf?son=.%2F', 'mp3player.swf?son='.urlencode($path_to_append), $content); } } /* Display user interface */ // Display the header -$nameTools = get_lang('EditDocument') . ': '.Security::remove_XSS($oldTitle); +$nameTools = get_lang('EditDocument') . ': '.Security::remove_XSS($document_data['title']); Display::display_header($nameTools, 'Doc'); @@ -386,15 +351,8 @@ if (isset($info_message)) { } } - -// Readonly -$sql = 'SELECT id, readonly FROM '.$dbTable.' WHERE path LIKE BINARY "'.$dir.$doc.'"'; -$rs = Database::query($sql); -$readonly = Database::result($rs, 0, 'readonly'); -$doc_id = Database::result($rs, 0, 'id'); - // Owner -$document_info = api_get_item_property_info(api_get_course_int_id(),'document', $doc_id); +$document_info = api_get_item_property_info(api_get_course_int_id(),'document', $document_id); $owner_id = $document_info['insert_user_id']; $last_edit_date = $document_info['lastedit_date']; @@ -416,9 +374,10 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_ $form->addElement('hidden', 'origin'); $form->addElement('hidden', 'origin_opt'); - if ($use_document_title) { - $form->add_textfield('title', get_lang('Title')); - $defaults['title'] = $oldTitle; + $form->add_textfield('title', get_lang('Title')); + + if ($use_document_title) { + $defaults['title'] = $document_data['title']; } else { $form->addElement('hidden', 'renameTo'); } @@ -443,7 +402,7 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_ } if (!$group_document && !is_my_shared_folder(api_get_user_id(), $my_cur_dir_path, $current_session_id)) { - $metadata_link = ''.get_lang('AddMetadata').''; + $metadata_link = ''.get_lang('AddMetadata').''; //Updated on field $last_edit_date = api_get_local_time($last_edit_date, null, date_default_timezone_get()); @@ -474,7 +433,7 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_ $defaults['file_path'] = Security::remove_XSS($_GET['file']); $defaults['commentPath'] = $file; $defaults['renameTo'] = $file_name; - $defaults['comment'] = $oldComment; + $defaults['comment'] = $document_data['comment']; $defaults['origin'] = Security::remove_XSS($_GET['origin']); $defaults['origin_opt'] = Security::remove_XSS($_GET['origin_opt']); @@ -520,6 +479,7 @@ Display::display_footer(); It returns nothing. */ function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) { + var_dump($source_file, $rename_to); $file_name_for_change = $base_work_dir.$dir.$source_file; //api_display_debug_info("call my_rename: params $file_name_for_change, $rename_to"); $rename_to = disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index d4e165b74a..72ccf9694d 100644 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -34,6 +34,7 @@ require_once 'exercise.class.php'; require_once 'exercise.lib.php'; require_once 'question.class.php'; require_once 'answer.class.php'; +require_once 'testcategory.class.php'; require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; require_once 'hotpotatoes.lib.php'; @@ -532,7 +533,7 @@ if (!empty($exercise_list)) { $title = Display::tag('font', $row['title'], array('style'=>'color:grey')); } else { $title = $row['title']; - } + } $count = intval(count_exercise_result_not_validated($my_exercise_id, $course_code, $session_id)); @@ -555,8 +556,11 @@ if (!empty($exercise_list)) { if ($session_id == $row['session_id']) { //Settings - $actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),'',22), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']); - $actions .=''.Display :: return_icon('test_results.png', get_lang('Results'),'',22).''; + $actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),'',22), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']); + + //Exercise results + $actions .=''.Display :: return_icon('test_results.png', get_lang('Results'),'',22).''; + //Export $actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id'])); //Clean exercise @@ -571,9 +575,8 @@ if (!empty($exercise_list)) { $actions .= Display::url(Display::return_icon('export_qti2.png','IMS/QTI','','22'), 'exercice.php?choice=exportqti2&exerciseId='.$row['id']); } else { // not session - $actions = Display::return_icon('edit_na.png', get_lang('ExerciseEditionNotAvailableInSession')); - - $actions .=''.Display :: return_icon('test_results.png', get_lang('Results'),'',22).''; + $actions = Display::return_icon('edit_na.png', get_lang('ExerciseEditionNotAvailableInSession')); + $actions .=''.Display :: return_icon('test_results.png', get_lang('Results'),'',22).''; $actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id'])); } @@ -652,7 +655,7 @@ if (!empty($exercise_list)) { WHERE exe_exo_id = ".$row['id']." AND exe_user_id = ".api_get_user_id()." AND exe_cours_id = '".api_get_course_id()."' AND - status <> 'incomplete' AND + status <> 'incomplete' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '" . api_get_session_id() . "' @@ -709,15 +712,26 @@ if (!empty($exercise_list)) { } else { $attempt_text = get_lang('CantShowResults'); } - } + } + + $class_tip = ''; if (empty($num)) { $num = ''; - } + } else { + $class_tip = 'link_tooltip'; + //@todo use sprintf and show the results validated by the teacher + if ($num == 1 ) { + $num = $num.' '.get_lang('Result'); + } else { + $num = $num.' '.get_lang('Results'); + } + $num = ''; + } $item .= Display::tag('td', $attempt_text); //See results - $actions =' '.$num.' '.Display::return_icon('test_results.png', get_lang('Results'),'',22).' '; + $actions = ''.$num.Display::return_icon('test_results.png', get_lang('Results'),'',22).' '; } $class = 'row_even'; if ($count % 2) { @@ -729,6 +743,16 @@ if (!empty($exercise_list)) { $count++; } // end foreach() } +} else { + if ($is_allowedToEdit && $origin != 'learnpath') { + echo '
'; + echo '

'.get_lang('Quiz').'

'; + echo Display::return_icon('quiz.png', '', array(), 64); + echo '
'; + echo Display::url(get_lang('NewEx'), 'exercise_admin.php?' . api_get_cidreq(), array('class' => 'a_button white')); + echo '
'; + echo '
'; + } } // end exercise list diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index a52bcbdde8..a67810f967 100644 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -27,8 +27,6 @@ $main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); - - /** * Shows a question * @@ -352,8 +350,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu api_preg_match_all('/\[[^]]+\]/', $user_choice[0]['answer'], $student_answer_list); $student_answer_list = $student_answer_list[0]; } - - //var_dump($teacher_answer_list, $student_answer_list); if (!empty($teacher_answer_list) && !empty($student_answer_list)) { $teacher_answer_list = $teacher_answer_list[0]; @@ -756,6 +752,8 @@ function get_count_exam_results() { // I know it's bad to add a static integer here... but // it factorise function get_exam_results_data // and I think it worths it. + //This is not bad for the hardcoded value, this is bad because you call 2 times get_exam_results_data()! jm + //@todo use a real count select I know the sql constructions are $tabres = get_exam_results_data(0, 9999999, 0, "ASC"); return count($tabres); } @@ -771,21 +769,13 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { $is_tutor = api_is_allowed_to_edit(true); $is_tutor_course = api_is_course_tutor(); - $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $TBL_USER = Database :: get_main_table(TABLE_MAIN_USER); - $TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT); - $TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); - $TBL_EXERCICE_ANSWER = Database :: get_course_table(TABLE_QUIZ_ANSWER); - $TBL_EXERCICE_QUESTION = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); - $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST); - $TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION); + + $TBL_USER = Database :: get_main_table(TABLE_MAIN_USER); + $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST); $TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_TRACK_HOTPOTATOES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $TBL_TRACK_ATTEMPT = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); - $TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); - $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); - $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); - $TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW); + $TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); $TBL_GROUP_REL_USER = Database :: get_course_table(TABLE_GROUP_USER); $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; @@ -992,7 +982,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { $number_of_items = intval($number_of_items); $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from, $number_of_items"; - + $results = array(); $resx = Database::query($sql); @@ -1006,7 +996,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { $lang_nostartdate = get_lang('NoStartDate') . ' / '; if (is_array($results)) { - $users_array_id = array (); + $users_array_id = array(); if ($_GET['gradebook'] == 'view') { $filter_by_no_revised = true; $from_gradebook = true; @@ -1137,12 +1127,12 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } } else { $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$results[$i]['exid'].'&id_session='.api_get_session_id().'&height=500&width=750'; - $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'thickbox'))."   "; + $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'thickbox a_button white small'))."   "; $html_link.= $attempt_link; if ($revised) { - $html_link.= Display::span(get_lang('Validated'), array('class'=>'label_tag notice')); + $html_link.= Display::span(get_lang('Validated'), array('class'=>'label_tag success')); } else { $html_link.= Display::span(get_lang('NotValidated'), array('class'=>'label_tag notice')); } diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index 41a4f43ff2..51042acdf1 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -27,7 +27,6 @@ $htmlHeadXtra[] = api_get_jquery_ui_js(); // Access control api_protect_course_script(true); - // including additional libraries require_once 'exercise.class.php'; require_once 'exercise.lib.php'; @@ -61,18 +60,23 @@ $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); -$course_id = api_get_course_int_id(); +$course_id = api_get_course_int_id(); +$exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null; +if (empty($exercise_id)) { + api_not_allowed(); +} -if (empty ($exerciseId)) { - $exerciseId = intval($_REQUEST['exerciseId']); +if (!empty($exercise_id)) + $parameters['exerciseId'] = $exercise_id; +if (!empty($_GET['path'])) { + $parameters['path'] = Security::remove_XSS($_GET['path']); } -// // filter display by student group // if $_GET['filterByGroup'] = -1 => do not filter // else, filter by group_id (0 for no group) -// + $filterByGroup = -1; if (isset($_GET['filterByGroup']) && is_numeric($_GET['filterByGroup'])) { $filterByGroup = Security::remove_XSS($_GET['filterByGroup']); @@ -142,7 +146,7 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G $from = $teacher_info['mail']; $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='.$exerciseId; + $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&id_session='.$session_id.'&exerciseId='.$exercise_id; $my_post_info = array(); $post_content_id = array(); @@ -252,11 +256,9 @@ if ($is_allowedToEdit && $origin != 'learnpath') { Display::return_icon('save.png', get_lang('Export'),'',32).''; } } else { - $actions .= '' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').''; + $actions .= '' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').''; } - - //Deleting an attempt if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !empty ($_GET['did']) && $_GET['did'] == strval(intval($_GET['did']))) { $sql = 'DELETE FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = ' . intval($_GET['did']); //_GET[did] filtered by entry condition @@ -265,11 +267,10 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp Database::query($sql); $filter=Security::remove_XSS($_GET['filter']); - header('Location: exercise_report.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&filter=' . $filter . '&exerciseId='.$exerciseId.'&filter_by_user='.$_GET['filter_by_user']); + header('Location: exercise_report.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&filter=' . $filter . '&exerciseId='.$exercise_id.'&filter_by_user='.$_GET['filter_by_user']); exit; } - if (api_is_allowed_to_edit(null,true)) { if (!$_GET['filter']) { $filter_by_not_revised = true; @@ -289,6 +290,13 @@ if (api_is_allowed_to_edit(null,true)) { default : null; } + + //Report by question + $actions .= Display::url(Display::return_icon('statistics_admin.gif', get_lang("ReportByQuestion")), 'stats.php?exerciseId='.$exercise_id); + + //Live results + $actions .=''.Display :: return_icon('activity_monitor.png', get_lang('LiveResults'),'',32).''; + if (!empty($_GET['exerciseId']) && empty($_GET['filter_by_user'])) { if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) { $view_result = ''.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').''; @@ -296,14 +304,12 @@ if (api_is_allowed_to_edit(null,true)) { $view_result = ''.Display :: return_icon('exercice_uncheck.png', get_lang('ShowUnCorrectedOnly'),'','32').''; } $actions .= $view_result; - // + // filter by student group menu - // - $exercice_id = intval($_GET['exerciseId']); $actions .= ""; @@ -311,15 +317,11 @@ if (api_is_allowed_to_edit(null,true)) { $actions .= Display::return_icon('group.gif', get_lang("FilterByGroup")); $actions .= displayGroupMenu("groupFilter", $filterByGroup, "doFilterByGroup()")." "; } + } $parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook'])); -$exercise_id = intval($_GET['exerciseId']); -if (!empty($exercise_id)) - $parameters['exerciseId'] = $exercise_id; -if (!empty($_GET['path'])) { - $parameters['path'] = Security::remove_XSS($_GET['path']); -} + $table = new SortableTable('quiz_results', 'get_count_exam_results', 'get_exam_results_data', 1, 10); $table->set_additional_parameters($parameters); @@ -339,7 +341,7 @@ if ($is_allowedToEdit || $is_tutor) { $table->set_header(6, get_lang('Date')); $table->set_header(7, get_lang('Score'),false); $table->set_header(8, get_lang('Status'), false); - $table->set_header(9, get_lang('CorrectTest'), false); + $table->set_header(9, get_lang('Actions'), false); } else { $table->set_header(0, get_lang('Exercice')); @@ -350,13 +352,12 @@ if ($is_allowedToEdit || $is_tutor) { } $content = $table->return_table(); - if ($is_allowedToEdit || $is_tutor) { $nameTools = get_lang('StudentScore'); $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); $objExerciseTmp = new Exercise(); - if ($objExerciseTmp->read($exerciseId)) { - $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exerciseId, "name" => $objExerciseTmp->name); + if ($objExerciseTmp->read($exercise_id)) { + $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exercise_id, "name" => $objExerciseTmp->name); } } else { $nameTools = get_lang('YourScore'); @@ -400,9 +401,9 @@ $extra = ''; $extra .= '
'; - $extra .= Display::tag('p', Display::input('radio', 'export_format', 'csv', array('checked'=>'1', 'id'=>'export_format_csv_label')). Display::tag('label', get_lang('ExportAsCSV'), array('for'=>'export_format_csv_label'))); - $extra .= Display::tag('p', Display::input('radio', 'export_format', 'xls', array('id'=>'export_format_xls_label')). Display::tag('label', get_lang('ExportAsXLS'), array('for'=>'export_format_xls_label'))); - $extra .= Display::tag('p', Display::input('checkbox', 'load_extra_data', '0',array('id'=>'load_extra_data_id')). Display::tag('label', get_lang('LoadExtraData'), array('for'=>'load_extra_data_id'))); +$extra .= Display::tag('p', Display::input('radio', 'export_format', 'csv', array('checked'=>'1', 'id'=>'export_format_csv_label')). Display::tag('label', get_lang('ExportAsCSV'), array('for'=>'export_format_csv_label'))); +$extra .= Display::tag('p', Display::input('radio', 'export_format', 'xls', array('id'=>'export_format_xls_label')). Display::tag('label', get_lang('ExportAsXLS'), array('for'=>'export_format_xls_label'))); +$extra .= Display::tag('p', Display::input('checkbox', 'load_extra_data', '0',array('id'=>'load_extra_data_id')). Display::tag('label', get_lang('LoadExtraData'), array('for'=>'load_extra_data_id'))); $extra .= '
'; if ($is_allowedToEdit) echo $extra; diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php index 15310e3214..718286391b 100644 --- a/main/exercice/exercise_submit.php +++ b/main/exercice/exercise_submit.php @@ -853,7 +853,7 @@ if (!empty($error)) { data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list, success: function(return_value) { if (return_value == "ok") { - $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('accept.png', get_lang('Ok'), array(), 22)).'"); + $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), 22)).'"); } else if (return_value == "error") { $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), 22)).'"); } else if (return_value == "one_per_page") { diff --git a/main/exercice/hotspot.class.php b/main/exercice/hotspot.class.php old mode 100755 new mode 100644 index c7a0dd7b75..d388be7ea0 --- a/main/exercice/hotspot.class.php +++ b/main/exercice/hotspot.class.php @@ -41,14 +41,14 @@ class HotSpot extends Question { global $text, $class; if(!isset($_GET['editQuestion'])) { $renderer = $form->defaultRenderer(); - $form->addElement('html', '
'.get_lang('UploadJpgPicture').'
'); - $form->addElement('file','imageUpload','*'); + //$form->addElement('html', '
'.get_lang('UploadJpgPicture').'
'); + $form->addElement('file','imageUpload',array('*', get_lang('UploadJpgPicture')) ); // setting the save button here and not in the question class.php // Saving a question $form->addElement('style_submit_button','submitQuestion',get_lang('GoToQuestion'), 'class="'.$class.'"'); - $renderer->setElementTemplate('
{label}
{element}
','imageUpload'); + $renderer->setElementTemplate('
{label}
{element}{label_2}
','imageUpload'); $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif')); $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); } else { diff --git a/main/exercice/live_stats.php b/main/exercice/live_stats.php index 48074d1051..5b9301f183 100644 --- a/main/exercice/live_stats.php +++ b/main/exercice/live_stats.php @@ -10,6 +10,13 @@ require_once 'exercise.lib.php'; $this_section = SECTION_COURSES; $exercise_id = (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) ? intval($_GET['exerciseId']) : 0; +// Access control +api_protect_course_script(true); + +if (!api_is_allowed_to_edit()) { + api_not_allowed(); +} + $objExercise = new Exercise(); $result = $objExercise->read($exercise_id); @@ -30,19 +37,18 @@ Display::display_header($tool_name); //jqgrid will use this URL to do the selects $minutes = 60; - -$url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes; +$url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes; //The order is important you need to check the the $column variable in the model.ajax.php file -$columns = array(get_lang('Firstname'), get_lang('Lastname'), get_lang('Date'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score')); +$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Date'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score')); //Column config $column_model = array( - array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left'), - array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left'), - array('name'=>'start_date', 'index'=>'start_date', 'width'=>'100', 'align'=>'left'), - array('name'=>'question', 'index'=>'count_questions', 'width'=>'100', 'align'=>'left'), - array('name'=>'score', 'index'=>'score', 'width'=>'100', 'align'=>'left','sortable'=>'false'), + array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left'), + array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left'), + array('name'=>'start_date', 'index'=>'start_date', 'width'=>'100', 'align'=>'left'), + array('name'=>'question', 'index'=>'count_questions', 'width'=>'100', 'align'=>'left'), + array('name'=>'score', 'index'=>'score', 'width'=>'100', 'align'=>'left','sortable'=>'false'), ); //Autowidth $extra_params['autowidth'] = 'true'; @@ -59,16 +65,29 @@ $action_links = 'function action_formatter(cellvalue, options, rowObject) { */ ?> ' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').''; +echo $actions = Display::div($actions, array('class'=> 'actions')); + echo '

'.$objExercise->name.'

'; +echo Display::tag('h4', get_lang('StudentsWhoAreTakingTheExerciseRightNow')); + echo Display::grid_html('live_stats'); Display::display_footer(); \ No newline at end of file diff --git a/main/exercice/overview.php b/main/exercice/overview.php index 52b3541c24..26a8afa87e 100644 --- a/main/exercice/overview.php +++ b/main/exercice/overview.php @@ -114,9 +114,9 @@ if (!empty($attempts)) { $counter--; $score = show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']); $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$attempt_result['exe_id'].'&id_session='.api_get_session_id().'&height=500&width=750'; - $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'thickbox')); + $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'thickbox a_button white small')); - $teacher_revised = Display::span(get_lang('Validated'), array('class'=>'label_tag notice')); + $teacher_revised = Display::span(get_lang('Validated'), array('class'=>'label_tag success')); //$attempt_link = get_lang('NoResult'); //$attempt_link = Display::return_icon('quiz_na.png', get_lang('NoResult'), array(), 22); if ($attempt_result['attempt_revised'] == 0) { diff --git a/main/exercice/stats.php b/main/exercice/stats.php index d355509073..95a7d463f8 100644 --- a/main/exercice/stats.php +++ b/main/exercice/stats.php @@ -8,6 +8,7 @@ $language_file = array('exercice', 'tracking'); require_once '../inc/global.inc.php'; require_once 'exercise.lib.php'; $this_section = SECTION_COURSES; + $exercise_id = (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) ? intval($_GET['exerciseId']) : 0; $objExercise = new Exercise(); @@ -29,7 +30,7 @@ $headers = array( get_lang('LowestScore'), get_lang('AverageScore'), get_lang('HighestScore'), - get_lang('MaximumScore') + get_lang('Weighting') ); if (!empty($question_list)) { @@ -39,10 +40,10 @@ if (!empty($question_list)) { $data[$question_id]['name'] = cut($question_obj->question, 100); $data[$question_id]['students_who_try_exercise'] = $exercise_stats['users']; - $data[$question_id]['lowest_score'] = $exercise_stats['min']; - $data[$question_id]['average_score'] = $exercise_stats['average']; - $data[$question_id]['highest_score'] = $exercise_stats['max']; - $data[$question_id]['max_score'] = $question_obj->weighting; + $data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2); + $data[$question_id]['average_score'] = round($exercise_stats['average'], 2); + $data[$question_id]['highest_score'] = round($exercise_stats['max'], 2); + $data[$question_id]['max_score'] = round($question_obj->weighting, 2); } } @@ -80,6 +81,14 @@ $headers = array( $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices')); $interbreadcrumb[] = array ("url" => "admin.php?exerciseId=$exercise_id","name" => $objExercise->name); -$tpl = new Template(get_lang('Stats')); +$tpl = new Template(get_lang('ReportByQuestion')); + +//$actions = array(); +//$actions[]= array(get_lang('Back'), Display::return_icon('back.png', get_lang('Back'), 'exercise_report.php?'.$exercise_id)); +//$tpl->set_actions($actions); + +$actions = '' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').''; +$actions = Display::div($actions, array('class'=> 'actions')); +$content = $actions.$content; $tpl->assign('content', $content); $tpl->display_one_col_template(); diff --git a/main/exercice/testcategory.class.php b/main/exercice/testcategory.class.php index 04fa8c079d..39179962c2 100644 --- a/main/exercice/testcategory.class.php +++ b/main/exercice/testcategory.class.php @@ -14,7 +14,7 @@ class Testcategory { If you give an in_id and no in_name, you get info concerning the category of id=in_id otherwise, you've got an category objet avec your in_id, in_name, in_descr */ - function Testcategory($in_id=0, $in_name, $in_description="") { + function Testcategory($in_id=0, $in_name = '', $in_description="") { if ($in_id != 0 && $in_name == "") { $tmpobj = new Testcategory(); $tmpobj->getCategory($in_id); @@ -69,17 +69,20 @@ class Testcategory { } } - /** remove catagory with id=in_id from the database if no question use this category + /** + * Removes the category with id=in_id from the database if no question use this category + * @todo I'm removing the $in_id parameter because it seems that you're using $this->id instead of $in_id after confirmation delete this + * jmontoya */ - function removeCategory($in_id) { + //function removeCategory($in_id) { + function removeCategory() { $t_cattable = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); $v_id = Database::escape_string($this->id); $sql = "DELETE FROM $t_cattable WHERE id=$v_id AND c_id=".api_get_course_int_id(); $res = Database::query($sql); if (Database::affected_rows() <= 0) { return false; - } - else { + } else { return true; } } @@ -87,7 +90,8 @@ class Testcategory { /** modify category name or description of category with id=in_id */ - function modifyCategory($in_id, $in_name, $in_description) { + //function modifyCategory($in_id, $in_name, $in_description) { + function modifyCategory() { $t_cattable = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); $v_id = Database::escape_string($this->id); $v_name = Database::escape_string($this->name); @@ -102,18 +106,21 @@ class Testcategory { } } - /** get number of question of category id=in_id + /** + * Gets the number of question of category id=in_id + * @todo I'm removing the $in_id parameter because it seems that you're using $this->id instead of $in_id after confirmation delete this + * jmontoya */ - function getCategoryQuestionsNumber($in_id) { + //function getCategoryQuestionsNumber($in_id) { + function getCategoryQuestionsNumber() { $t_reltable = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); $in_id = Database::escape_string($this->id); $sql = "SELECT count(*) AS nb FROM $t_reltable WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); - $res = Database::query($sql, __FILE__, __LINE__); + $res = Database::query($sql); $row = Database::fetch_array($res); return $row['nb']; } - function display($in_color="#E0EBF5") { echo " + + {if $type == 'course'} +
+
+
+
+
+ + +
+
+
+ {/if} - +
\ No newline at end of file diff --git a/main/template/default/auth/courses_categories.php b/main/template/default/auth/courses_categories.php old mode 100755 new mode 100644 index 992409fcd9..e03412d31e --- a/main/template/default/auth/courses_categories.php +++ b/main/template/default/auth/courses_categories.php @@ -20,7 +20,33 @@ $stok = Security::get_token(); */ -if (intval($_GET['hidden_links']) != 1) { ?> +?> + + + +
@@ -110,6 +136,9 @@ if (intval($_GET['hidden_links']) != 1) { ?> if (!empty($search_term)) { echo "

".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."
"; } + + $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; + if (!empty($browse_courses_in_category)) { @@ -128,14 +157,13 @@ if (intval($_GET['hidden_links']) != 1) { ?> } else { $course_medium_image = api_get_path(WEB_IMG_PATH).'without_picture.png'; // without picture } + + $rating = Display::return_rating_system($course['code'].'_rating', $course['point_average'], $ajax_url.'&course_id='.$course['real_id'], $course['users_who_voted']); + //

'.get_lang('Teacher').'
'.$tutor_name.'
+ //
'.get_lang('CreationDate').'
'.api_format_date($creation_date,DATE_FORMAT_SHORT).'
echo '
-
-
-
'.$title.'
-
'.get_lang('Teacher').'
'.$tutor_name.'
-
'.get_lang('CreationDate').'
'.api_format_date($creation_date,DATE_FORMAT_SHORT).'
-
'; +
'; echo '
'; if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { @@ -144,18 +172,24 @@ if (intval($_GET['hidden_links']) != 1) { ?> echo ''; } else { echo ''; - } - - echo '
-
-
'.get_lang('ConnectionsLastMonth').'
'.$count_connections.'
'; + } + echo '
'; + + + echo '
+
'.cut($title, 60).'
+ '.$rating.' +
'; + + echo '
'.get_lang('ConnectionsLastMonth').'
'.$count_connections.'
'; echo '
'; echo '
-

Skills {$user.total_found_skills} / {$total_search_skills}

-
    - +

    {"Skills"|get_lang} {$user.total_found_skills} / {$total_search_skills}

    +
      {foreach $user['skills'] as $skill_data}
    • - {$skill_list[$skill_data.skill_id].name} - {if $skill_data.found} - * I have this skill * - {/if} - + {if !empty({$skill_list[$skill_data.skill_id].name})} + {$skill_list[$skill_data.skill_id].name} + {else} + {"SkillNotFound"|get_lang} + {/if} + {if $skill_data.found} + *{"IHaveThisSkill"|get_lang}* + {/if}
    • {/foreach}
    @@ -177,15 +155,13 @@ function checkLength( o, n, min, max ) { {/foreach} {/foreach} {else} -
    {"No results"|get_lang}
    +
    {"NoResults"|get_lang}
    {/if} - -