MDL-66360 grade: fix user grade notification sending errors

This commit is contained in:
Simey Lameze 2019-11-08 09:49:58 +08:00
parent c67a54e619
commit 175fd687b4
2 changed files with 6 additions and 11 deletions

View File

@ -491,13 +491,7 @@ abstract class component_gradeitem {
* @param stdClass $grader The user who is grading
*/
public function send_student_notification(stdClass $gradeduser, stdClass $grader): void {
list($itemtype, $itemmodule) = \core_component::normalize_component($this->component);
$gradeitem = \grade_item::fetch([
'itemtype' => $itemtype,
'itemmodule' => $itemmodule,
'iteminstance' => $this->itemnumber,
]);
$contextname = $this->context->get_context_name();
$eventdata = new \core\message\message();
$eventdata->courseid = $this->context->get_course_context()->instanceid;
$eventdata->component = 'moodle';
@ -505,9 +499,10 @@ abstract class component_gradeitem {
$eventdata->userfrom = $grader;
$eventdata->userto = $gradeduser;
$eventdata->subject = get_string('gradenotificationsubject', 'grades');
$eventdata->fullmessage = get_string('gradenotificationmessage', 'grades', ['name' => $gradeitem->get_name()]);
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessage = get_string('gradenotificationmessage', 'grades', $contextname);
$eventdata->contexturl = $this->context->get_url();
$eventdata->contexturlname = $contextname;
$eventdata->fullmessageformat = FORMAT_HTML;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
$eventdata->notification = 1;

View File

@ -318,7 +318,7 @@ $string['grademax'] = 'Maximum grade';
$string['grademax_help'] = 'This setting determines the maximum grade when using the value grade type. The maximum grade for an activity-based grade item is set on the activity settings page.';
$string['grademin'] = 'Minimum grade';
$string['grademin_help'] = 'This setting determines the minimum grade when using the value grade type.';
$string['gradenotificationmessage'] = 'You have new feedback on your work for "{$a->name}"';
$string['gradenotificationmessage'] = 'You have new feedback on your work for "{$a}"';
$string['gradenotificationsubject'] = 'Your have been graded';
$string['gradeoutcomeitem'] = 'Grade outcome item';
$string['gradeoutcomes'] = 'Outcomes';