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

Implemented Test.getAverageScore and Percentage

This commit is contained in:
2022-04-22 02:33:26 +00:00
parent ec6305086e
commit c0cde8a08a

View File

@@ -151,6 +151,19 @@ class Test {
})); }));
} }
async getAverageScore() {
const trs = await this.getTestResults();
return trs.reduce((a, b) => a + b.mark, 0) /
(trs.length || 1);
}
async getAveragePercentage() {
return await this.getAverageScore() /
this.template.maxMark *
100;
}
async addResult(accountId, studentId, mark) { async addResult(accountId, studentId, mark) {
const tr = await TestResult.create( const tr = await TestResult.create(
this.#conn, this.#conn,