diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 38361ab801..8bac4d4ddf 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -203,6 +203,9 @@ switch ($action) { } $count = SessionManager::get_count_admin($where_condition); break; + case 'get_session_lp_progress': + $count = SessionManager::get_count_session_lp_progress($_GET['session_id']); + break; /*case 'get_extra_fields': $type = $_REQUEST['type']; $obj = new ExtraField($type); @@ -431,6 +434,23 @@ switch ($action) { ) ); break; + case 'get_session_lp_progress': + $columns = array( + 'username', 'firstname', 'lastname', 'name', 'progress' + ); + $sessionId = 0; + if (isset($_GET['session_id']) && !empty($_GET['session_id'])) + { + $sessionId = intval($_GET['session_id']); + } + $result = SessionManager::get_session_lp_progress($sessionId, + array( + 'where' => $where_condition, + 'order' => "$sidx $sord", + 'limit'=> "$start , $limit" + ) + ); + break; case 'get_timelines': $columns = array('headline', 'actions'); @@ -630,6 +650,7 @@ $allowed_actions = array( 'get_usergroups_teacher', 'get_gradebooks', 'get_sessions', + 'get_session_lp_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 87542a51e4..d1bb0ded26 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -475,10 +475,83 @@ class SessionManager $formatted_sessions[] = $session; } } - return $formatted_sessions; } + /** + * Get total of records for progress of learning paths in the given session + * @param int session id + * @return int + */ + public static function get_count_session_lp_progress($sessionId = 0) { + $tbl_lp = Database::get_course_table(TABLE_LP_MAIN); + $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW); + $tbl_user = Database::get_main_table(TABLE_MAIN_USER); + $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); + + $sql = "select count(*) as total_rows + FROM $tbl_lp_view v + INNER JOIN $tbl_lp l ON l.id = v.lp_id + INNER JOIN $tbl_user u ON u.user_id = v.user_id + INNER JOIN $tbl_course c"; + $sql .= ' WHERE v.session_id = ' . $sessionId; + $result_rows = Database::query($sql); + $row = Database::fetch_array($result_rows); + $num = $row['total_rows']; + return $num; + } + /** + * Gets the progress of learning paths in the given session + * @param int session id + * @param array options order and limit keys + * @return array table with user name, lp name, progress + */ + public static function get_session_lp_progress($sessionId = 0, $options) + { + $tbl_lp = Database::get_course_table(TABLE_LP_MAIN); + $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW); + $tbl_user = Database::get_main_table(TABLE_MAIN_USER); + $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); + + + $select = "select u.username, u.firstname, u.lastname, l.name, v.progress + FROM $tbl_lp_view v + INNER JOIN $tbl_lp l ON l.id = v.lp_id + INNER JOIN $tbl_user u ON u.user_id = v.user_id + INNER JOIN $tbl_course c + "; + + $where = ' WHERE 1=1 '; + if (!empty($options['where'])) { + $where .= ' AND '.$options['where']; + } + + $where .= ' AND v.session_id = ' . $sessionId; + + $order = null; + if (!empty($options['order'])) { + $order = " ORDER BY ".$options['order']; + } + $limit = null; + if (!empty($options['limit'])) { + $limit = " LIMIT ".$options['limit']; + } + + $select .= $where.$order.$limit; + error_log($select); + $result = Database::query($select); + $formatted_sessions = array(); + if (Database::num_rows($result) > 0) { + while ($row = Database::fetch_assoc($result)) { + error_log(print_r($row,1)); + $formatted_sessions[] = $row; + } + /*foreach ($lps as $lp) { + error_log(print_r($lp,1)); + }*/ + } + return $formatted_sessions; + } /** * Creates a new course code based in given code * diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 6c44383a4a..73b70eb74d 100644 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -18,6 +18,7 @@ require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php'; require_once 'myspace.lib.php'; +$htmlHeadXtra[] = api_get_jqgrid_js(); // the section (for the tabs) $this_section = SECTION_TRACKING; //for HTML editor repository @@ -158,7 +159,7 @@ echo ''. Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).''; echo ''; -if (!empty($session_id) && $display != 'accessoverview') { +if (!empty($session_id) && !in_array($display, array('accessoverview','progressoverview'))) { 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') { @@ -182,7 +183,7 @@ if (!empty($session_id) && $display != 'accessoverview') { // Actions menu $nb_menu_items = count($menu_items); -if (empty($session_id) || $display == 'accessoverview') { +if (empty($session_id) || in_array($display, array('accessoverview','progressoverview'))) { if ($nb_menu_items > 1) { foreach ($menu_items as $key => $item) { echo $item; @@ -201,17 +202,20 @@ if (empty($session_id) || $display == 'accessoverview') { } $sessionFilter->addElement('select_ajax', 'session_name', get_lang('SearchCourseBySession'), null, array('url' => $url, 'defaults' => $sessionList)); $courseListUrl = api_get_self(); - if ($is_platform_admin && $view == 'admin' && $display == 'accessoverview') { + + #show filter by session + if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','progressoverview'))) { echo '