Add session id param + fix results see BT#12275

remotes/angel/1.11.x
Julio 8 years ago
parent ca63112438
commit f7a607c625
  1. 4
      main/inc/ajax/model.ajax.php
  2. 33
      main/inc/lib/tracking.lib.php
  3. 3
      main/tracking/course_log_groups.php

@ -194,7 +194,8 @@ 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');
$sessionId = isset($_REQUEST['session_id']) ? $_REQUEST['session_id'] : null;
$count = Tracking::get_group_reporting($course_id, $sessionId, $group_id, 'count');
break;
case 'get_user_course_report':
case 'get_user_course_report_resumed':
@ -613,6 +614,7 @@ switch ($action) {
$result = Tracking::get_group_reporting(
$course_id,
$sessionId,
$group_id,
'all',
$start,

@ -19,6 +19,7 @@ class Tracking
{
public static function get_group_reporting(
$course_id,
$sessionId = null,
$group_id = null,
$type = 'all',
$start = 0,
@ -31,6 +32,7 @@ class Tracking
return null;
}
$course_info = api_get_course_info_by_id($course_id);
$sessionId = (int) $sessionId;
$table_group = Database :: get_course_table(TABLE_GROUP);
$course_id = intval($course_id);
@ -39,12 +41,16 @@ class Tracking
$select = ' count(id) as count ';
}
$default_where = array('c_id = ? ' => array($course_id));
if (empty($sessionId)) {
$default_where = array('c_id = ? AND (session_id = 0 or session_id IS NULL)' => array($course_id));
} else {
$default_where = array('c_id = ? AND session_id = ? ' => array($course_id, $sessionId));
}
$result = Database::select($select, $table_group, array(
'limit' => " $start, $limit",
'where' => $default_where,
'order' => "$sidx $sord")
'limit' => " $start, $limit",
'where' => $default_where,
'order' => "$sidx $sord")
);
if ($type == 'count') {
@ -63,25 +69,30 @@ class Tracking
$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);
$time += Tracking::get_time_spent_on_the_course($user_data['user_id'], $course_info['code'], $sessionId);
$avg_student_score += Tracking::get_avg_student_score($user_data['user_id'], $course_info['code'], array(), $sessionId);
$avg_student_progress += Tracking::get_avg_student_progress($user_data['user_id'], $course_info['code'], array(), $sessionId);
$work += Tracking::count_student_assignments($user_data['user_id'], $course_info['code'], $sessionId);
$messages += Tracking::count_student_messages($user_data['user_id'], $course_info['code'], $sessionId);
}
$countUsers = count($users);
$averageProgress = empty($countUsers) ? 0 : $avg_student_progress/$countUsers;
$averageScore = empty($countUsers) ? 0 : $avg_student_score/$countUsers;
$group_item = array(
'id' => $group['id'],
'name' => $group['name'],
'time' => api_time_to_hms($time),
'progress' => $avg_student_progress,
'score' => $avg_student_score,
'progress' => $averageProgress,
'score' => $averageScore,
'works' => $work,
'messages' => $messages,
);
$parsed_result[] = $group_item;
}
}
return $parsed_result;
}

@ -23,9 +23,10 @@ if (!$is_allowedToTrack) {
$course_id = api_get_course_int_id();
$course_code = api_get_course_id();
$sessionId = api_get_session_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;
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_group_reporting&course_id='.$course_id.'&session_id='.$sessionId;
// The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(

Loading…
Cancel
Save