Skip to content

Commit

Permalink
Merge branch 'MDL-46442-master' of git://github.com/zbdd/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Dec 16, 2014
2 parents c236f82 + a4b10a5 commit b721d50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1870,13 +1870,14 @@ public static function cron() {
* Mark in the database that this grade record should have an update notification sent by cron.
*
* @param stdClass $grade a grade record keyed on id
* @param bool $mailedoverride when true, flag notification to be sent again.
* @return bool true for success
*/
public function notify_grade_modified($grade) {
public function notify_grade_modified($grade, $mailedoverride = false) {
global $DB;

$flags = $this->get_user_flags($grade->userid, true);
if ($flags->mailed != 1) {
if ($flags->mailed != 1 || $mailedoverride) {
$flags->mailed = 0;
}

Expand Down Expand Up @@ -6652,7 +6653,7 @@ protected function apply_grade_to_user($formdata, $userid, $attemptnumber) {
// 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);
$this->notify_grade_modified($grade, true);
}
}

Expand Down
7 changes: 7 additions & 0 deletions mod/assign/tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,13 @@ public function test_cron() {
$this->assertEquals(2, count($messages));
$this->assertEquals(1, $messages[0]->notification);
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);

// Regrading a grade causes a notification to the user.
$data->sendstudentnotifications = true;
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
assign::cron();
$messages = $sink->get_messages();
$this->assertEquals(3, count($messages));
}

/**
Expand Down

0 comments on commit b721d50

Please sign in to comment.