fmido88 / moodle-enrol_wallet

Enrollment using wallet credit with coupons and using payments gateways with restrictions.
Other
3 stars 1 forks source link

Wrong logic on course reward calculation #31

Closed bobnguyenthedeveloper closed 2 months ago

bobnguyenthedeveloper commented 3 months ago

I think we have some problem with the logic here: https://github.com/fmido88/moodle-enrol_wallet/blob/fee86bd66448a1a6ca3d79c36b1ce1d134b352c6/classes/observer.php#L83

The $percentage variable represents the percentage of the user's grade relative to the course's maximum grade. Therefore, 100 - $percentage should be interpreted as the difference between the user's grade and the maximum grade. According to this logic, the higher the user's score, the lower the award, which is incorrect.

I believe that the correct implementation should be: image

fmido88 commented 2 months ago

Thanks @bobnguyenthedeveloper for pointing me to this. I modified it in the last update.

In future updates I'll check only the enrolment method the user used and also the award may be become a percentage of what they pay for the course.