Bistate aggregator shows failed if course is finished - progress otherwise. (If failed result is supported
This commit is contained in:
parent
4d4a461e21
commit
46ab702292
|
@ -133,15 +133,14 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
else if($started == 0){
|
||||
return completion::INCOMPLETE;
|
||||
}
|
||||
else if($this->use_failed && ($fraction_failed >= $this->thresh_progress)){
|
||||
return completion::FAILED;
|
||||
}
|
||||
else {
|
||||
return completion::PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
public function aggregate_course(courseinfo $courseinfo, studyitem $studyitem, $userid){
|
||||
$course = $courseinfo->course();
|
||||
$coursefinished = ($course->enddate)?($course->enddate < time()):false;
|
||||
// Note: studyitem condition config is not used in this aggregator.
|
||||
// loop through all associated gradables and count the totals, completed, etc..
|
||||
$completions = [];
|
||||
|
@ -156,7 +155,12 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
}
|
||||
|
||||
// Combine the aquired completions into one
|
||||
return self::aggregate_binary_goals($completions,$required);
|
||||
$result = self::aggregate_binary_goals($completions,$required);
|
||||
if($this->use_failed && $result == completion::PROGRESS && $coursefinished){
|
||||
return completion::FAILED;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -199,6 +203,8 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
$table = "local_treestudyplan_gradecfg";
|
||||
$gradeitem = $gradeinfo->getGradeitem();
|
||||
$grade = $gradeitem->get_final($userid);
|
||||
$course = \get_course($gradeitem->courseid); // Fetch course from cache
|
||||
$coursefinished = ($course->enddate)?($course->enddate < time()):false;
|
||||
|
||||
if(empty($grade)){
|
||||
return completion::INCOMPLETE;
|
||||
|
@ -244,7 +250,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
// return completed if completed
|
||||
return completion::COMPLETED;
|
||||
}
|
||||
else if($this->use_failed && $finalgrade < $gradecfg->min_progress)
|
||||
else if($this->use_failed && $coursefinished)
|
||||
{
|
||||
// return failed if failed is enabled and the grade is less than the minimum grade for progress
|
||||
return completion::FAILED;
|
||||
|
@ -260,7 +266,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
if($finalgrade >= $gradeitem->gradepass){
|
||||
return completion::COMPLETED;
|
||||
}
|
||||
else if($this->use_failed && $gradeitem->gradepass >= 3 && $range >= 3 && $finalgrade == 1)
|
||||
else if($this->use_failed && $coursefinished)
|
||||
{
|
||||
// return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
|
||||
return completion::FAILED;
|
||||
|
@ -280,7 +286,7 @@ class bistate_aggregator extends \local_treestudyplan\aggregator {
|
|||
if($score > 0.55){
|
||||
return completion::COMPLETED;
|
||||
}
|
||||
else if($this->use_failed && $range >= 3 && $finalgrade == 1)
|
||||
else if($this->use_failed && $coursefinished)
|
||||
{
|
||||
// return failed if failed is enabled and the grade is 1, while there are at leas 3 states.
|
||||
return completion::FAILED;
|
||||
|
|
Loading…
Reference in New Issue
Block a user