From a417ff33b3fc81c3839cfdd71bcbc5f00b82d8fc Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 14 Aug 2017 12:05:54 +0200 Subject: [PATCH] Add min to validate parameter in condition see BT#13099 --- user_portal.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/user_portal.php b/user_portal.php index 4dc1ebf2ac..654ff36a86 100755 --- a/user_portal.php +++ b/user_portal.php @@ -347,7 +347,8 @@ if (!empty($courseAndSessions['courses']) && $allow) { $total[$category->get_course_code()] = [ 'score' => $parentScore, 'total_score_with_children' => api_number_format($totalScoreWithChildrenAverage), - 'children' => $children + 'children' => $children, + 'min_validated' => $category->getMinimumToValidate() ]; } @@ -356,8 +357,21 @@ if (!empty($courseAndSessions['courses']) && $allow) { $maxPercentage = 80; $maxCustomPercentageCounter = 0; $validatedCoursesPercentage = 0; + + $countValidated = 0; + foreach ($total as $courseCode => $data) { + $totalScoreWithChildren = $data['total_score_with_children']; + if ($totalScoreWithChildren == 100) { + $countValidated++; + } + } + foreach ($total as $courseCode => $data) { $totalScoreWithChildren = $data['total_score_with_children']; + if ($data['min_validated'] < $countValidated) { + $totalScoreWithChildren = 0; + } + if (in_array($courseCode, $mandatoryCourse)) { if ($totalScoreWithChildren == 100) { $finalScore = 0;