Add special course to complete course list see BT#13099

pull/2487/head
jmontoyaa 8 years ago
parent 729432ecca
commit e34da7399f
  1. 1
      main/inc/lib/course.lib.php
  2. 1
      main/inc/lib/userportal.lib.php
  3. 151
      user_portal.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);

@ -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) {

@ -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',

Loading…
Cancel
Save