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

make sending a confirmation email for requested evaluations to teachers optional #74

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 adminsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions classes/evaluation_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions classes/evasys_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -64,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 (
Expand Down Expand Up @@ -119,6 +121,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;
}
Expand Down
9 changes: 9 additions & 0 deletions classes/local/form/evasys_category_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ 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);
$mform->addHelpButton('send_mail_to_teacher', 'send_mail_to_teacher', 'block_evasys_sync');

// TODO automatic
/*$mform->addElement('checkbox', 'teacher_evaluation_request_needs_approval',
get_string('teacher_evaluation_request_needs_approval', 'block_evasys_sync'));
Expand All @@ -91,6 +96,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());

Expand All @@ -109,6 +115,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;
}
Expand Down
2 changes: 1 addition & 1 deletion db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course_category" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="category_mode" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="mode_flags" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="See evasys_category for explanation."/>
<FIELD NAME="mode_flags" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="33" SEQUENCE="false" COMMENT="See evasys_category for explanation."/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
Expand Down
12 changes: 12 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions lang/de/block_evasys_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@
$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['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';

$string['evasys_settings_for'] = 'Evasys-Einstellungen für {$a}';
Expand Down
3 changes: 3 additions & 0 deletions lang/en/block_evasys_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
$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['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';

$string['evasys_settings_for'] = 'Evasys settings for {$a}';
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;