Hi Dan,
thank you for your answer and naming of the corresponding function.
Alex and I did some testing and research and we think that the calculation is indeed buggy respectively needs an addition.
You are using this formula to calculate the grades:
$usersummary->takensessionspercentage * $attendancegrade
(https://github.com/danmarsden/moodle-mod_attendance/blob/master/locallib.php#L256)
Let's have a look at an example:
The teacher uses the Scale "Not yet competent, Competent". So, $attendancegrade will be 2 ($attendancegrade = count($scalearray)).
He also has 2 attendance status: "Attended (A)" and "Not attended (N)" graded with 2 (A) and 1 points (N).
- Now assuming a participant has a "takensessionspercentage" of 70% (0.7). Your formula then calcuates: 0.7 * 2 = 1.4.
This solution will be mapped to the Scale that lies between 1 and 2 in our example. So 1.4 will be rounded down to 1 and that means that the user will get a "Not competent" grade.
- Now assuming a participant has a "takensessionspercentage" of 76% (0.76). Your formula then calcuates: 0.76 * 2 = 1.52.
This solution will be mapped to the Scale that lies between 1 and 2 in our example. So 1.52 will be rounded up to 2 and that means that the user will get a "Competent" grade.
With a scale of two items, the breakpoint should be at 50% attendance (in my understanding).
If you would change your formula to the following, the result should be correct then:
0.5 + ($usersummary->takensessionspercentage * $attendancegrade)
- Attendance percentage 0.7
=> 0.5 + (0.7 * 2) = 1.9
This will be rounded up to 2 and therefore the user will now get the correct grade "Competent".
- Attendance percentage 0.76
=> 0.5 + (0.76 * 2) = 2.02
This will be rounded down to 2 and therefore the user will still get the correct grade "Competent".
- Attendance percentage 0.49
=> 0.5 + (0.49 * 2) = 1.48
This will be rounded down to 1 and therefore the user will get the correct grade "Not competent".
Best, Kathrin