Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: suppress cancel emails in bulk upload #174

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/booking_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 16 additions & 5 deletions tests/upload_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,29 +550,40 @@ 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,
],
];
}

/**
* 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');

// Create f2f in course.
// 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();
Expand All @@ -595,7 +606,7 @@ public function test_email_suppression($shouldsuppress) {
$record = (object) [
'email' => $student->email,
'session' => $session->id,
'status' => 'booked',
'status' => $status,
];

$records = [$record];
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024070500;
$plugin->release = 2024070500;
$plugin->version = 2024070900;
$plugin->release = 2024070900;
$plugin->requires = 2023100900; // Requires 4.3.
$plugin->component = 'mod_facetoface';
$plugin->maturity = MATURITY_STABLE;
Expand Down
Loading