diff --git a/main/forum/reply.php b/main/forum/reply.php index 40c0341ab5..473cfde914 100755 --- a/main/forum/reply.php +++ b/main/forum/reply.php @@ -67,7 +67,11 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) { } if ($current_forum['forum_of_group'] != 0) { - $show_forum = GroupManager::user_has_access(api_get_user_id(), $current_forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM); + $show_forum = GroupManager::user_has_access( + api_get_user_id(), + $current_forum['forum_of_group'], + GroupManager::GROUP_TOOL_FORUM + ); if (!$show_forum) { api_not_allowed(); } @@ -90,25 +94,52 @@ if (!empty($gradebook) && $gradebook == 'view') { if ($origin == 'group') { $_clean['toolgroup'] = (int)$_SESSION['toolgroup']; $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']); - $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups')); - $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']); - $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']); - $interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']); - $interbreadcrumb[] = array('url' => 'javascript: void(0);', 'name' => get_lang('Reply')); + $interbreadcrumb[] = array( + 'url' => '../group/group.php?'.api_get_cidreq(), + 'name' => get_lang('Groups'), + ); + $interbreadcrumb[] = array( + 'url' => '../group/group_space.php?'.api_get_cidreq(), + 'name' => get_lang('GroupSpace').' '.$group_properties['name'], + ); + $interbreadcrumb[] = array( + 'url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), + 'name' => $current_forum['forum_title'], + ); + $interbreadcrumb[] = array( + 'url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(), + 'name' => $current_thread['thread_title'], + ); + $interbreadcrumb[] = array( + 'url' => 'javascript: void(0);', + 'name' => get_lang('Reply'), + ); } else { - $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook, 'name' => $nameTools); - $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']); - $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']); - $interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']); + $interbreadcrumb[] = array( + 'url' => 'index.php?gradebook='.$gradebook, + 'name' => $nameTools, + ); + $interbreadcrumb[] = array( + 'url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&'.api_get_cidreq(), + 'name' => $current_forum_category['cat_title'], + ); + $interbreadcrumb[] = array( + 'url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), + 'name' => $current_forum['forum_title'], + ); + $interbreadcrumb[] = array( + 'url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(), + 'name' => $current_thread['thread_title'], + ); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Reply')); } /* Resource Linker */ -if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Resources')) { - $_SESSION['formelements'] = $_POST; - $_SESSION['origin'] = $_SERVER['REQUEST_URI']; - $_SESSION['breadcrumbs'] = $interbreadcrumb; +if (isset($_POST['add_resources']) && $_POST['add_resources'] == get_lang('Resources')) { + $_SESSION['formelements'] = $_POST; + $_SESSION['origin'] = $_SERVER['REQUEST_URI']; + $_SESSION['breadcrumbs'] = $interbreadcrumb; header('Location: ../resourcelinker/resourcelinker.php'); exit; } @@ -151,7 +182,9 @@ if ($origin != 'learnpath') { } /*New display forum div*/ echo '
'; -echo '

'.prepare4display($current_forum['forum_title']).'

'; +echo '

'. + prepare4display($current_forum['forum_title']).'

'; echo '

'.prepare4display($current_forum['forum_comment']).'

'; echo '
'; /* End new display forum */ @@ -159,7 +192,13 @@ echo ''; $my_action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $my_post = isset($_GET['post']) ? Security::remove_XSS($_GET['post']) : ''; $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : ''; -$values = show_add_post_form($current_forum, $forum_setting, $my_action, $my_post, $my_elements); +$values = show_add_post_form( + $current_forum, + $forum_setting, + $my_action, + $my_post, + $my_elements +); if (!empty($values) AND isset($_POST['SubmitPost'])) { $result = store_reply($current_forum, $values); //@todo split the show_add_post_form function diff --git a/main/img/icons/32/group_na.png b/main/img/icons/32/group_na.png new file mode 100644 index 0000000000..2ec1acdfb5 Binary files /dev/null and b/main/img/icons/32/group_na.png differ diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index bd9382033f..18df3893d5 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -186,6 +186,11 @@ if (!$sidx) { //@todo rework this switch ($action) { + case 'get_group_reporting': + $course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : null; + $group_id = isset($_REQUEST['gidReq']) ? $_REQUEST['gidReq'] : null; + $count = Tracking::get_group_reporting($course_id, $group_id, 'count'); + break; case 'get_user_course_report': case 'get_user_course_report_resumed': $userId = api_get_user_id(); @@ -563,6 +568,20 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit $columns = array(); switch ($action) { + case 'get_group_reporting': + $columns = array('name', 'time', 'progress', 'score', 'works', 'messages', 'actions'); + + $result = Tracking::get_group_reporting( + $course_id, + $group_id, + 'all', + $start, + $limit, + $sidx, + $sord, + $whereCondition + ); + break; case 'get_course_exercise_medias': $columns = array('question'); $result = Question::get_course_medias( @@ -1555,7 +1574,8 @@ $allowed_actions = array( //'get_course_exercise_medias', 'get_user_course_report', 'get_user_course_report_resumed', - 'get_exercise_grade' + 'get_exercise_grade', + 'get_group_reporting' ); //5. Creating an obj to return a json diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 841c2be92d..4ad9afbe00 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1699,6 +1699,7 @@ class CourseManager * @param string $date_from * @param string $date_to * @param boolean $includeInvitedUsers Whether include the invited users + * @param int $groupId * @return array with user id */ public static function get_student_list_from_course_code( @@ -1707,7 +1708,8 @@ class CourseManager $session_id = 0, $date_from = null, $date_to = null, - $includeInvitedUsers = true + $includeInvitedUsers = true, + $groupId = 0 ) { $userTable = Database::get_main_table(TABLE_MAIN_USER); @@ -1715,28 +1717,37 @@ class CourseManager $course_code = Database::escape_string($course_code); $courseInfo = api_get_course_info($course_code); $courseId = $courseInfo['real_id']; - $students = array(); if ($session_id == 0) { - // students directly subscribed to the course - $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " cu - INNER JOIN $userTable u - ON cu.user_id = u.user_id - WHERE c_id = '$courseId' AND cu.status = " . STUDENT; - - if (!$includeInvitedUsers) { - $sql .= " AND u.status != " . INVITEE; - } - - $rs = Database::query($sql); - while ($student = Database::fetch_array($rs)) { - $students[$student['user_id']] = $student; + if (empty($groupId)) { + // students directly subscribed to the course + $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu + INNER JOIN $userTable u + ON cu.user_id = u.user_id + WHERE c_id = '$courseId' AND cu.status = ".STUDENT; + + if (!$includeInvitedUsers) { + $sql .= " AND u.status != ".INVITEE; + } + $rs = Database::query($sql); + while ($student = Database::fetch_array($rs)) { + $students[$student['user_id']] = $student; + } + } else { + $students = GroupManager::get_users( + $groupId, + false, + null, + null, + false, + $courseInfo['real_id'] + ); + $students = array_flip($students); } } // students subscribed to the course through a session - if ($with_session) { $joinSession = ""; diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index f6e31994e6..f0e4146cf6 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -1001,6 +1001,7 @@ class GroupManager $user_table = Database :: get_main_table(TABLE_MAIN_USER); $group_id = intval($group_id); + if (empty($courseId)) { $courseId = api_get_course_int_id(); } else { @@ -1028,7 +1029,6 @@ class GroupManager $limit = intval($limit); $sql .= " LIMIT $start, $limit"; } - $res = Database::query($sql); $users = array(); while ($obj = Database::fetch_object($res)) { @@ -2234,7 +2234,7 @@ class GroupManager $groupNameClass = 'muted'; } - $group_name = ''. + $group_name = ''. Security::remove_XSS($this_group['name']).' '; if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) { $group_name .= Display::label(get_lang('OneMyGroups'), 'success'); @@ -2289,9 +2289,9 @@ class GroupManager // Self-registration / unregistration if (!api_is_allowed_to_edit(false, true)) { if (self :: is_self_registration_allowed($user_id, $this_group['id'])) { - $row[] = ''.get_lang('GroupSelfRegInf').''; + $row[] = ''.get_lang('GroupSelfRegInf').''; } elseif (self :: is_self_unregistration_allowed($user_id, $this_group['id'])) { - $row[] = ''.get_lang('GroupSelfUnRegInf').''; + $row[] = ''.get_lang('GroupSelfUnRegInf').''; } else { $row[] = '-'; } @@ -2306,10 +2306,10 @@ class GroupManager Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).' '; if ($this_group['status'] == 1) { - $edit_actions .= '' . + $edit_actions .= '' . Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . ' '; } else { - $edit_actions .= '' . + $edit_actions .= '' . Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . ' '; } @@ -2319,13 +2319,13 @@ class GroupManager $edit_actions .= ''. Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL).' '; - /*$edit_actions .= ''. + /*$edit_actions .= ''. Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).' ';*/ - $edit_actions .= ''. + $edit_actions .= ''. Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).' '; - $edit_actions .= ''. + $edit_actions .= ''. Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).' '; $row[] = $edit_actions; diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 7e512a60e7..4b49ea4cce 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -14,6 +14,74 @@ use CpChart\Classes\pImage as pImage; */ class Tracking { + public static function get_group_reporting( + $course_id, + $group_id = null, + $type = 'all', + $start = 0, + $limit = 1000, + $sidx = 1, + $sord = 'desc', + $where_condition = array() + ) { + if (empty($course_id)) { + return null; + } + $course_info = api_get_course_info_by_id($course_id); + $table_group = Database :: get_course_table(TABLE_GROUP); + $course_id = intval($course_id); + + $select = ' * '; + if ($type == 'count') { + $select = ' count(id) as count '; + } + + $default_where = array('c_id = ? ' => array($course_id)); + + $result = Database::select($select, $table_group, array( + 'limit' => " $start, $limit", + 'where' => $default_where, + 'order' => "$sidx $sord") + ); + + if ($type == 'count') { + return $result[0]['count']; + } + + $parsed_result = array(); + if (!empty($result)) { + foreach ($result as $group) { + $users = GroupManager::get_users($group['id'], true); + + $time = 0; + $avg_student_score = 0; + $avg_student_progress = 0; + $work = 0; + $messages = 0; + + foreach ($users as $user_data) { + $time += Tracking::get_time_spent_on_the_course($user_data['user_id'], $course_info['code'], 0); + $avg_student_score += Tracking::get_avg_student_score($user_data['user_id'], $course_info['code'], array(), 0); + $avg_student_progress += Tracking::get_avg_student_progress($user_data['user_id'], $course_info['code'], array(), 0); + $work += Tracking::count_student_assignments($user_data['user_id'], $course_info['code'], 0); + $messages += Tracking::count_student_messages($user_data['user_id'], $course_info['code'], 0); + } + + $group_item = array( + 'id' => $group['id'], + 'name' => $group['name'], + 'time' => api_time_to_hms($time), + 'progress' => $avg_student_progress, + 'score' => $avg_student_score, + 'works' => $work, + 'messages' => $messages, + ); + $parsed_result[] = $group_item; + } + } + return $parsed_result; + } + /** * @param int $user_id * @param array $courseInfo @@ -3245,6 +3313,7 @@ class Tracking $rs = Database::query($sql); $row = Database::fetch_array($rs, 'ASSOC'); $count = $row['count']; + return $count; } @@ -3254,32 +3323,46 @@ class Tracking * @param int Session id (optional), if param $session_id is * null(default) it'll return results including sessions, * 0 = session is not filtered + * @param int $groupId * @return int The number of post by course */ - public static function count_number_of_posts_by_course($course_code, $session_id = null) + public static function count_number_of_posts_by_course($course_code, $session_id = null, $groupId = 0) { - $a_course = CourseManager :: get_course_information($course_code); - if (!empty($a_course)) { - $tbl_posts = Database :: get_course_table(TABLE_FORUM_POST); - $tbl_forums = Database :: get_course_table(TABLE_FORUM); + $courseInfo = api_get_course_info($course_code); + if (!empty($courseInfo)) { + $tbl_posts = Database :: get_course_table(TABLE_FORUM_POST); + $tbl_forums = Database :: get_course_table(TABLE_FORUM); $condition_session = ''; if (isset($session_id)) { $session_id = intval($session_id); - $condition_session = ' AND f.session_id = '. $session_id; + $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id'); } - $course_id = $a_course['real_id']; + $course_id = $courseInfo['real_id']; + $groupId = intval($groupId); + if (!empty($groupId)) { + $groupCondition = " i.to_group_id = $groupId "; + } else { + $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) "; + } - $sql = "SELECT count(*) FROM $tbl_posts p INNER JOIN $tbl_forums f - ON f.forum_id = p.forum_id - WHERE p.c_id = $course_id AND - f.c_id = $course_id - $condition_session + $item = Database :: get_course_table(TABLE_ITEM_PROPERTY); + $sql = "SELECT count(*) FROM $tbl_posts p + INNER JOIN $tbl_forums f + ON f.forum_id = p.forum_id AND p.c_id = f.c_id + INNER JOIN $item i + ON (tool = '".TOOL_FORUM."' AND f.c_id = i.c_id AND f.iid = i.ref) + WHERE + p.c_id = $course_id AND + f.c_id = $course_id AND + $groupCondition + $condition_session "; $result = Database::query($sql); $row = Database::fetch_row($result); $count = $row[0]; + return $count; } else { return null; @@ -3292,31 +3375,60 @@ class Tracking * @param int Session id (optional), * if param $session_id is null(default) it'll return results including * sessions, 0 = session is not filtered + * @param int $groupId * @return int The number of threads by course */ - public static function count_number_of_threads_by_course($course_code, $session_id = null) + public static function count_number_of_threads_by_course($course_code, $session_id = null, $groupId = 0) { $course_info = api_get_course_info($course_code); if (empty($course_info)) { return null; } + $course_id = $course_info['real_id']; $tbl_threads = Database :: get_course_table(TABLE_FORUM_THREAD); - $tbl_forums = Database :: get_course_table(TABLE_FORUM); + $tbl_forums = Database :: get_course_table(TABLE_FORUM); + $condition_session = ''; if (isset($session_id)) { $session_id = intval($session_id); - $condition_session = ' AND f.session_id = '. $session_id; + $condition_session = ' AND f.session_id = '. $session_id; } - $sql = "SELECT count(*) FROM $tbl_threads t INNER JOIN $tbl_forums f ON f.forum_id = t.forum_id - WHERE t.c_id = $course_id AND f.c_id = $course_id $condition_session "; + $groupId = intval($groupId); + + if (!empty($groupId)) { + $groupCondition = " i.to_group_id = $groupId "; + } else { + $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) "; + } + + $item = Database :: get_course_table(TABLE_ITEM_PROPERTY); + $sql = "SELECT count(*) + FROM $tbl_threads t + INNER JOIN $tbl_forums f + ON f.iid = t.forum_id AND f.c_id = t.c_id + INNER JOIN $item i + ON ( + tool = '".TOOL_FORUM_THREAD."' AND + f.c_id = i.c_id AND + t.iid = i.ref + ) + WHERE + t.c_id = $course_id AND + f.c_id = $course_id AND + $groupCondition + $condition_session + "; + $result = Database::query($sql); if (Database::num_rows($result)) { $row = Database::fetch_row($result); $count = $row[0]; + return $count; } else { + return null; } } @@ -3327,9 +3439,10 @@ class Tracking * @param int Session id (optional), * if param $session_id is null(default) it'll return results * including sessions, 0 = session is not filtered + * @param int $groupId * @return int The number of forums by course */ - public static function count_number_of_forums_by_course($course_code, $session_id = null) + public static function count_number_of_forums_by_course($course_code, $session_id = null, $groupId = 0) { $course_info = api_get_course_info($course_code); if (empty($course_info)) { @@ -3340,11 +3453,28 @@ class Tracking $condition_session = ''; if (isset($session_id)) { $session_id = intval($session_id); - $condition_session = ' session_id = '. $session_id; + $condition_session = ' AND f.session_id = '. $session_id; + } + + $groupId = intval($groupId); + if (!empty($groupId)) { + $groupCondition = " i.to_group_id = $groupId "; + } else { + $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) "; } $tbl_forums = Database :: get_course_table(TABLE_FORUM); - $sql = "SELECT count(*) FROM $tbl_forums WHERE c_id = $course_id AND $condition_session"; + $item = Database :: get_course_table(TABLE_ITEM_PROPERTY); + + $sql = "SELECT count(*) + FROM $tbl_forums f + INNER JOIN $item i + ON f.c_id = i.c_id AND f.iid = i.ref AND tool = '".TOOL_FORUM."' + WHERE + f.c_id = $course_id AND + $groupCondition + $condition_session + "; $result = Database::query($sql); if (Database::num_rows($result)) { $row = Database::fetch_row($result); diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index 8dcad8b09a..17361f19f0 100755 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -219,6 +219,10 @@ Display::display_header($nameTools, 'Tracking'); echo '
'; echo Display::return_icon('user_na.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM); +echo Display::url( + Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), + 'course_log_groups.php?'.api_get_cidreq() +); echo Display::url( Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_tools.php?'.api_get_cidreq() diff --git a/main/tracking/course_log_groups.php b/main/tracking/course_log_groups.php new file mode 100644 index 0000000000..ec428c87e1 --- /dev/null +++ b/main/tracking/course_log_groups.php @@ -0,0 +1,127 @@ + 'name', + 'index' => 'name', + 'width' => '200', + 'align' => 'left', + ), + array( + 'name' => 'time', + 'index' => 'time', + 'width' => '50', + 'align' => 'left', + 'sortable' => 'false', + ), + array( + 'name' => 'progress', + 'index' => 'progress', + 'width' => '50', + 'align' => 'left', + 'sortable' => 'false', + ), + array( + 'name' => 'score', + 'index' => 'score', + 'width' => '50', + 'align' => 'left', + 'sortable' => 'false', + ), + array( + 'name' => 'works', + 'index' => 'works', + 'width' => '50', + 'align' => 'left', + 'sortable' => 'false', + ), + array( + 'name' => 'messages', + 'index' => 'messages', + 'width' => '50', + 'align' => 'left', + 'sortable' => 'false', + ), + array( + 'name' => 'actions', + 'index' => 'actions', + 'width' => '50', + 'align' => 'left', + 'formatter' => 'action_formatter', + 'sortable' => 'false', + ), +); + +// Autowidth +$extra_params['autowidth'] = 'true'; +// height auto +$extra_params['height'] = 'auto'; + +$action_links = ' +function action_formatter(cellvalue, options, rowObject) { + return \''.Display::return_icon('2rightarrow.gif',get_lang('Edit'),'',ICON_SIZE_SMALL).''. + '\'; +}'; + + +// Add the JS needed to use the jqgrid +$htmlHeadXtra[] = api_get_jqgrid_js(); + +$htmlHeadXtra[] = ' +'; + +Display::display_header(); + +echo '
'; +echo Display::url(Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM), 'courseLog.php?'.api_get_cidreq(true, false)); +echo Display::url(Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), '#'); +echo Display::url(Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_tools.php?'.api_get_cidreq(true, false)); +echo Display::url(Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_resources.php?'.api_get_cidreq(true, false)); +echo '
'; + +echo Display::grid_html('group_users'); + +Display::display_footer(); diff --git a/main/tracking/course_log_resources.php b/main/tracking/course_log_resources.php index e09d86249d..ba7c4d640c 100755 --- a/main/tracking/course_log_resources.php +++ b/main/tracking/course_log_resources.php @@ -65,6 +65,11 @@ echo Display::url( api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq() ); +echo Display::url( + Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), + 'course_log_groups.php?'.api_get_cidreq(true, false) +); + echo Display::url( Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'tracking/course_log_tools.php?'.api_get_cidreq() diff --git a/main/tracking/course_log_tools.php b/main/tracking/course_log_tools.php index fe26706ece..232ae40026 100755 --- a/main/tracking/course_log_tools.php +++ b/main/tracking/course_log_tools.php @@ -5,14 +5,12 @@ * @package chamilo.tracking */ -/* INIT SECTION */ - -$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null; -// Including the global initialization file require_once '../inc/global.inc.php'; $current_course_tool = TOOL_TRACKING; $course_info = api_get_course_info(); +$groupId = isset($_REQUEST['gidReq']) ? intval($_REQUEST['gidReq']) : 0; +//$groupId = api_get_group_id(); $from_myspace = false; $from = isset($_GET['from']) ? $_GET['from'] : null; @@ -35,7 +33,7 @@ if (!$is_allowedToTrack) { // Including additional libraries. require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php'; -$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST); +$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST); // Starting the output buffering when we are exporting the information. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false; @@ -65,25 +63,62 @@ Display::display_header($nameTools, 'Tracking'); // getting all the students of the course if (empty($session_id)) { // Registered students in a course outside session. - $a_students = CourseManager :: get_student_list_from_course_code(api_get_course_id()); + $a_students = CourseManager:: get_student_list_from_course_code( + api_get_course_id(), + false, + 0, + null, + null, + true, + api_get_group_id() + ); } else { // Registered students in session. - $a_students = CourseManager :: get_student_list_from_course_code(api_get_course_id(), true, api_get_session_id()); + $a_students = CourseManager:: get_student_list_from_course_code( + api_get_course_id(), + true, + api_get_session_id() + ); } - $nbStudents = count($a_students); +$student_ids = array_keys($a_students); +$studentCount = count($student_ids); /* MAIN CODE */ echo '
'; -echo Display::url(Display::return_icon('user.png', get_lang('StudentsTracking'), array(), 32), 'courseLog.php?'.api_get_cidreq()); -echo Display::return_icon('course_na.png', get_lang('CourseTracking'), array(), 32); -echo Display::url(Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), 32), 'course_log_resources.php?'.api_get_cidreq()); +echo Display::url( + Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM), + 'courseLog.php?'.api_get_cidreq() +); + +if (empty($groupId)) { + echo Display::url( + Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), + 'course_log_groups.php?'.api_get_cidreq() + ); + echo Display::url(Display::return_icon('course_na.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), '#'); +} else { + echo Display::url( + Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), + '#' + ); + echo Display::url( + Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), + 'course_log_tools.php?'.api_get_cidreq(true, false).'&gidReq=0' + ); +} + +echo Display::url( + Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM), + 'course_log_resources.php?'.api_get_cidreq() +); echo ''; -echo ''.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).''; +echo ''. + Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).''; echo ' '.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).''; @@ -95,15 +130,15 @@ $course_code = api_get_course_id(); $course_id = api_get_course_int_id(); $list = new LearnpathList(null, $course_code, $session_id); - $flat_list = $list->get_flat_list(); - if (count($flat_list) > 0) { // learning path tracking echo '
- '.Display::page_subheader(Display::return_icon('scorms.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath')).' + '.Display::page_subheader( + Display::return_icon('scorms.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath') + ).' '; if ($export_csv) { @@ -116,10 +151,15 @@ if (count($flat_list) > 0) { $lp_avg_progress = 0; foreach ($a_students as $student_id => $student) { // get the progress in learning pathes - $lp_avg_progress += Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id); + $lp_avg_progress += Tracking::get_avg_student_progress( + $student_id, + $course_code, + array($lp_id), + $session_id + ); } - if ($nbStudents > 0) { - $lp_avg_progress = $lp_avg_progress / $nbStudents; + if ($studentCount > 0) { + $lp_avg_progress = $lp_avg_progress / $studentCount; } else { $lp_avg_progress = null; } @@ -145,7 +185,9 @@ if (count($flat_list) > 0) { // Exercices tracking. echo '
- '.Display::page_subheader(Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices')).' + '.Display::page_subheader( + Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices') + ).'
'; $course_id = api_get_course_int_id(); @@ -163,18 +205,16 @@ if ($export_csv) { $course_path_params = '&cidReq='.$course_code.'&id_session='.$session_id; if (Database::num_rows($rs) > 0) { - $student_ids = array_keys($a_students); - $count_students = count($student_ids); while ($quiz = Database::fetch_array($rs)) { $quiz_avg_score = 0; - if ($count_students > 0) { + if ($studentCount > 0) { foreach ($student_ids as $student_id) { $avg_student_score = Tracking::get_avg_student_exercise_score($student_id, $course_code, $quiz['id'], $session_id); $quiz_avg_score += $avg_student_score; } } - $count_students = ($count_students == 0 || is_null($count_students) || $count_students == '') ? 1 : $count_students; - $quiz_avg_score = round(($quiz_avg_score / $count_students), 2).'%'; + $studentCount = ($studentCount == 0 || is_null($studentCount) || $studentCount == '') ? 1 : $studentCount; + $quiz_avg_score = round(($quiz_avg_score / $studentCount), 2).'%'; $url = api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.$quiz['id'].$course_path_params; echo ''; @@ -190,22 +230,51 @@ if (Database::num_rows($rs) > 0) { $csv_content[] = $temp; } } + echo '
'.Display::url($quiz['title'], $url).''.$quiz_avg_score.'
'; echo '
'; -// Forums tracking. -echo '
- '.Display::page_subheader(Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').' - '.get_lang('SeeDetail').''). - ''; -$count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($course_code, $session_id); -$count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($course_code, $session_id); -$count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($course_code, $session_id); +$filterByUsers = array(); + +if (!empty($groupId)) { + $filterByUsers = $student_ids; +} + +$count_number_of_forums_by_course = Tracking:: count_number_of_forums_by_course( + $course_code, + $session_id, + $groupId +); + +$count_number_of_threads_by_course = Tracking:: count_number_of_threads_by_course( + $course_code, + $session_id, + $groupId +); + +$count_number_of_posts_by_course = Tracking:: count_number_of_posts_by_course( + $course_code, + $session_id, + $groupId +); + if ($export_csv) { $csv_content[] = array(get_lang('Forum'), ''); $csv_content[] = array(get_lang('ForumForumsNumber', ''), $count_number_of_forums_by_course); $csv_content[] = array(get_lang('ForumThreadsNumber', ''), $count_number_of_threads_by_course); $csv_content[] = array(get_lang('ForumPostsNumber', ''), $count_number_of_posts_by_course); } + +// Forums tracking. +echo '
+ '.Display::page_subheader( + Display::return_icon('forum.gif', get_lang('Forum')). + get_lang('Forum').' - '. + get_lang('SeeDetail').'' + ). + '
'; + + echo ''; echo ''; echo '';
'.get_lang('ForumForumsNumber').''.$count_number_of_forums_by_course.'
'.get_lang('ForumThreadsNumber').''.$count_number_of_threads_by_course.'
'.get_lang('ForumPostsNumber').''.$count_number_of_posts_by_course.'