mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-33600 Assign: Allow teachers to skip notifying students about grade update.
This commit is contained in:
parent
ab7f498343
commit
f7dc9871e7
4 changed files with 21 additions and 2 deletions
|
@ -312,6 +312,8 @@ $string['savegradingresult'] = 'Grade';
|
|||
$string['saveallquickgradingchanges'] = 'Save all quick grading changes';
|
||||
$string['savenext'] = 'Save and show next';
|
||||
$string['scale'] = 'Scale';
|
||||
$string['sendstudentnotifications'] = 'Notify students';
|
||||
$string['sendstudentnotifications_help'] = 'If enabled, students receive a message about the updated grade or feedback.';
|
||||
$string['sendnotifications'] = 'Notify graders about submissions';
|
||||
$string['sendnotifications_help'] = 'If enabled, graders (usually teachers) receive a message whenever a student submits an assignment, early, on time and late. Message methods are configurable.';
|
||||
$string['selectlink'] = 'Select...';
|
||||
|
|
|
@ -4928,7 +4928,10 @@ class assign {
|
|||
$this->update_user_flags($flags);
|
||||
}
|
||||
$this->update_grade($grade);
|
||||
$this->notify_grade_modified($grade);
|
||||
// Allow teachers to skip sending notifications.
|
||||
if (optional_param('sendstudentnotifications', true, PARAM_BOOL)) {
|
||||
$this->notify_grade_modified($grade);
|
||||
}
|
||||
|
||||
// Save outcomes.
|
||||
if ($CFG->enableoutcomes) {
|
||||
|
@ -5720,6 +5723,8 @@ class assign {
|
|||
$mform->setDefault('addattempt', 0);
|
||||
}
|
||||
}
|
||||
$mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
|
||||
$mform->setDefault('sendstudentnotifications', 1);
|
||||
|
||||
$mform->addElement('hidden', 'action', 'submitgrade');
|
||||
$mform->setType('action', PARAM_ALPHA);
|
||||
|
@ -6215,7 +6220,11 @@ class assign {
|
|||
}
|
||||
}
|
||||
$this->update_grade($grade);
|
||||
$this->notify_grade_modified($grade);
|
||||
// Note the default if not provided for this option is true (e.g. webservices).
|
||||
// This is for backwards compatibility.
|
||||
if (!isset($formdata->sendstudentnotifications) || $formdata->sendstudentnotifications) {
|
||||
$this->notify_grade_modified($grade);
|
||||
}
|
||||
|
||||
$addtolog = $this->add_to_log('grade submission', $this->format_grade_for_log($grade), '', true);
|
||||
$params = array(
|
||||
|
|
|
@ -52,6 +52,10 @@ class mod_assign_quick_grading_form extends moodleform {
|
|||
$mform->addElement('hidden', 'action', 'quickgrade');
|
||||
$mform->setType('action', PARAM_ALPHA);
|
||||
|
||||
// Skip notifications option.
|
||||
$mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
|
||||
$mform->setDefault('sendstudentnotifications', 1);
|
||||
|
||||
// Buttons.
|
||||
$savemessage = get_string('saveallquickgradingchanges', 'assign');
|
||||
$mform->addElement('submit', 'savequickgrades', $savemessage);
|
||||
|
|
|
@ -536,6 +536,9 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
|
|||
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
|
||||
$assign->testable_apply_grade_to_user($data, $this->students[1]->id, 0);
|
||||
|
||||
$data->sendstudentnotifications = false;
|
||||
$assign->testable_apply_grade_to_user($data, $this->students[2]->id, 0);
|
||||
|
||||
// Now run cron and see that one message was sent.
|
||||
$this->preventResetByRollback();
|
||||
$sink = $this->redirectMessages();
|
||||
|
@ -544,6 +547,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
|
|||
assign::cron();
|
||||
|
||||
$messages = $sink->get_messages();
|
||||
// The sent count should be 2, because the 3rd one was marked as do not send notifications.
|
||||
$this->assertEquals(2, count($messages));
|
||||
$this->assertEquals(1, $messages[0]->notification);
|
||||
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue