From 4052f7e562476fbe47ea96aa33ed03e5d874612b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Perales?= Date: Wed, 11 Dec 2013 22:16:38 -0500 Subject: [PATCH 1/6] Report, progress of exercise REFS BT#7017 --- main/inc/ajax/model.ajax.php | 39 +++++++++++++++++++- main/inc/lib/sessionmanager.lib.php | 57 ++++++++++++++++++++++++++++- main/mySpace/index.php | 17 ++++++--- main/mySpace/myspace.lib.php | 55 ++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 9 deletions(-) diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 53edf40451..32922a3cd7 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -239,14 +239,16 @@ switch ($action) { break; case 'get_session_lp_progress': case 'get_session_progress': - #$count = SessionManager::get_count_session_lp_progress(intval($_GET['session_id'])); - #break; $courses = SessionManager::get_course_list_by_session_id(intval($_GET['session_id'])); //TODO let select course $course = current($courses); $users = CourseManager::get_student_list_from_course_code($course['code'], true, intval($_GET['session_id'])); $count = count($users); break; + case 'get_exercise_progress': + $records = SessionManager::get_exercise_progress(intval($_GET['session_id'])); + $count = count($records); + break; /*case 'get_extra_fields': $type = $_REQUEST['type']; $obj = new ExtraField($type); @@ -563,6 +565,38 @@ switch ($action) { ) ); break; + case 'get_exercise_progress': + $sessionId = 0; + if (isset($_GET['session_id']) && !empty($_GET['session_id'])) + { + $sessionId = intval($_GET['session_id']); + $courses = SessionManager::get_course_list_by_session_id($sessionId); + //TODO let select course + $course = current($courses); + } + + $columns = array( + 'session', + 'exercise_id', + 'quiz_title', + 'username', + 'lastname', + 'firstname', + 'time', + 'question_id', + 'question', + 'answer', + 'correct' + ); + + $result = SessionManager::get_exercise_progress($sessionId, + array( + 'where' => $where_condition, + 'order' => "$sidx $sord", + 'limit'=> "$start , $limit" + ) + ); + break; case 'get_session_lp_progress': $sessionId = 0; if (isset($_GET['session_id']) && !empty($_GET['session_id'])) @@ -861,6 +895,7 @@ $allowed_actions = array( 'get_sessions_tracking', 'get_session_lp_progress', 'get_session_progress', + 'get_exercise_progress', 'get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_teacher', diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 52a84189e3..fa0035e4ed 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -501,6 +501,58 @@ class SessionManager $num = $row['total_rows']; return $num; } + /** + * Get the progress of a exercise + * @param int session id + * @return array + */ + public static function get_exercise_progress($sessionId = 0, $options = array()) + { + $session = Database::get_main_table(TABLE_MAIN_SESSION); + $user = Database::get_main_table(TABLE_MAIN_USER); + $quiz = Database::get_course_table(TABLE_QUIZ_TEST); + $quiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER); + $quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); + $table_stats_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); + $table_stats_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); + + $courses = SessionManager::get_course_list_by_session_id($sessionId); + //TODO let select course + $course = current($courses); + //TODO fix this + $course_info = array('real_id' => $course['id']); + + $sql = "SELECT + s.name as session, + CONCAT (q.c_id, q.id) as exercise_id, + q.title as quiz_title, + u.username, + u.lastname, + u.firstname, + a.tms as time, + qa.question_id, + qq.question, + qa.answer, + qa.correct + FROM $table_stats_attempt a + LEFT JOIN $quiz_answer qa ON a.answer = qa.id_auto + LEFT JOIN $quiz_question qq ON qq.id = qa.question_id + INNER JOIN $table_stats_exercises e ON e.exe_id = a.exe_id + INNER JOIN $session s ON s.id = a.session_id + INNER JOIN $quiz q ON q.id = e.exe_exo_id + INNER JOIN $user u ON u.user_id = a.user_id + WHERE a.session_id = %d + AND a.course_code = '%s'"; + + $sql_query = sprintf($sql, $sessionId, $course['code']); + + $rs = Database::query($sql_query); + while ($row = Database::fetch_array($rs)) + { + $data[] = $row; + } + return $data; + } /** * Gets the progress of learning paths in the given session * @param int session id @@ -520,6 +572,7 @@ class SessionManager //TODO fix this $course_info = array('real_id' => $course['id']); + //getting all the students of the course //we are not using this because it only returns user ids /*if (empty($sessionId) @@ -607,8 +660,8 @@ class SessionManager $forum_post = Database::get_course_table(TABLE_FORUM_POST); $tbl_course_lp = Database::get_course_table(TABLE_LP_MAIN); $wiki = Database::get_course_table(TABLE_WIKI); - $table_stats_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT); - $table_stats_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS); + $table_stats_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT); + $table_stats_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS); $courses = SessionManager::get_course_list_by_session_id($sessionId); //TODO let select course diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 945da9868b..bc55ab7c29 100644 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -160,7 +160,7 @@ echo ''. Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).''; echo ''; -if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview'))) { +if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview','exerciseprogress'))) { echo ''.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).''; if (!api_is_platform_admin()) { if (api_get_setting('add_users_by_coach') == 'true') { @@ -183,7 +183,7 @@ if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogres // Actions menu $nb_menu_items = count($menu_items); -if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) { +if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview', 'exerciseprogress'))) { if ($nb_menu_items > 1) { foreach ($menu_items as $key => $item) { echo $item; @@ -204,7 +204,7 @@ $sessionFilter->addElement('select_ajax', 'session_name', get_lang('SearchCourse $courseListUrl = api_get_self(); #show filter by session -if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) { +if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview', 'exerciseprogress'))) { echo '
'; echo $sessionFilter->return_form(); echo '
'; @@ -608,6 +608,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst echo ' | '.get_lang('DisplayAccessOverview').''; echo ' | '.get_lang('DisplayLpProgressOverview').''; echo ' | '.get_lang('DisplayProgressOverview').''; + echo ' | '.get_lang('DisplayExerciseProgress').''; echo ' | '.get_lang('DisplayCourseOverview').''; echo ' | '.get_lang('LPQuestionListResults').''; echo ' | '.get_lang('LPExerciseResultsBySession').''; @@ -625,13 +626,19 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst } } else if($display == 'lpprogressoverview') { if (!empty($_GET['session_id'])) { - echo MySpace::display_tracking_lp_progress_overview($_GET['session_id']); + echo MySpace::display_tracking_lp_progress_overview(intval($_GET['session_id'])); } else { Display::display_warning_message(get_lang('ChooseSession')); } } else if($display == 'progressoverview') { if (!empty($_GET['session_id'])) { - echo MySpace::display_tracking_progress_overview($_GET['session_id']); + echo MySpace::display_tracking_progress_overview(intval($_GET['session_id'])); + } else { + Display::display_warning_message(get_lang('ChooseSession')); + } + } else if($display == 'exerciseprogress') { + if (!empty($_GET['session_id'])) { + echo MySpace::display_tracking_exercise_progress_overview(intval($_GET['session_id'])); } else { Display::display_warning_message(get_lang('ChooseSession')); } diff --git a/main/mySpace/myspace.lib.php b/main/mySpace/myspace.lib.php index 86e190556a..e54f3a5b4f 100644 --- a/main/mySpace/myspace.lib.php +++ b/main/mySpace/myspace.lib.php @@ -320,6 +320,61 @@ class MySpace { $table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true); + $return = ''; + $return .= Display::grid_html('lps'); + return $return; + } + /** + * Display a sortable table that contains an overview off all the progress of the user in a session + * @author César Perales , Beeznest Team + */ + function display_tracking_exercise_progress_overview($sessionId = 0) { + + $courses = SessionManager::get_course_list_by_session_id($sessionId); + //TODO let select course + $course = current($courses); + /** + * Column name + * The order is important you need to check the $column variable in the model.ajax.php file + */ + $columns = array( + get_lang('Session'), + get_lang('ExerciseId'), + get_lang('QuizTitle'), + get_lang('Username'), + get_lang('Lastname'), + get_lang('Firstname'), + get_lang('Time'), + get_lang('Question_id'), + get_lang('Question'), + get_lang('Answer'), + get_lang('Correct'), + ); + + /** + * Column config + */ + $column_model = array( + array('name'=>'session', 'index'=>'session', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), + array('name'=>'exercise_id', 'index'=>'exercise_id', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'quiz_title', 'index'=>'quiz_title', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'username', 'index'=>'username', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'time', 'index'=>'time', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'question_id', 'index'=>'question_id', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'question', 'index'=>'question', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'answer', 'index'=>'answer', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + array('name'=>'correct', 'index'=>'correct', 'width'=>'100', 'align'=>'left', 'search' => 'true'), + ); + //get dinamic column names + + $action_links = ''; + // jqgrid will use this URL to do the selects + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . intval($sessionId); + $table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true); + + $return = ''; $return .= Display::grid_html('lps'); return $return; From 4fa13af1cc474b414208836d50ea13def4f7b0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Perales?= Date: Wed, 11 Dec 2013 22:44:09 -0500 Subject: [PATCH 2/6] Reports, adding select options REFS BT#7017 --- main/inc/lib/sessionmanager.lib.php | 67 +++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index fa0035e4ed..9dd67d0daa 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -522,6 +522,23 @@ class SessionManager //TODO fix this $course_info = array('real_id' => $course['id']); + $where = " WHERE a.session_id = %d + AND a.course_code = '%s'"; + + $limit = null; + if (!empty($options['limit'])) { + $limit = " LIMIT ".$options['limit']; + } + + if (!empty($options['where'])) { + $where .= ' AND '.$options['where']; + } + + $order = null; + if (!empty($options['order'])) { + $order = " ORDER BY ".$options['order']; + } + $sql = "SELECT s.name as session, CONCAT (q.c_id, q.id) as exercise_id, @@ -541,8 +558,8 @@ class SessionManager INNER JOIN $session s ON s.id = a.session_id INNER JOIN $quiz q ON q.id = e.exe_exo_id INNER JOIN $user u ON u.user_id = a.user_id - WHERE a.session_id = %d - AND a.course_code = '%s'"; + $where $order $limit"; + $sql_query = sprintf($sql, $sessionId, $course['code']); @@ -583,11 +600,28 @@ class SessionManager // Registered students in session. $users = CourseManager :: get_student_list_from_course_code($course_code, true, $sessionId); }*/ - $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code FROM $session_course_user s - INNER JOIN $user u ON u.user_id = s.id_user - WHERE course_code = '%s' + $where = " WHERE course_code = '%s' AND s.status <> 2 and id_session = %s"; + $limit = null; + if (!empty($options['limit'])) { + $limit = " LIMIT ".$options['limit']; + } + + if (!empty($options['where'])) { + $where .= ' AND '.$options['where']; + } + + $order = null; + if (!empty($options['order'])) { + $order = " ORDER BY ".$options['order']; + } + + $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code + FROM $session_course_user s + INNER JOIN $user u ON u.user_id = s.id_user + $where $order $limit"; + $sql_query = sprintf($sql, $course['code'], $sessionId); $rs = Database::query($sql_query); @@ -679,11 +713,28 @@ class SessionManager // Registered students in session. $users = CourseManager :: get_student_list_from_course_code($course_code, true, $sessionId); }*/ - $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code FROM $session_course_user s - INNER JOIN $user u ON u.user_id = s.id_user - WHERE course_code = '%s' + $where = " WHERE course_code = '%s' AND s.status <> 2 and id_session = %s"; + $limit = null; + if (!empty($options['limit'])) { + $limit = " LIMIT ".$options['limit']; + } + + if (!empty($options['where'])) { + $where .= ' AND '.$options['where']; + } + + $order = null; + if (!empty($options['order'])) { + $order = " ORDER BY ".$options['order']; + } + + $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code + FROM $session_course_user s + INNER JOIN $user u ON u.user_id = s.id_user + $where $order $limit"; + $sql_query = sprintf($sql, $course['code'], $sessionId); $rs = Database::query($sql_query); From cbae5fba116ff97c685dafd05eebd2bedcc479ea Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 12 Dec 2013 10:29:19 +0100 Subject: [PATCH 3/6] Updating license. --- license.txt | 1 - .../ajaxfilemanager/_ajax_get_details_listing.php | 6 ++++++ .../ajaxfilemanager/_ajax_get_thumbnail_listing.php | 7 ++++++- .../plugins/ajaxfilemanager/_ajax_load_folders.php | 7 ++++++- .../plugins/ajaxfilemanager/ajax_create_folder.php | 7 ++++++- .../plugins/ajaxfilemanager/ajax_delete_file.php | 7 ++++++- .../plugins/ajaxfilemanager/ajax_editor_reset.php | 7 ++++++- .../editor/plugins/ajaxfilemanager/ajax_file_copy.php | 9 +++------ .../editor/plugins/ajaxfilemanager/ajax_file_paste.php | 7 ++++++- .../plugins/ajaxfilemanager/ajax_file_upload.php | 6 ++++++ .../plugins/ajaxfilemanager/ajax_get_file_listing.php | 6 ++++++ .../ajaxfilemanager/ajax_get_folder_listing.php | 7 ++++++- .../editor/plugins/ajaxfilemanager/ajax_image_save.php | 10 +++------- .../editor/plugins/ajaxfilemanager/ajax_image_undo.php | 10 ++++------ .../editor/plugins/ajaxfilemanager/ajax_login.php | 6 ++++++ .../editor/plugins/ajaxfilemanager/ajax_preview.php | 7 ++++++- .../plugins/ajaxfilemanager/ajax_save_as_form.php | 7 ++++++- .../editor/plugins/ajaxfilemanager/ajax_save_name.php | 7 ++++++- .../editor/plugins/ajaxfilemanager/ajax_save_text.php | 7 +++++++ 19 files changed, 101 insertions(+), 30 deletions(-) diff --git a/license.txt b/license.txt index 0e533d4c7f..ebf52bd32f 100644 --- a/license.txt +++ b/license.txt @@ -11,7 +11,6 @@ Copyright (c) 2003-2007 Ghent University (UGent) Copyright (c) 2001-2004 Universite catholique de Louvain (UCL) Copyright (c) 2003-2008 Vrije Universiteit Brussel (VUB) Copyright (c) 2004-2008 Hoogeschool Gent (HoGent) -Copyright (c) Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn) For a full list of contributors detaining copyrights over parts of the Chamilo software, see "documentation/credits.html". diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_details_listing.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_details_listing.php index 0382d425bf..744ec6f71f 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_details_listing.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_details_listing.php @@ -1,5 +1,11 @@ getLastestRestorable(); diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_login.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_login.php index 509658f51c..bb472f779b 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_login.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_login.php @@ -1,5 +1,11 @@ Date: Thu, 12 Dec 2013 10:31:13 +0100 Subject: [PATCH 4/6] Minor - removing global value. --- main/admin/course_request_accepted.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/main/admin/course_request_accepted.php b/main/admin/course_request_accepted.php index 729ce89d8b..360e42f0d0 100644 --- a/main/admin/course_request_accepted.php +++ b/main/admin/course_request_accepted.php @@ -41,7 +41,6 @@ $course_validation_feature = api_get_setting('course_validation') == 'true'; $delete_course_request = intval($_GET['delete_course_request']); $message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))); $is_error_message = !empty($_GET['is_error_message']); -$keyword = Database::escape_string(trim($_GET['keyword'])); if ($course_validation_feature) { @@ -99,12 +98,8 @@ function get_number_of_requests() { * Get course data to display */ function get_request_data($from, $number_of_items, $column, $direction) { - global $keyword; - + $keyword = Database::escape_string(trim($_GET['keyword'])); $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); - $users_table = Database :: get_main_table(TABLE_MAIN_USER); - $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $sql = "SELECT id AS col0, code AS col1, title AS col2, From 092a136e64c794f24e04ee7acc0abb22faff6b76 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 12 Dec 2013 12:33:09 +0100 Subject: [PATCH 5/6] Using api_is_allowed_in_course() in dropbox. --- main/dropbox/dropbox_init.inc.php | 2 +- main/inc/lib/main_api.lib.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main/dropbox/dropbox_init.inc.php b/main/dropbox/dropbox_init.inc.php index b6b205a012..e233631c2b 100644 --- a/main/dropbox/dropbox_init.inc.php +++ b/main/dropbox/dropbox_init.inc.php @@ -125,7 +125,7 @@ $language_file = array('dropbox', 'document'); // including the basic Chamilo initialisation file require_once '../inc/global.inc.php'; -$is_allowed_in_course = api_is_allowed_to_edit(false, true); +$is_allowed_in_course = api_is_allowed_in_course(); $is_courseTutor = api_is_course_tutor(); $is_courseAdmin = api_is_course_admin(); $current_course_tool = TOOL_DROPBOX; diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 4a45fe31a4..b2380936fd 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -6782,3 +6782,11 @@ function api_can_login_as($loginAsUserId, $userId = null) return (api_is_platform_admin() OR (api_is_session_admin() && $user_info['status'] == 5) OR $isDrh()); } + +/** + * @return bool + */ +function api_is_allowed_in_course() +{ + return Session::read('is_allowed_in_course'); +} \ No newline at end of file From f528198ea2c0055fa8840c3ee83defae74366d3f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 12 Dec 2013 14:49:08 +0100 Subject: [PATCH 6/6] Fixing typo. --- main/dropbox/dropbox_functions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index 3dc4669882..46a37ade8c 100644 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -40,7 +40,7 @@ function handle_multiple_actions() } // STEP 2: at least one file has to be selected. If not we return an error message - $ids = issset($_GET['id']) ? $_GET['id'] : array(); + $ids = isset($_GET['id']) ? $_GET['id'] : array(); if (count($ids)>0) { $checked_file_ids = $_POST['id']; } else {