Skip to content

Commit

Permalink
MDL-58278 mod_assign: Ignore send notify with mw
Browse files Browse the repository at this point in the history
When marking workflow is on and the grade is not released we never send notifications anyway.
Instead of preventing the grading form from submitting (validation error) we silently ignore it.
  • Loading branch information
Damyon Wiese committed Apr 20, 2017
1 parent 6e0c45e commit 6785483
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 0 additions & 5 deletions mod/assign/gradeform.php
Expand Up @@ -78,11 +78,6 @@ public function validation($data, $files) {
$errors = parent::validation($data, $files);
$instance = $this->assignment->get_instance();

if ($instance->markingworkflow && !empty($data['sendstudentnotifications']) &&
$data['workflowstate'] != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
$errors['workflowstate'] = get_string('studentnotificationworkflowstateerror', 'assign');
}

// Advanced grading.
if (!array_key_exists('grade', $data)) {
return $errors;
Expand Down
8 changes: 8 additions & 0 deletions mod/assign/locallib.php
Expand Up @@ -7430,6 +7430,14 @@ protected function apply_grade_to_user($formdata, $userid, $attemptnumber) {
$feedbackmodified) {
$this->update_grade($grade, !empty($formdata->addattempt));
}

// We never send notifications if we have marking workflow and the grade is not released.
if ($this->get_instance()->markingworkflow &&
isset($formdata->workflowstate) &&
$formdata->workflowstate != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
$formdata->sendstudentnotifications = false;
}

// 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) {
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/tests/locallib_test.php
Expand Up @@ -1169,10 +1169,12 @@ public function test_markingworkflow_cron() {
$data->grade = '50.0';

// This student will not receive notification.
$data->sendstudentnotifications = 1;
$data->workflowstate = ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE;
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);

// This student will receive notification.
$data->sendstudentnotifications = 1;
$data->workflowstate = ASSIGN_MARKING_WORKFLOW_STATE_RELEASED;
$assign->testable_apply_grade_to_user($data, $this->students[1]->id, 0);

Expand Down

0 comments on commit 6785483

Please sign in to comment.