mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 18:19:25 +00:00
Notify when a test result is changed
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const crypto = require('crypto');
|
||||
|
||||
const { EmailBuilder, Emailer } = require('./Emailer');
|
||||
const MySQLDate = require('./MySQLDate');
|
||||
|
||||
class TestResult {
|
||||
@@ -97,7 +98,29 @@ class TestResult {
|
||||
this.id
|
||||
]);
|
||||
|
||||
let body = 'Your result has been changed for ' +
|
||||
`the test "${this.test.template.name}" ` +
|
||||
'that you took on ' +
|
||||
`${this.test.dateString}\n\n` +
|
||||
`Your previous result was ${this.mark}/` +
|
||||
`${this.test.template.maxMark} ` +
|
||||
`(${this.percentage}%) which was a grade ` +
|
||||
`${this.grade}\n\n`;
|
||||
|
||||
this.mark = mark;
|
||||
|
||||
body += `Your new result is ${this.mark}/` +
|
||||
`${this.test.template.maxMark} ` +
|
||||
`(${this.percentage}%) which is a grade ` +
|
||||
`${this.grade}`;
|
||||
|
||||
const email = new EmailBuilder()
|
||||
.addTo([ this.student.getEmail() ])
|
||||
.setSubject('Stratos - Test result changed')
|
||||
.setBody(body);
|
||||
|
||||
const emailer = new Emailer();
|
||||
await emailer.sendEmail(email);
|
||||
}
|
||||
|
||||
get percentage() {
|
||||
|
||||
Reference in New Issue
Block a user