Skip to content

Commit

Permalink
Merge branch 'MDL-36667-24' of git://github.com/damyon/moodle into MO…
Browse files Browse the repository at this point in the history
…ODLE_24_STABLE
  • Loading branch information
danpoltawski committed Jan 7, 2013
2 parents e04f57c + 3d6b1bf commit 181b7f5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mod/assign/feedback/file/importziplib.php
Expand Up @@ -266,7 +266,7 @@ public function import_zip_files($assignment, $fileplugin) {
$fileplugin->update_file_count($grade); $fileplugin->update_file_count($grade);


// Update the last modified time on the grade which will trigger student notifications. // Update the last modified time on the grade which will trigger student notifications.
$assignment->update_grade($grade); $assignment->notify_grade_modified($grade);
} }
} }
} }
Expand Down
1 change: 1 addition & 0 deletions mod/assign/feedback/file/locallib.php
Expand Up @@ -403,6 +403,7 @@ public function view_batch_upload_files($users) {
// Now copy each of these files to the users feedback file area. // Now copy each of these files to the users feedback file area.
foreach ($users as $userid) { foreach ($users as $userid) {
$grade = $this->assignment->get_user_grade($userid, true); $grade = $this->assignment->get_user_grade($userid, true);
$this->assignment->notify_grade_modified($grade);


$this->copy_area_files($fs, $this->copy_area_files($fs,
$this->assignment->get_context()->id, $this->assignment->get_context()->id,
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/feedback/offline/locallib.php
Expand Up @@ -157,6 +157,7 @@ public function process_import_grades($draftid, $importid, $ignoremodified) {
$grade->grade = $record->grade; $grade->grade = $record->grade;
$grade->grader = $USER->id; $grade->grader = $USER->id;
if ($this->assignment->update_grade($grade)) { if ($this->assignment->update_grade($grade)) {
$this->assignment->notify_grade_modified($grade);
$this->assignment->add_to_log('grade submission', $this->assignment->format_grade_for_log($grade)); $this->assignment->add_to_log('grade submission', $this->assignment->format_grade_for_log($grade));
$updatecount += 1; $updatecount += 1;
} }
Expand All @@ -178,6 +179,7 @@ public function process_import_grades($draftid, $importid, $ignoremodified) {
if ($newvalue != $oldvalue) { if ($newvalue != $oldvalue) {
$updatecount += 1; $updatecount += 1;
$grade = $this->assignment->get_user_grade($record->user->id, true); $grade = $this->assignment->get_user_grade($record->user->id, true);
$this->assignment->notify_grade_modified($grade);
if ($plugin->set_editor_text($field, $newvalue, $grade->id)) { if ($plugin->set_editor_text($field, $newvalue, $grade->id)) {
$logdesc = get_string('feedbackupdate', 'assignfeedback_offline', $logdesc = get_string('feedbackupdate', 'assignfeedback_offline',
array('field'=>$description, array('field'=>$description,
Expand Down
23 changes: 23 additions & 0 deletions mod/assign/locallib.php
Expand Up @@ -1476,6 +1476,23 @@ static function cron() {
return true; return true;
} }


/**
* 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
* @return bool true for success
*/
public function notify_grade_modified($grade) {
global $DB;

$grade->timemodified = time();
if ($grade->mailed != 1) {
$grade->mailed = 0;
}

return $DB->update_record('assign_grades', $grade);
}

/** /**
* Update a grade in the grade table for the assignment and in the gradebook * Update a grade in the grade table for the assignment and in the gradebook
* *
Expand Down Expand Up @@ -2175,6 +2192,10 @@ public function get_user_grade($userid, $create) {
$grade->grade = -1; $grade->grade = -1;
$grade->grader = $USER->id; $grade->grader = $USER->id;
$grade->extensionduedate = 0; $grade->extensionduedate = 0;

// The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet.
// This is because students only want to be notified about certain types of update (grades and feedback).
$grade->mailed = 2;
$gid = $DB->insert_record('assign_grades', $grade); $gid = $DB->insert_record('assign_grades', $grade);
$grade->id = $gid; $grade->id = $gid;
return $grade; return $grade;
Expand Down Expand Up @@ -3712,6 +3733,7 @@ private function process_save_quick_grades() {
} }


$this->update_grade($grade); $this->update_grade($grade);
$this->notify_grade_modified($grade);


// save outcomes // save outcomes
if ($CFG->enableoutcomes) { if ($CFG->enableoutcomes) {
Expand Down Expand Up @@ -4406,6 +4428,7 @@ private function apply_grade_to_user($formdata, $userid) {
} }
} }
$this->update_grade($grade); $this->update_grade($grade);
$this->notify_grade_modified($grade);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);


$this->add_to_log('grade submission', $this->format_grade_for_log($grade)); $this->add_to_log('grade submission', $this->format_grade_for_log($grade));
Expand Down

0 comments on commit 181b7f5

Please sign in to comment.