Skip to content

Commit

Permalink
Improvement: Add message about enrolment to waitinglist #800
Browse files Browse the repository at this point in the history
  • Loading branch information
eynimeni committed Jan 30, 2025
1 parent 6a9ade7 commit b6a68c0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
9 changes: 7 additions & 2 deletions classes/enrollink.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function enrol_user(int $userid): int {
try {
$user = singleton_service::get_instance_of_user($userid);
$booking = singleton_service::get_instance_of_booking_by_cmid($cmid);
// Enrol to bookingoption and reduce places in bookinganswer.
$bo->user_submit_response(
$user,
$booking->id,
Expand All @@ -173,9 +174,13 @@ public function enrol_user(int $userid): int {
MOD_BOOKING_VERIFIED,
$this->erlid
);
// Change answer if user was enrolled only to waitinglist.
if ($this->enrolmentstatus_waitinglist($bo->settings)) {
$courseenrolmentstatus = MOD_BOOKING_AUTOENROL_STATUS_WAITINGLIST;
} else {
$courseenrolmentstatus = MOD_BOOKING_AUTOENROL_STATUS_SUCCESS;
}

// Enrol to bookingoption and reduce places in bookinganswer.
$courseenrolmentstatus = MOD_BOOKING_AUTOENROL_STATUS_SUCCESS;
} catch (\Exception $e) {
$courseenrolmentstatus = MOD_BOOKING_AUTOENROL_STATUS_EXCEPTION;
}
Expand Down
1 change: 1 addition & 0 deletions lang/de/booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@
$string['enrollink:3'] = 'Ihr Einschreibelink ist leider fehlerhaft';
$string['enrollink:4'] = 'Es sind keine freien Plätze mehr in Ihrem Kontingent verfügbar';
$string['enrollink:5'] = 'Keine Gastnutzer erlaubt';
$string['enrollink:6'] = 'Ihre Anmeldung ist erfolgt und muss noch von einer berechtigten Person bestätigt werden.';
$string['enrollinktriggered'] = 'Einschreibe-Link Generierung ausgelöst';
$string['enrollinktriggered:description'] = 'Das Event als Grundlage für die automatische Generierung eines Einschreibe-Links wurde ausgelöst.';
$string['enrolmentstatus'] = 'Nutzer:innen erst zu Kursbeginn in den Kurs einschreiben (Standard: Nicht angehakt → sofort einschreiben.)';
Expand Down
1 change: 1 addition & 0 deletions lang/en/booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@
$string['enrollink:3'] = 'Your enrolment link is invalid.';
$string['enrollink:4'] = 'There are no more places available in the bundle.';
$string['enrollink:5'] = 'No guestusers allowed';
$string['enrollink:6'] = 'Your registration has been completed and must still be confirmed by an authorised person.';
$string['enrollinktriggered'] = 'Enrol link generation triggered';
$string['enrollinktriggered:description'] = 'The event as the basis for the automatic generation of an enrolment link has been triggered.';
$string['enrolmentstatus'] = 'Enrol users at course start time (Default: Not checked → enrol them immediately.)';
Expand Down
1 change: 1 addition & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
define('MOD_BOOKING_AUTOENROL_STATUS_LINK_NOT_VALID', 3);
define('MOD_BOOKING_AUTOENROL_STATUS_NO_MORE_SEATS', 4);
define('MOD_BOOKING_AUTOENROL_STATUS_LOGGED_IN_AS_GUEST', 5);
define('MOD_BOOKING_AUTOENROL_STATUS_WAITINGLIST', 6);

// Status for user submit response (enrolment into bookingoption).
// 1 if we just added this booking option to the shopping cart, 2 for confirmation.
Expand Down
10 changes: 5 additions & 5 deletions tests/booking_rules/rules_enrollink_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,11 @@ public function test_rule_on_enrollink_and_enroll_via_waitinglists(array $bdata)
$infostring = $enrollink->get_readable_info($info2);
$courselink = $enrollink->get_courselink_url();
// Validate enrollment status and remainaing free places.
$this->assertEquals(MOD_BOOKING_AUTOENROL_STATUS_SUCCESS, $info2);
$this->assertEquals('Successfully enrolled', $infostring);
$this->assertEquals(MOD_BOOKING_AUTOENROL_STATUS_WAITINGLIST, $info2);
$this->assertEquals('Your registration has been completed and must still be confirmed by an authorised person.', $infostring);
$this->assertStringContainsString('/moodle/course/view.php?id=' . $course2->id, $courselink);
$this->assertEquals(2, $enrollink->free_places_left());
// TODO: I would expect 1 there? Or after confirmation?
// No reduction of seats because user needs confirmation first.

// Proceed with enrolling of student3.
$this->setUser($student3);
Expand All @@ -636,7 +636,7 @@ public function test_rule_on_enrollink_and_enroll_via_waitinglists(array $bdata)
$info2 = $enrollink->enrol_user($student3->id);
$courselink = $enrollink->get_courselink_url();
// Validate enrollment status and remainaing free places.
$this->assertEquals(MOD_BOOKING_AUTOENROL_STATUS_SUCCESS, $info2);
$this->assertEquals(MOD_BOOKING_AUTOENROL_STATUS_WAITINGLIST, $info2);
$this->assertStringContainsString('/moodle/course/view.php?id=' . $course2->id, $courselink);
$this->assertEquals(2, $enrollink->free_places_left());

Expand Down Expand Up @@ -665,7 +665,7 @@ public function test_rule_on_enrollink_and_enroll_via_waitinglists(array $bdata)
$info2 = $enrollink->enrol_user($USER->id);
$courselink = $enrollink->get_courselink_url();
// Validate enrollment status and remainaing free places.
$this->assertEquals(MOD_BOOKING_AUTOENROL_STATUS_SUCCESS, $info2);
$this->assertEquals(MOD_BOOKING_AUTOENROL_STATUS_WAITINGLIST, $info2);
$this->assertStringContainsString('/moodle/course/view.php?id=' . $course2->id, $courselink);
$this->assertEquals(1, $enrollink->free_places_left());

Expand Down

0 comments on commit b6a68c0

Please sign in to comment.