diff --git a/classes/booking_manager.php b/classes/booking_manager.php index 9650450..af97e53 100644 --- a/classes/booking_manager.php +++ b/classes/booking_manager.php @@ -335,7 +335,7 @@ public function process() { if (facetoface_user_cancel($session, $user->id, true, $cancelerr)) { // Notify the user of the cancellation if the session hasn't started yet. $timenow = time(); - if (!facetoface_has_session_started($session, $timenow)) { + if (!facetoface_has_session_started($session, $timenow) && !$this->suppressemail) { facetoface_send_cancellation_notice($this->facetoface, $session, $user->id); } } else { diff --git a/tests/upload_test.php b/tests/upload_test.php index f071338..b7a4a83 100644 --- a/tests/upload_test.php +++ b/tests/upload_test.php @@ -550,10 +550,20 @@ public function test_updates_for_previous_sessions() { */ public static function email_suppression_provider(): array { return [ - 'no suppression' => [ + 'no suppression, booked' => [ + 'status' => 'booked', 'shouldsuppress' => false, ], - 'suppressed emails' => [ + 'suppressed emails, booked' => [ + 'status' => 'booked', + 'shouldsuppress' => true, + ], + 'no suppression, cancel' => [ + 'status' => 'cancelled', + 'shouldsuppress' => false, + ], + 'suppressed emails, cancel' => [ + 'status' => 'cancelled', 'shouldsuppress' => true, ], ]; @@ -561,10 +571,11 @@ public static function email_suppression_provider(): array { /** * Tests that the email suppression property is considered when signing up users. + * @param string $status status of session to use in csv * @param bool $shouldsuppress * @dataProvider email_suppression_provider */ - public function test_email_suppression($shouldsuppress) { + public function test_email_suppression(string $status, bool $shouldsuppress) { /** @var \mod_facetoface_generator $generator */ $generator = $this->getDataGenerator()->get_plugin_generator('mod_facetoface'); @@ -572,7 +583,7 @@ public function test_email_suppression($shouldsuppress) { // Note the f2f must have a confirmation message & subject set, otherwise no emails will be sent ever. $course = $this->getDataGenerator()->create_course(); $facetoface = $generator->create_instance(['course' => $course->id, 'confirmationmessage' => 'test', - 'confirmationsubject' => 'test']); + 'confirmationsubject' => 'test', 'cancellationmessage' => 'test', 'cancellationsubject' => 'test']); $student = $this->getDataGenerator()->create_and_enrol($course, 'student'); $this->setCurrentTimeStart(); @@ -595,7 +606,7 @@ public function test_email_suppression($shouldsuppress) { $record = (object) [ 'email' => $student->email, 'session' => $session->id, - 'status' => 'booked', + 'status' => $status, ]; $records = [$record]; diff --git a/version.php b/version.php index 9ab8d81..4fd789c 100644 --- a/version.php +++ b/version.php @@ -30,8 +30,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023101905; -$plugin->release = 2022101905; +$plugin->version = 2023101906; +$plugin->release = 2023101906; $plugin->requires = 2022031500; // Requires 4.0. $plugin->component = 'mod_facetoface'; $plugin->maturity = MATURITY_STABLE;