Add stats columns in class user list see BT#14608

pull/2591/head
Julio 8 years ago
parent c2912aff26
commit 590410f435
  1. 14
      main/admin/usergroup_users.php
  2. 11
      main/inc/ajax/model.ajax.php
  3. 40
      main/inc/lib/tracking.lib.php
  4. 17
      main/inc/lib/usergroup.lib.php
  5. 2
      main/mySpace/myStudents.php
  6. 43
      plugin/lp_calendar/LpCalendarPlugin.php

@ -137,6 +137,10 @@ if (api_get_plugin_setting('lp_calendar', 'enabled') === 'true') {
$columns = [
get_lang('Name'),
get_lang('Calendar'),
get_lang('Examn'),
get_lang('TimeSpentInTheCourse'),
get_lang('Jours de parcours réalisés'),
get_lang('Différence de nombre de jours avec le plan issu du learning_calendar '),
get_lang('Actions'),
];
@ -151,6 +155,16 @@ if (api_get_plugin_setting('lp_calendar', 'enabled') === 'true') {
'sortable' => 'false',
'formatter' => 'extra_formatter',
],
['name' => 'examn', 'index' => 'examn', 'width' => '35', 'align' => 'left', 'sortable' => 'false'],
['name' => 'time_spent', 'index' => 'time_spent', 'width' => '35', 'align' => 'left', 'sortable' => 'false'],
[
'name' => 'lp_day_completed',
'index' => 'lp_day_completed',
'width' => '35',
'align' => 'left',
'sortable' => 'false',
],
['name' => 'days_diff', 'index' => 'days_diff', 'width' => '35', 'align' => 'left', 'sortable' => 'false'],
[
'name' => 'actions',
'index' => 'actions',

@ -793,7 +793,16 @@ switch ($action) {
$usergroup->protectScript();
$columns = ['name', 'actions'];
if (api_get_plugin_setting('lp_calendar', 'enabled') === 'true') {
$columns = ['name', 'calendar', 'actions', 'calendar_id'];
$columns = [
'name',
'calendar',
'examn',
'time_sent',
'lp_day_completed',
'days_diff',
'actions',
'calendar_id',
];
}
$result = $usergroup->getUserGroupUsers($id);
break;

@ -4635,7 +4635,8 @@ class Tracking
$session_id = 0,
$extra_params = '',
$show_courses = true,
$showAllSessions = true
$showAllSessions = true,
$returnArray = false
) {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
@ -4774,6 +4775,12 @@ class Tracking
$course_in_session[$my_session_id]['name'] = $session_name;
}
if ($returnArray) {
$course_in_session[0] = $courseIdList;
return $course_in_session;
}
$html = '';
// Course list
if ($show_courses) {
@ -5409,7 +5416,7 @@ class Tracking
if ($pluginCalendar) {
$course_in_session[0] = $courseIdList;
$plugin = LpCalendarPlugin::create();
$html .= LpCalendarPlugin::getUserStats($user_id, $course_in_session);
$html .= LpCalendarPlugin::getUserStatsPanel($user_id, $course_in_session);
}
}
@ -6830,8 +6837,37 @@ class Tracking
return $allow;
}
public function getCoursesAndSessions($userId)
{
$userId = (int) $userId;
// Get the list of sessions where the user is subscribed as student
$sql = 'SELECT session_id, c_id
FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
WHERE user_id='.$userId;
$rs = Database::query($sql);
$tmp_sessions = [];
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$tmp_sessions[] = $row['session_id'];
if ($drh_can_access_all_courses) {
if (in_array($row['session_id'], $tmp_sessions)) {
$courses_in_session[$row['session_id']][] = $row['c_id'];
}
} else {
if (isset($courses_in_session_by_coach[$row['session_id']])) {
if (in_array($row['session_id'], $tmp_sessions)) {
$courses_in_session[$row['session_id']][] = $row['c_id'];
}
}
}
}
}
}
/**
* @todo move into a proper file
*

@ -119,6 +119,23 @@ class UserGroup extends Model
$data['calendar'] = $calendarInfo['title'];
}
}
$courseAndSessionList = Tracking::show_user_progress(
$userId,
0,
'',
true,
true,
true
);
$stats = LpCalendarPlugin::getUserStats($userId, $courseAndSessionList)
$data['examn'] = 'examn';
$data['time_spent'] = 'time_spent';
$data['lp_day_completed'] = 'lp_day_completed';
$data['days_diff'] = 'days_diff';
}
$data['id'] = $data['user_id'];
$list[] = $data;

@ -1875,7 +1875,7 @@ if ($allow && (api_is_drh() || api_is_platform_admin())) {
$pluginCalendar = api_get_plugin_setting('lp_calendar', 'enabled') === 'true';
if ($pluginCalendar) {
$plugin = LpCalendarPlugin::create();
echo LpCalendarPlugin::getUserStats($student_id, $courses_in_session);
echo LpCalendarPlugin::getUserStatsPanel($student_id, $courses_in_session);
}
if ($export) {

@ -634,6 +634,31 @@ class LpCalendarPlugin extends Plugin
*
* @return string
*/
public static function getUserStatsPanel($userId, $courseAndSessionList)
{
// @todo use translation
// get events from this year to today
$stats = self::getUserStats($userId, $courseAndSessionList);
$html = "Nombre de jours cumulés dans le calendrier: ".$stats['user_event_count'];
if (!empty($courseAndSessionList)) {
$count = $stats['completed'];
$html .= '<br />';
$html .= "Nombre de jours cumulés dans les parcours réalisés: ".$stats['completed'];
$html .= '<br />';
$html .= 'Nombre de jour de retard ou d\'avance à la date d\'aujourd\'hui '.$stats['diff'];
}
$html = Display::panel($html, get_lang('CalendarStats'));
return $html;
}
/**
* @param int $userId
* @param int $courseAndSessionList
*
* @return array
*/
public static function getUserStats($userId, $courseAndSessionList)
{
// @todo use translation
@ -646,16 +671,18 @@ class LpCalendarPlugin extends Plugin
true
);
$completed = 0;
$diff = 0;
$html = "Nombre de jours cumulés dans le calendrier: $takenCount";
if (!empty($courseAndSessionList)) {
$count = self::getItemCountChecked($userId, $courseAndSessionList);
$html .= '<br />';
$html .= "Nombre de jours cumulés dans les parcours réalisés: $count";
$html .= '<br />';
$html .= 'Nombre de jour de retard ou d\'avance à la date d\'aujourd\'hui '.($takenCount - $count);
$completed = self::getItemCountChecked($userId, $courseAndSessionList);
$diff = $takenCount - $completed;
}
$html = Display::panel($html, get_lang('CalendarStats'));
return $html;
return [
'user_event_count' => $takenCount,
'completed' => $completed,
'diff' => $diff
];
}
}

Loading…
Cancel
Save