Add group report see BT#5758

1.10.x
Julio Montoya 10 years ago
parent f912205581
commit 27105de8d4
  1. 71
      main/forum/reply.php
  2. BIN
      main/img/icons/32/group_na.png
  3. 22
      main/inc/ajax/model.ajax.php
  4. 43
      main/inc/lib/course.lib.php
  5. 18
      main/inc/lib/groupmanager.lib.php
  6. 170
      main/inc/lib/tracking.lib.php
  7. 4
      main/tracking/courseLog.php
  8. 127
      main/tracking/course_log_groups.php
  9. 5
      main/tracking/course_log_resources.php
  10. 131
      main/tracking/course_log_tools.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 '<div class="forum_title">';
echo '<h1><a href="viewforum.php?&origin='.$origin.'&forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a></h1>';
echo '<h1><a href="viewforum.php?&origin='.$origin.'&forum='.$current_forum['forum_id'].'" '.
class_visible_invisible($current_forum['visibility']).'>'.
prepare4display($current_forum['forum_title']).'</a></h1>';
echo '<p class="forum_description">'.prepare4display($current_forum['forum_comment']).'</p>';
echo '</div>';
/* End new display forum */
@ -159,7 +192,13 @@ echo '</div>';
$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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -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

@ -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 = "";

@ -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 = '<a class="'.$groupNameClass.'" href="group_space.php?cidReq='.api_get_course_id().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.
$group_name = '<a class="'.$groupNameClass.'" href="group_space.php?cidReq='.api_get_course_id().'&origin='.$orig.'&gidReq='.$this_group['id'].'">'.
Security::remove_XSS($this_group['name']).'</a> ';
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[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&amp;action=self_reg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
$row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_reg&group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
} elseif (self :: is_self_unregistration_allowed($user_id, $this_group['id'])) {
$row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&amp;action=self_unreg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
$row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_unreg&group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
} else {
$row[] = '-';
}
@ -2306,10 +2306,10 @@ class GroupManager
Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
if ($this_group['status'] == 1) {
$edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&amp;action=set_invisible&amp;id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
$edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&action=set_invisible&id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
} else {
$edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=set_visible&amp;id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
$edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=set_visible&id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
}
@ -2319,13 +2319,13 @@ class GroupManager
$edit_actions .= '<a href="'.$url.'group_overview.php?action=export&type=xls&'.api_get_cidreq(true, false).'&id='.$this_group['id'].'" title="'.get_lang('ExportUsers').'">'.
Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
/*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
/*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=empty_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=fill_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=fill_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=delete_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=delete_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$row[] = $edit_actions;

@ -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);

@ -219,6 +219,10 @@ Display::display_header($nameTools, 'Tracking');
echo '<div class="actions">';
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()

@ -0,0 +1,127 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
if ($from == 'myspace') {
$from_myspace = true;
$this_section = "session_my_space";
} else {
$this_section = SECTION_COURSES;
}
// Access restrictions.
$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
if (!$is_allowedToTrack) {
api_not_allowed(true);
exit;
}
$course_id = api_get_course_int_id();
$course_code = api_get_course_id();
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_group_reporting&course_id='.$course_id;
// 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('Time'),
get_lang('Progress'),
get_lang('Score'),
get_lang('Works'),
get_lang('Messages'),
get_lang('Actions'),
);
// Column config
$column_model = array(
array(
'name' => '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 \'<a href="course_log_tools.php?id_session=0&cidReq='.$course_code.'&gidReq=\'+options.rowId+\'">'.Display::return_icon('2rightarrow.gif',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
// Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = '
<script>
$(function() {
'.Display::grid_js('group_users',$url, $columns, $column_model, $extra_params, array(), $action_links, true).'
});
</script>';
Display::display_header();
echo '<div class="actions">';
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 '</div>';
echo Display::grid_html('group_users');
Display::display_footer();

@ -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()

@ -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 '<div class="actions">';
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 '<span style="float:right; padding-top:0px;">';
echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&id_session='.api_get_session_id().'&export=csv">
'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
@ -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 '<div class="report_section">
'.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')
).'
<table class="data_table">';
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 '<div class="report_section">
'.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')
).'
<table class="data_table">';
$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 '<tr><td>'.Display::url($quiz['title'], $url).'</td><td align="right">'.$quiz_avg_score.'</td></tr>';
@ -190,22 +230,51 @@ if (Database::num_rows($rs) > 0) {
$csv_content[] = $temp;
}
}
echo '</table></div>';
echo '<div class="clear"></div>';
// Forums tracking.
echo '<div class="report_section">
'.Display::page_subheader(Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a>').
'<table class="data_table">';
$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 '<div class="report_section">
'.Display::page_subheader(
Display::return_icon('forum.gif', get_lang('Forum')).
get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?'.api_get_cidreq().'">'.
get_lang('SeeDetail').'</a>'
).
'<table class="data_table">';
echo '<tr><td>'.get_lang('ForumForumsNumber').'</td><td align="right">'.$count_number_of_forums_by_course.'</td></tr>';
echo '<tr><td>'.get_lang('ForumThreadsNumber').'</td><td align="right">'.$count_number_of_threads_by_course.'</td></tr>';
echo '<tr><td>'.get_lang('ForumPostsNumber').'</td><td align="right">'.$count_number_of_posts_by_course.'</td></tr>';

Loading…
Cancel
Save