From 0a98527d681cdc1e07780ebc17e0eec9632e2ded Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Tue, 29 Aug 2023 11:56:32 +0200 Subject: [PATCH 1/3] added checkbox to make sending a confirmation email for requested evaluations to teachers optional --- classes/evaluation_manager.php | 8 +++++--- classes/evasys_category.php | 5 +++++ classes/local/form/evasys_category_edit_form.php | 8 ++++++++ lang/de/block_evasys_sync.php | 2 ++ lang/en/block_evasys_sync.php | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/classes/evaluation_manager.php b/classes/evaluation_manager.php index bc6d0f6..e11ab69 100644 --- a/classes/evaluation_manager.php +++ b/classes/evaluation_manager.php @@ -109,11 +109,13 @@ public static function set_default_evaluation_for($courseids, evasys_category $c $data->courseshort = $course->shortname; $data->coursefull = $course->fullname; - foreach ($teachers as $teacher) { - email_to_user($teacher, $coordinatoruser, + if ($category->send_mail_to_teacher()) { + foreach ($teachers as $teacher) { + email_to_user($teacher, $coordinatoruser, get_string('notify_teacher_email_subject', 'block_evasys_sync', $data), get_string('notify_teacher_email_body', 'block_evasys_sync', $data) - ); + ); + } } self::clear_error($course->id); diff --git a/classes/evasys_category.php b/classes/evasys_category.php index a4c05e3..fb870a8 100644 --- a/classes/evasys_category.php +++ b/classes/evasys_category.php @@ -43,6 +43,7 @@ class evasys_category extends persistent { const MASK_AUTOMATIC_TASK_CREATION = 1 << 2; const MASK_TEACHER_CAN_CHANGE_EVALUATION = 1 << 3; const MASK_EVALUATION_CHANGE_NEEDS_APPROVAL = 1 << 4; + const MASK_SEND_MAIL_TO_TEACHER = 1 << 5; /** * Return the definition of the properties of this model. @@ -119,6 +120,10 @@ public function can_teacher_request_evaluation() : bool { return $this->get('mode_flags') & self::MASK_TEACHER_CAN_REQUEST_EVALUATION; } + public function send_mail_to_teacher() : bool { + return $this->get('mode_flags') & self::MASK_SEND_MAIL_TO_TEACHER; + } + public function teacher_evaluation_request_needs_approval() : bool { return $this->get('mode_flags') & self::MASK_EVALUATION_REQUEST_NEEDS_APPROVAL; } diff --git a/classes/local/form/evasys_category_edit_form.php b/classes/local/form/evasys_category_edit_form.php index d71db34..f1fd964 100644 --- a/classes/local/form/evasys_category_edit_form.php +++ b/classes/local/form/evasys_category_edit_form.php @@ -69,6 +69,10 @@ protected function definition() { get_string('teacher_can_request_evaluation', 'block_evasys_sync')); $mform->setDefault('teacher_can_request_evaluation', true); + $mform->addElement('checkbox', 'send_mail_to_teacher', + get_string('send_mail_to_teacher', 'block_evasys_sync')); + $mform->setDefault('send_mail_to_teacher', true); + // TODO automatic /*$mform->addElement('checkbox', 'teacher_evaluation_request_needs_approval', get_string('teacher_evaluation_request_needs_approval', 'block_evasys_sync')); @@ -91,6 +95,7 @@ protected function definition() { $mform->setDefault('standard_time_end', $this->evasys_category->get('standard_time_end')); } $mform->setDefault('teacher_can_request_evaluation', $this->evasys_category->can_teacher_request_evaluation()); + $mform->setDefault('send_mail_to_teacher', $this->evasys_category->send_mail_to_teacher()); // $mform->setDefault('teacher_evaluation_request_needs_approval', $this->evasys_category->teacher_evaluation_request_needs_approval()); // $mform->setDefault('automatic_task_creation', $this->evasys_category->is_automatic()); @@ -109,6 +114,9 @@ function get_data_transformed(): ?evasys_category { if ($data->teacher_can_request_evaluation ?? false) { $flags |= evasys_category::MASK_TEACHER_CAN_REQUEST_EVALUATION; } + if ($data->send_mail_to_teacher ?? false) { + $flags |= evasys_category::MASK_SEND_MAIL_TO_TEACHER; + } if ($data->teacher_evaluation_needs_approval ?? false) { $flags |= evasys_category::MASK_EVALUATION_REQUEST_NEEDS_APPROVAL; } diff --git a/lang/de/block_evasys_sync.php b/lang/de/block_evasys_sync.php index 732c06a..15c7037 100755 --- a/lang/de/block_evasys_sync.php +++ b/lang/de/block_evasys_sync.php @@ -245,6 +245,8 @@ $string['teacher_can_change_evaluation'] = 'Lehrende können bestehende Evaluationen verändern'; $string['teacher_evaluation_change_needs_approval'] = 'Änderungen an bestehenden Evaluationen müssen von Ihnen bestätigt werden'; +$string['send_mail_to_teacher'] = 'Sende Bestätigungsmail an Lehrende'; + $string['search_for_courses'] = 'Nach Kursen suchen'; $string['evasys_settings_for'] = 'Evasys-Einstellungen für {$a}'; diff --git a/lang/en/block_evasys_sync.php b/lang/en/block_evasys_sync.php index b0740ae..ed627b8 100755 --- a/lang/en/block_evasys_sync.php +++ b/lang/en/block_evasys_sync.php @@ -256,6 +256,8 @@ $string['teacher_can_change_evaluation'] = 'Teachers can change existing evaluation'; $string['teacher_evaluation_change_needs_approval'] = 'Teacher\'s evaluation changes needs approval from you'; +$string['send_mail_to_teacher'] = 'Send mail to teacher'; + $string['search_for_courses'] = 'Search for courses'; $string['evasys_settings_for'] = 'Evasys settings for {$a}'; From e7393f9059e4878ed568c67dd2f2416aff83cc20 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Thu, 21 Sep 2023 12:40:28 +0200 Subject: [PATCH 2/3] added help button for send_mail_to_teacher checkbox --- classes/local/form/evasys_category_edit_form.php | 1 + lang/de/block_evasys_sync.php | 2 ++ lang/en/block_evasys_sync.php | 1 + 3 files changed, 4 insertions(+) diff --git a/classes/local/form/evasys_category_edit_form.php b/classes/local/form/evasys_category_edit_form.php index f1fd964..57efd07 100644 --- a/classes/local/form/evasys_category_edit_form.php +++ b/classes/local/form/evasys_category_edit_form.php @@ -72,6 +72,7 @@ protected function definition() { $mform->addElement('checkbox', 'send_mail_to_teacher', get_string('send_mail_to_teacher', 'block_evasys_sync')); $mform->setDefault('send_mail_to_teacher', true); + $mform->addHelpButton('send_mail_to_teacher', 'send_mail_to_teacher', 'block_evasys_sync'); // TODO automatic /*$mform->addElement('checkbox', 'teacher_evaluation_request_needs_approval', diff --git a/lang/de/block_evasys_sync.php b/lang/de/block_evasys_sync.php index 15c7037..195bb93 100755 --- a/lang/de/block_evasys_sync.php +++ b/lang/de/block_evasys_sync.php @@ -246,6 +246,8 @@ $string['teacher_evaluation_change_needs_approval'] = 'Änderungen an bestehenden Evaluationen müssen von Ihnen bestätigt werden'; $string['send_mail_to_teacher'] = 'Sende Bestätigungsmail an Lehrende'; +$string['send_mail_to_teacher_help'] = 'Falls ausgewählt, wird eine Benachrichtigungsmail an Lehrende geschickt, wenn über die evasys-Überblick-Seite eine Evaluation für ihren Kurs beantragt wird.'; + $string['search_for_courses'] = 'Nach Kursen suchen'; diff --git a/lang/en/block_evasys_sync.php b/lang/en/block_evasys_sync.php index ed627b8..003a940 100755 --- a/lang/en/block_evasys_sync.php +++ b/lang/en/block_evasys_sync.php @@ -257,6 +257,7 @@ $string['teacher_evaluation_change_needs_approval'] = 'Teacher\'s evaluation changes needs approval from you'; $string['send_mail_to_teacher'] = 'Send mail to teacher'; +$string['send_mail_to_teacher_help'] = 'If checked, each time an evaluation is requested from the evasys overview page, a notification email will be sent to the teacher of the course.'; $string['search_for_courses'] = 'Search for courses'; From dcb66e492764aae001a9c50ed435e1de878749d6 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Thu, 21 Sep 2023 13:01:28 +0200 Subject: [PATCH 3/3] changed default values of evasys_category.php mode_flags --- adminsettings.php | 2 +- classes/evasys_category.php | 1 + db/install.xml | 2 +- db/upgrade.php | 12 ++++++++++++ version.php | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/adminsettings.php b/adminsettings.php index 4d26b4a..9dee70d 100755 --- a/adminsettings.php +++ b/adminsettings.php @@ -74,7 +74,7 @@ } else { $record->category_mode = 0; } - $record->mode_flags = 0; + //$record->mode_flags = 0; $persistent = new \block_evasys_sync\evasys_category(0, $record); $persistent->create(); if ($evasysroleid) { diff --git a/classes/evasys_category.php b/classes/evasys_category.php index fb870a8..55b569e 100644 --- a/classes/evasys_category.php +++ b/classes/evasys_category.php @@ -65,6 +65,7 @@ protected static function define_properties() { 'message' => new \lang_string('invalidmode', 'block_evasys_sync') ), 'mode_flags' => array( + 'default' => 33, 'type' => PARAM_INT ), 'standard_time_start' => array ( diff --git a/db/install.xml b/db/install.xml index e57334e..9e01daa 100644 --- a/db/install.xml +++ b/db/install.xml @@ -9,7 +9,7 @@ - + diff --git a/db/upgrade.php b/db/upgrade.php index f3f87dd..296ee7b 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -532,5 +532,17 @@ function xmldb_block_evasys_sync_upgrade ($oldversion) { upgrade_block_savepoint(true, 2022092400, 'evasys_sync'); } + if ($oldversion < 2023092100) { + // Changing default of evasyscategory mode_flags + $table = new xmldb_table('block_evasys_sync_categories'); + $field = new xmldb_field('mode_flags', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, 33, 'category_mode'); + + // Launch change of type for field mode_flags. + $dbman->change_field_default($table, $field); + + // Evasys_sync savepoint reached. + upgrade_block_savepoint(true, 2023092100, 'evasys_sync'); + } + return true; } diff --git a/version.php b/version.php index 98d9e74..4ad0c08 100755 --- a/version.php +++ b/version.php @@ -18,6 +18,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'block_evasys_sync'; -$plugin->version = 2023080700; // YYYYMMDDHH (year, month, day, 24-hr time). +$plugin->version = 2023092100; // YYYYMMDDHH (year, month, day, 24-hr time). $plugin->requires = 2022041900; // YYYYMMDDHH (This is the release version for Moodle 4.0). $plugin->maturity = MATURITY_RC;