Learnpath: Add option to show the max progress instead average - refs BT#19309

pull/4066/head
Christian 4 years ago
parent e69fe9e3d9
commit 70010ce5f0
  1. 30
      main/inc/lib/tracking.lib.php
  2. 3
      main/install/configuration.dist.php
  3. 5
      main/tracking/courseLog.php

@ -3011,8 +3011,9 @@ class Tracking
* @param bool $returnArray Will return an array of the type: * @param bool $returnArray Will return an array of the type:
* [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
* @param bool $maxInsteadAvg Optional. It will return the max progress instead the average
* *
* @return float Average progress of the user in this course from 0 to 100 * @return float Average or max 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,
@ -3020,7 +3021,8 @@ class Tracking
$lpIdList = [], $lpIdList = [],
$sessionId = null, $sessionId = null,
$returnArray = false, $returnArray = false,
$onlySeriousGame = false $onlySeriousGame = false,
$maxInsteadAvg = false
) { ) {
// If there is at least one learning path and one student. // If there is at least one learning path and one student.
if (empty($studentId)) { if (empty($studentId)) {
@ -3146,6 +3148,11 @@ class Tracking
if (!empty($newProgress)) { if (!empty($newProgress)) {
$sum = array_sum($newProgress); $sum = array_sum($newProgress);
$average = $sum / $total; $average = $sum / $total;
// It will return the max progress instead the average
if ($maxInsteadAvg) {
return max($newProgress);
}
} }
if ($returnArray) { if ($returnArray) {
@ -5230,6 +5237,7 @@ class Tracking
if (!empty($session_id)) { if (!empty($session_id)) {
$sessionCondition = " AND s.id = $session_id"; $sessionCondition = " AND s.id = $session_id";
} }
$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
// Get the list of sessions where the user is subscribed as student // Get the list of sessions where the user is subscribed as student
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
@ -5345,7 +5353,12 @@ class Tracking
$time = api_time_to_hms($total_time_login); $time = api_time_to_hms($total_time_login);
$progress = self::get_avg_student_progress( $progress = self::get_avg_student_progress(
$user_id, $user_id,
$course_code $course_code,
[],
null,
false,
false,
$lpShowMaxProgress
); );
$bestScore = self::get_avg_student_score( $bestScore = self::get_avg_student_score(
$user_id, $user_id,
@ -5786,7 +5799,10 @@ class Tracking
$user_id, $user_id,
$course_code, $course_code,
[], [],
$session_id_from_get $session_id_from_get,
false,
false,
$lpShowMaxProgress
); );
$total_time_login = self::get_time_spent_on_the_course( $total_time_login = self::get_time_spent_on_the_course(
@ -8990,11 +9006,15 @@ class TrackingCourseLog
true true
); );
$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
$avg_student_progress = Tracking::get_avg_student_progress( $avg_student_progress = Tracking::get_avg_student_progress(
$user['user_id'], $user['user_id'],
$course_code, $course_code,
[], [],
$session_id $session_id,
false,
false,
$lpShowMaxProgress
); );
if (empty($avg_student_progress)) { if (empty($avg_student_progress)) {

@ -490,7 +490,8 @@ ALTER TABLE sys_announcement ADD COLUMN visible_boss INT DEFAULT 0;
//$_configuration['tracking_skip_generic_data'] = false; //$_configuration['tracking_skip_generic_data'] = false;
// Show view accordion lp_category // Show view accordion lp_category
//$_configuration['lp_category_accordion'] = false; //$_configuration['lp_category_accordion'] = false;
// // Show the best progress instead of averages in reporting of learnpaths
// $_configuration['lp_show_max_progress_instead_of_average'] = false;
// Show view accordion lp_item_view // Show view accordion lp_item_view
// $_configuration['lp_view_accordion'] = false; // $_configuration['lp_view_accordion'] = false;
// Allow export learning paths to students // Allow export learning paths to students

@ -29,6 +29,7 @@ $sortByFirstName = api_sort_by_first_name();
$from_myspace = false; $from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null; $from = isset($_GET['from']) ? $_GET['from'] : null;
$origin = api_get_origin(); $origin = api_get_origin();
$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
// Starting the output buffering when we are exporting the information. // Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false; $export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false;
@ -682,10 +683,12 @@ if ($nbStudents > 0) {
false false
); );
$headers['training_time'] = get_lang('TrainingTime'); $headers['training_time'] = get_lang('TrainingTime');
$courseProgressHeadTitle = ($lpShowMaxProgress ? get_lang('ScormAndLPMaxProgress'): get_lang('ScormAndLPProgressTotalAverage'));
$table->set_header( $table->set_header(
$headerCounter++, $headerCounter++,
get_lang('CourseProgress').' '. get_lang('CourseProgress').' '.
Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), [], ICON_SIZE_TINY), Display::return_icon('info3.gif', $courseProgressHeadTitle, [], ICON_SIZE_TINY),
false false
); );
$headers['course_progress'] = get_lang('CourseProgress'); $headers['course_progress'] = get_lang('CourseProgress');

Loading…
Cancel
Save