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