Reports: Add LP progress report per session / course see BT#17613

pull/3440/head
Julio Montoya 5 years ago
parent d69ba7eb0f
commit 892cd7088e
  1. 76
      main/inc/ajax/myspace.ajax.php
  2. 6
      main/inc/lib/course.lib.php
  3. 2
      main/inc/lib/tracking.lib.php
  4. 7
      main/inc/lib/usermanager.lib.php

@ -2,10 +2,13 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/** /**
* Responses to AJAX calls. * Responses to AJAX calls.
*/ */
require_once __DIR__.'/../global.inc.php'; require_once __DIR__.'/../global.inc.php';
$action = $_GET['a']; $action = $_GET['a'];
// Access restrictions. // Access restrictions.
@ -17,9 +20,78 @@ if (!$is_allowedToTrack) {
} }
switch ($action) { switch ($action) {
// At this date : 23/02/2017, a minor review can't determine where is used this case 'access_detail' case 'lp_global_report':
$userId = (int) $_REQUEST['user_id'];
if (empty($userId)) {
exit;
}
$cacheAvailable = api_get_configuration_value('apc');
$table = null;
$variable = 'lp_global_report_'.$userId;
if ($cacheAvailable) {
if (apcu_exists($variable)) {
$table = apcu_fetch($variable);
}
}
if (!empty($table)) {
echo $table;
exit;
}
$sessionCategoryList = UserManager::get_sessions_by_category($userId, false);
$total = 0;
$totalAverage = 0;
$table = new HTML_Table(['class' => 'data_table']);
$row = 0;
$col = 0;
foreach ($sessionCategoryList as $category) {
$sessionList = $category['sessions'];
foreach ($sessionList as $session) {
$courses = $session['courses'];
$sessionId = $session['session_id'];
$session['session_name'];
$totalCourse = 0;
$totalSessionAverage = 0;
foreach ($courses as &$course) {
$average = Tracking::get_avg_student_progress($userId, $course['course_code'], [], $sessionId);
$course['average'] = $average;
$totalSessionAverage += $average;
$totalAverage += $average;
$total++;
$totalCourse++;
$total++;
}
$row++;
$table->setCellContents($row, 0, $session['session_name']);
$table->setCellContents($row, 1, round($totalSessionAverage/count($courses), 2));
$table->setCellContents($row, 2, '');
$row++;
foreach ($courses as &$course) {
$table->setCellContents($row, 0, $session['session_name'].'-'.count($courses));
$table->setCellContents($row, 1, $course['title']);
$table->setCellContents($row, 2, $course['average']);
$row++;
}
}
}
$table->setCellContents(0, 0, get_lang('Global'));
$table->setCellContents(0, 1, round($totalAverage/$total, 2));
$result = $table->toHtml();
if ($cacheAvailable) {
apcu_store($variable, $result, 60);
}
echo $result;
break;
case 'access_detail': case 'access_detail':
$user_id = intval($_REQUEST['student']); // At this date : 23/02/2017, a minor review can't determine where is used this case 'access_detail'.
$user_id = (int) $_REQUEST['student'];
$course_code = Security::remove_XSS($_REQUEST['course']); $course_code = Security::remove_XSS($_REQUEST['course']);
$type = Security::remove_XSS($_REQUEST['type']); $type = Security::remove_XSS($_REQUEST['type']);
$range = Security::remove_XSS($_REQUEST['range']); $range = Security::remove_XSS($_REQUEST['range']);

@ -6106,7 +6106,7 @@ class CourseManager
public static function getCourseUsers($filterByActive = null) public static function getCourseUsers($filterByActive = null)
{ {
// This would return only the users from real courses: // This would return only the users from real courses:
$userList = self::get_user_list_from_course_code( return self::get_user_list_from_course_code(
api_get_course_id(), api_get_course_id(),
api_get_session_id(), api_get_session_id(),
null, null,
@ -6120,8 +6120,6 @@ class CourseManager
[], [],
$filterByActive $filterByActive
); );
return $userList;
} }
/** /**
@ -6175,7 +6173,7 @@ class CourseManager
'users', 'users',
get_lang('Users'), get_lang('Users'),
$result, $result,
['select_all_checkbox' => true] ['select_all_checkbox' => true, 'id' => 'users']
); );
} }

@ -2557,7 +2557,7 @@ class Tracking
* [sum_of_progresses, number] if it is set to true * [sum_of_progresses, number] if it is set to true
* @param bool $onlySeriousGame Optional. Limit average to lp on seriousgame mode * @param bool $onlySeriousGame Optional. Limit average to lp on seriousgame mode
* *
* @return float Average progress of the user in this course * @return float Average progress of the user in this course from 0 to 100
*/ */
public static function get_avg_student_progress( public static function get_avg_student_progress(
$studentId, $studentId,

@ -3471,10 +3471,7 @@ class UserManager
$coachList = SessionManager::getCoachesBySession($session_id); $coachList = SessionManager::getCoachesBySession($session_id);
$categoryStart = $row['session_category_date_start'] ? $row['session_category_date_start']->format('Y-m-d') : ''; $categoryStart = $row['session_category_date_start'] ? $row['session_category_date_start']->format('Y-m-d') : '';
$categoryEnd = $row['session_category_date_end'] ? $row['session_category_date_end']->format('Y-m-d') : ''; $categoryEnd = $row['session_category_date_end'] ? $row['session_category_date_end']->format('Y-m-d') : '';
$courseList = self::get_courses_list_by_session( $courseList = self::get_courses_list_by_session($user_id, $session_id);
$user_id,
$session_id
);
$daysLeft = SessionManager::getDayLeftInSession($row, $user_id); $daysLeft = SessionManager::getDayLeftInSession($row, $user_id);
// User portal filters: // User portal filters:
@ -3856,6 +3853,7 @@ class UserManager
session_rel_course_user table if there are courses registered session_rel_course_user table if there are courses registered
to our user or not */ to our user or not */
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
c.title,
c.visibility, c.visibility,
c.id as real_id, c.id as real_id,
c.code as course_code, c.code as course_code,
@ -3893,6 +3891,7 @@ class UserManager
if (api_is_allowed_to_create_course()) { if (api_is_allowed_to_create_course()) {
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
c.title,
c.visibility, c.visibility,
c.id as real_id, c.id as real_id,
c.code as course_code, c.code as course_code,

Loading…
Cancel
Save