MDL-45324 assign: notify when workflow is Off, or if state is Released

When marking workflow is enabled, students will be notified only when
the workflow state transitions to 'Released'. Until that happens,
sending of messages will be held and the 'Notify students' grading
form option will be locked.

Additionally, the batch set marking workflow state facility gains
the 'Notify students' option.

Credit to Steve Upton and David Balch for the basis of this patch.
This commit is contained in:
Jonathon Fowler
2014-12-10 22:29:08 +10:00
parent 2d84748c26
commit 70cfc878b9
5 changed files with 98 additions and 6 deletions
@@ -49,6 +49,11 @@ class mod_assign_batch_set_marking_workflow_state_form extends moodleform {
$options = $params['markingworkflowstates'];
$mform->addElement('select', 'markingworkflowstate', get_string('markingworkflowstate', 'assign'), $options);
// Don't allow notification to be sent until in "Released" state.
$mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
$mform->setDefault('sendstudentnotifications', 0);
$mform->disabledIf('sendstudentnotifications', 'markingworkflowstate', 'neq', ASSIGN_MARKING_WORKFLOW_STATE_RELEASED);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action', 'setbatchmarkingworkflowstate');
@@ -59,5 +64,24 @@ class mod_assign_batch_set_marking_workflow_state_form extends moodleform {
}
/**
* Validate the submitted form data.
*
* @param array $data array of ("fieldname"=>value) of submitted data
* @param array $files array of uploaded files "element_name"=>tmp_file_path
* @return array of "element_name"=>"error_description" if there are errors
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
// As the implementation of this feature exists currently, no user will see a validation
// failure from this form, but this check ensures the form won't validate if someone
// manipulates the 'sendstudentnotifications' field's disabled attribute client-side.
if (!empty($data['sendstudentnotifications']) && $data['markingworkflowstate'] != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
$errors['sendstudentnotifications'] = get_string('studentnotificationworkflowstateerror', 'assign');
}
return $errors;
}
}