mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 23:19:29 +00:00
Change implementation of Test.dateString
This commit is contained in:
23
lib/Test.js
23
lib/Test.js
@@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-empty-function, getter-return */
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { EmailBuilder, Emailer } = require('./Emailer');
|
const { EmailBuilder, Emailer } = require('./Emailer');
|
||||||
@@ -118,14 +117,18 @@ class Test {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get dateString() {
|
getDateString(long = true) {
|
||||||
return this.date.toLocaleDateString('en-GB', {
|
const options = {
|
||||||
timeZone: 'Europe/London',
|
timeZone: 'Europe/London',
|
||||||
weekday: 'long',
|
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
month: 'numeric',
|
month: 'numeric',
|
||||||
year: 'numeric'
|
year: 'numeric'
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (long)
|
||||||
|
options.weekday = 'long';
|
||||||
|
|
||||||
|
return this.date.toLocaleDateString('en-GB', options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTestResults() {
|
async getTestResults() {
|
||||||
@@ -163,7 +166,7 @@ class Test {
|
|||||||
.setBody(
|
.setBody(
|
||||||
'Your result has been added for ' +
|
'Your result has been added for ' +
|
||||||
`the test "${this.template.name}" that you ` +
|
`the test "${this.template.name}" that you ` +
|
||||||
`took on ${this.dateString}\n\n` +
|
`took on ${this.getDateString()}\n\n` +
|
||||||
`You scored ${mark}/${this.template.maxMark} ` +
|
`You scored ${mark}/${this.template.maxMark} ` +
|
||||||
`(${tr.percentage}%) which is a grade ` +
|
`(${tr.percentage}%) which is a grade ` +
|
||||||
`${tr.grade}`
|
`${tr.grade}`
|
||||||
@@ -197,14 +200,6 @@ class Test {
|
|||||||
return t.id === this.id;
|
return t.id === this.id;
|
||||||
}).length;
|
}).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateAverageScore() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
calculateGradeBoundaries() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Test;
|
module.exports = Test;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class TestResult {
|
|||||||
let body = 'Your result has been changed for ' +
|
let body = 'Your result has been changed for ' +
|
||||||
`the test "${this.test.template.name}" ` +
|
`the test "${this.test.template.name}" ` +
|
||||||
'that you took on ' +
|
'that you took on ' +
|
||||||
`${this.test.dateString}\n\n` +
|
`${this.test.getDateString()}\n\n` +
|
||||||
`Your previous result was ${this.mark}/` +
|
`Your previous result was ${this.mark}/` +
|
||||||
`${this.test.template.maxMark} ` +
|
`${this.test.template.maxMark} ` +
|
||||||
`(${this.percentage}%) which was a grade ` +
|
`(${this.percentage}%) which was a grade ` +
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class TestTemplate {
|
|||||||
.setBody(
|
.setBody(
|
||||||
`New test added for class ${c.name}:\n` +
|
`New test added for class ${c.name}:\n` +
|
||||||
`Test name: ${this.name}\n` +
|
`Test name: ${this.name}\n` +
|
||||||
`Test date: ${t.dateString}\n` +
|
`Test date: ${t.getDateString()}\n` +
|
||||||
`Maximum mark: ${this.maxMark}`
|
`Maximum mark: ${this.maxMark}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ router.get('/reports', async (req, res) => {
|
|||||||
id: t.id,
|
id: t.id,
|
||||||
name: `${t.template.name} - ` +
|
name: `${t.template.name} - ` +
|
||||||
`${t.class.name} - ` +
|
`${t.class.name} - ` +
|
||||||
`${t.dateString}`
|
`${t.getDateString()}`
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user