Skip to content

Commit

Permalink
MDL-43908 mod_assign: Prevent notifications for unavailable assignments
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Butler <[email protected]>
  • Loading branch information
tonyjbutler committed Jul 24, 2014
1 parent ccd6839 commit c681f7a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5971,7 +5971,16 @@ public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data,
}
}
$mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
$mform->setDefault('sendstudentnotifications', $this->get_instance()->sendstudentnotifications);
// Get assignment visibility information for student.
$modinfo = get_fast_modinfo($settings->course, $userid);
$cm = $modinfo->get_cm($this->get_course_module()->id);
// Don't allow notification to be sent if student can't access assignment.
if (!$cm->uservisible) {
$mform->setDefault('sendstudentnotifications', 0);
$mform->freeze('sendstudentnotifications');
} else {
$mform->setDefault('sendstudentnotifications', $this->get_instance()->sendstudentnotifications);
}

$mform->addElement('hidden', 'action', 'submitgrade');
$mform->setType('action', PARAM_ALPHA);
Expand Down

0 comments on commit c681f7a

Please sign in to comment.