Skip to content

Commit

Permalink
some fixes to refund upon unenrol logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fmido88 authored Nov 13, 2023
1 parent 442c67f commit a9bebee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ public function unenrol_user(stdClass $instance, $userid) {
$refundperiod = get_config('enrol_wallet', 'unenrolrefundperiod');
$now = time();
if (
$now > $enrolend
|| ($now - $enrolstart) > $refundperiod
(!empty($enrolend) && $now > $enrolend) // The enrolmet already ended.
|| ($now > $enrolstart && !empty($refundperiod) && ($now - $enrolstart) > $refundperiod) // Passed the period.
) {
// Condition for refunding aren't met.
return parent::unenrol_user($instance, $userid);
Expand Down Expand Up @@ -311,6 +311,7 @@ public function unenrol_user(stdClass $instance, $userid) {
if ($credit <= 0) {
return parent::unenrol_user($instance, $userid);
} else if ($credit > $cost) {
// Shouldn't happen.
$credit = $cost;
}

Expand Down Expand Up @@ -1587,7 +1588,7 @@ public function course_updated($inserted, $course, $data) {
* @param object $context context of existing course or parent category if course does not exist
* @return array errors array
*/
public function course_edit_validation($instance, array $data, $context) {
public function course_edit_validation($instance, $data, $context) {
if (empty($instance)) {
if (isset($data['instanceid'])) {
$data['id'] = $data['instanceid'];
Expand Down

0 comments on commit a9bebee

Please sign in to comment.