From e34da7399f37b31f3639be591366c0e847af4552 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 22 Aug 2017 11:19:03 +0200 Subject: [PATCH] Add special course to complete course list see BT#13099 --- main/inc/lib/course.lib.php | 1 + main/inc/lib/userportal.lib.php | 1 + user_portal.php | 151 +------------------------------- 3 files changed, 3 insertions(+), 150 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index c57ada434d..eb0fe385b7 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -3636,6 +3636,7 @@ class CourseManager $params = []; //Param (course_code) needed to get the student info in page "My courses" $params['course_code'] = $course['code']; + $params['code'] = $course['code']; // Get notifications. $course_info['id_session'] = null; $courseUserInfo = self::getUserCourseInfo($user_id, $courseId); diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 5cf33b2fcf..6a55576b91 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1379,6 +1379,7 @@ class IndexManager $specialCourseList = $this->tpl->fetch( $this->tpl->get_template($coursesWithoutCategoryTemplate) ); + $courseCompleteList = array_merge($courseCompleteList, $specialCourses); } if ($courses['in_category'] || $courses['not_category']) { foreach ($courses['in_category'] as $courseData) { diff --git a/user_portal.php b/user_portal.php index ce4f3b0d3e..f8bf481d06 100755 --- a/user_portal.php +++ b/user_portal.php @@ -299,7 +299,7 @@ $allow = api_get_configuration_value('gradebook_dependency'); if ($allow) { $courseAndSessions = $controller->returnCoursesAndSessions( $userId, - true, + false, '', false ); @@ -404,155 +404,6 @@ if ($allow) { $badgeList[$id]['skills'] = $skillList; } } - /* - - $categoriesNoCourseList = Category::load(null, null, ''); - $courseList = api_get_configuration_value('gradebook_dependency_mandatory_courses'); - $courseList = isset($courseList['courses']) ? $courseList['courses'] : []; - $mandatoryCourse = []; - if (!empty($courseList)) { - foreach ($courseList as $courseId) { - $courseInfo = api_get_course_info_by_id($courseId); - $mandatoryCourse[] = $courseInfo['code']; - } - } - - // @todo improve calls of course info - $subscribedCourses = !empty($courseAndSessions['courses']) ? $courseAndSessions['courses'] : []; - $mainCategoryList = []; - foreach ($subscribedCourses as $courseInfo) { - $courseCode = $courseInfo['code']; - $categories = Category::load(null, null, $courseCode); - $category = !empty($categories[0]) ? $categories[0] : []; - if (!empty($category)) { - $mainCategoryList[] = $category; - } - } - $total = []; - foreach ($mainCategoryList as $category) { - $parentScore = Category::getCurrentScore( - $userId, - $category, - true - ); - - $dependencies = $category->getCourseListDependency(); - $children = []; - $totalScoreWithChildren = 0; - if (!empty($dependencies)) { - foreach ($dependencies as $courseId) { - $courseInfo = api_get_course_info_by_id($courseId); - $courseCode = $courseInfo['code']; - $categories = Category::load(null, null, $courseCode); - $subCategory = !empty($categories[0]) ? $categories[0] : null; - if (!empty($subCategory)) { - $score = Category::getCurrentScore( - $userId, - $subCategory, - true - ); - $totalScoreWithChildren += $score; - $children[$subCategory->get_course_code()] = ['score' => $score]; - } - } - } - $totalScoreWithChildren += $parentScore; - $totalScoreWithChildrenAverage = $parentScore; - if (!empty($children)) { - $totalScoreWithChildrenAverage = $totalScoreWithChildren / (1 + count($children)); - } - - $total[$category->get_course_code()] = [ - 'score' => $parentScore, - 'total_score_with_children' => api_number_format($totalScoreWithChildrenAverage), - 'children' => $children, - 'min_validated' => $category->getMinimumToValidate() - ]; - } - - $countTotalGradeBookValidated = 0; - foreach ($total as $courseCode => $data) { - $totalScoreWithChildren = $data['total_score_with_children']; - if ($totalScoreWithChildren == 100) { - $countTotalGradeBookValidated++; - } - } - - - $finalScore = 0; - $customTotalPercentage = 0; - $maxPercentage = 80; - $maxCustomPercentageCounter = 0; - $validatedCoursesPercentage = 0; - $resultPerCategory = []; - - $mandatoryPercentage = 0; - $nonMandatoryPercentage = 0; - - foreach ($categoriesNoCourseList as $category) { - $dependencies = $category->getCourseListDependency(); - $minValidated = $category->getMinimumToValidate(); - $resultPerCategory[$category->get_id()] = ''; - $subTotal = 0; - if (!empty($dependencies)) { - foreach ($dependencies as $courseId) { - $courseInfo = api_get_course_info_by_id($courseId); - $courseCode = $courseInfo['code']; - if (in_array($courseCode, $mandatoryCourse)) { - if ($mandatoryPercentage <= 20) { - $mandatoryPercentage += 10; - } - } else { - if ($nonMandatoryPercentage <= 80) { - $nonMandatoryPercentage += 10; - } - } - if (isset($total[$courseCode])) { - $subTotal += $total[$courseCode]['total_score_with_children']; - } - } - - if ($minValidated < $countTotalGradeBookValidated) { - $subTotal = 0; - } - $resultPerCategory[$category->get_id()] = $subTotal; - } - - $completed = false; - if ($mandatoryPercentage == 20 && $nonMandatoryPercentage == 80) { - $completed = true; - } - }*/ - - /* - 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; - $customTotalPercentage += 10; - $validatedCoursesPercentage += 10; - break; - } - } else { - $maxCustomPercentageCounter++; - if ($customTotalPercentage < $maxPercentage && - $totalScoreWithChildren == 100 - ) { - $customTotalPercentage += 10; - } - } - $finalScore += $totalScoreWithChildren; - } - - $completed = false; - if ($validatedCoursesPercentage == 20 && $customTotalPercentage == 80) { - $completed = true; - }*/ $controller->tpl->assign( 'grade_book_sidebar',