Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions main/course_info/infocours.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,26 @@ function is_settings_editable()
$form->addGroup($group, '', [get_lang('LpReturnLink')]);
}

if (api_get_configuration_value('lp_show_max_progress_or_average_enable_course_level_redefinition')) {
$group = [
$form->createElement(
'radio',
'lp_show_max_or_average_progress',
null,
get_lang('LpMaxProgress'),
'max'
),
$form->createElement(
'radio',
'lp_show_max_or_average_progress',
null,
get_lang('LpAverageProgress'),
'average'
),
];
$form->addGroup($group, '', [get_lang('lpShowMaxProgressOrAverage')]);
}

$exerciseInvisible = api_get_setting('exercise_invisible_in_session');
$configureExerciseVisibility = api_get_setting('configure_exercise_visibility_in_course');

Expand Down
4 changes: 4 additions & 0 deletions main/inc/lib/course.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5820,6 +5820,10 @@ public static function getCourseSettingVariables(AppPlugin $appPlugin)
$courseSettings[] = 'portfolio_max_score';
}

if (api_get_configuration_value('lp_show_max_progress_or_average_enable_course_level_redefinition')) {
$courseSettings[] = 'lp_show_max_or_average_progress';
}

if (!empty($pluginCourseSettings)) {
$courseSettings = array_merge(
$courseSettings,
Expand Down
17 changes: 15 additions & 2 deletions main/inc/lib/tracking.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5237,7 +5237,6 @@ public static function showUserProgress(
if (!empty($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
if (api_is_multiple_url_enabled()) {
Expand Down Expand Up @@ -5345,6 +5344,13 @@ function ($column, $columnKey) use ($availableColumns) {
foreach ($courses as $course_code => $course_title) {
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
if (api_get_configuration_value('lp_show_max_progress_or_average_enable_course_level_redefinition')) {
$lpShowProgressCourseSetting = api_get_course_setting('lp_show_max_or_average_progress', $courseInfo, true);
if (in_array($lpShowProgressCourseSetting, ['max', 'average'])) {
$lpShowMaxProgress = ('max' === $lpShowProgressCourseSetting);
}
}

$total_time_login = self::get_time_spent_on_the_course(
$user_id,
Expand Down Expand Up @@ -8977,6 +8983,14 @@ public static function get_user_data(
}
}

$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
if (api_get_configuration_value('lp_show_max_progress_or_average_enable_course_level_redefinition')) {
$lpShowProgressCourseSetting = api_get_course_setting('lp_show_max_or_average_progress', $courseInfo, true);
if (in_array($lpShowProgressCourseSetting, ['max', 'average'])) {
$lpShowMaxProgress = ('max' === $lpShowProgressCourseSetting);
}
}

while ($user = Database::fetch_array($res, 'ASSOC')) {
$userIdList[] = $user['user_id'];
$user['official_code'] = $user['col0'];
Expand Down Expand Up @@ -9006,7 +9020,6 @@ public static function get_user_data(
true
);

$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
$avg_student_progress = Tracking::get_avg_student_progress(
$user['user_id'],
$course_code,
Expand Down
2 changes: 2 additions & 0 deletions main/install/configuration.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@
//$_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;
// Enable redefinition of the setting to show the best progress instead of averages in reporting of learnpaths at a course level.
// $_configuration['lp_show_max_progress_or_average_enable_course_level_redefinition'] = false;
// Show view accordion lp_item_view
// $_configuration['lp_view_accordion'] = false;
// Allow export learning paths to students
Expand Down
16 changes: 12 additions & 4 deletions main/tracking/courseLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
$from = isset($_GET['from']) ? $_GET['from'] : null;
$origin = api_get_origin();
$lpShowMaxProgress = api_get_configuration_value('lp_show_max_progress_instead_of_average');
if (api_get_configuration_value('lp_show_max_progress_or_average_enable_course_level_redefinition')) {
$lpShowProgressCourseSetting = api_get_course_setting('lp_show_max_or_average_progress');
if (in_array($lpShowProgressCourseSetting, ['max', 'average'])) {
$lpShowMaxProgress = ('max' === $lpShowProgressCourseSetting);
}
}

// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false;
Expand Down Expand Up @@ -779,10 +785,12 @@ function(index) {
}
}
if (isset($defaultExtraFields)) {
foreach ($defaultExtraInfo as $field) {
$table->set_header($counter, $field['display_text'], false);
$headers[$field['variable']] = $field['display_text'];
$counter++;
if (!empty($defaultExtraInfo)) {
foreach ($defaultExtraInfo as $field) {
$table->set_header($counter, $field['display_text'], false);
$headers[$field['variable']] = $field['display_text'];
$counter++;
}
}
}
$table->set_header($counter, get_lang('Details'), false);
Expand Down