Skip to content

Commit 95433c0

Browse files
committed
Fix progress value see BT#14393
1 parent 6f3a543 commit 95433c0

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

main/inc/lib/tracking.lib.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ public static function get_avg_student_progress(
25772577
if (!empty($lpList)) {
25782578
/** @var $lp */
25792579
foreach ($lpList as $lpId => $lp) {
2580-
$lpIdList[] = $lpId;
2580+
$lpIdList[] = $lp['lp_old_id'];
25812581
}
25822582
}
25832583
}
@@ -2609,29 +2609,30 @@ public static function get_avg_student_progress(
26092609
}
26102610

26112611
// Fill with lp ids
2612+
$newProgress = [];
26122613
if (!empty($lpIdList)) {
26132614
foreach ($lpIdList as $lpId) {
2614-
if (!isset($progress[$lpId])) {
2615-
$progress[$lpId] = 0;
2615+
if (isset($progress[$lpId])) {
2616+
$newProgress[] = $progress[$lpId];
26162617
}
26172618
}
2619+
$total = count($lpIdList);
2620+
} else {
2621+
$newProgress = $progress;
2622+
$total = count($newProgress);
26182623
}
26192624

2620-
if (!empty($progress)) {
2621-
$sum = array_sum($progress);
2622-
$average = 0;
2623-
if (!empty($lpIdList)) {
2624-
$average = $sum / count($lpIdList);
2625-
}
2626-
} else {
2627-
$average = 0;
2628-
$sum = 0;
2625+
$average = 0;
2626+
$sum = 0;
2627+
if (!empty($newProgress)) {
2628+
$sum = array_sum($newProgress);
2629+
$average = $sum / $total;
26292630
}
26302631

26312632
if ($returnArray) {
26322633
return [
26332634
$sum,
2634-
count($lpIdList),
2635+
$total,
26352636
];
26362637
}
26372638

0 commit comments

Comments
 (0)