Skip to content

Commit 6b02b38

Browse files
committed
Docs for MDL-84387 enhancement to mod_assign messages
1 parent 8b6b54c commit 6b02b38

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/apis/plugintypes/assign/submission.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,32 @@ public function view($submission) {
363363

364364
The view function is called to display the entire submission to both markers and students. In this case it uses the helper function in the assignment class to write the list of files.
365365

366+
#### submission_summary_for_email()
367+
368+
```php
369+
#[\Override]
370+
public function submission_summary_for_messages(stdClass $submission): array {
371+
global $PAGE;
372+
373+
$onlinetextsubmission = $this->get_onlinetext_submission($submission->id);
374+
if (!$onlinetextsubmission || !$onlinetextsubmission->onlinetext) {
375+
return ['', ''];
376+
}
377+
378+
$renderer = $PAGE->get_renderer('mod_assign');
379+
$templatecontext = ['wordcount' => count_words($onlinetextsubmission->onlinetext)];
380+
return [
381+
// Mustache strips off all trailing whitespace, but we want a newline at the end.
382+
$renderer->render_from_template(
383+
'assignsubmission_onlinetext/notification_text', $templatecontext) . "\n",
384+
$renderer->render_from_template(
385+
'assignsubmission_onlinetext/notification_html', $templatecontext),
386+
];
387+
}
388+
```
389+
390+
This method produces a summary of what was submitted, in a form suitable to include in messages (for example, the 'You have submitted' confirmation). Moodle messages can be plain text or HTML, so you need to prepare both. It is recommended to use templates so themes can override it if they want to. As you produce your output, think about the fact that multiple Submission plugins may be in use at the same time, in which case your summary will appear alongside other summaries.
391+
366392
#### can_upgrade()
367393

368394
```php

0 commit comments

Comments
 (0)