1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 20:19:30 +00:00

Notify when a test result is changed

This commit is contained in:
2022-04-21 15:48:42 +00:00
parent 72b8c5adef
commit 483ed5d46f

View File

@@ -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() {