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