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

Added TestResult.create

This commit is contained in:
2022-04-18 20:17:29 +00:00
parent 5def59357c
commit 326dd35b44

View File

@@ -1,5 +1,7 @@
'use strict'; 'use strict';
const crypto = require('crypto');
const MySQLDate = require('./MySQLDate'); const MySQLDate = require('./MySQLDate');
class TestResult { class TestResult {
@@ -110,6 +112,34 @@ class TestResult {
//TODO get actual grades //TODO get actual grades
return 'C'; return 'C';
} }
static async create(conn, testId, accountId, studentId, mark) {
const sql = `
insert into testResult
(
testResultId,
studentId,
testId,
accountId,
mark,
time
)
values (?, ?, ?, ?, ?, ?);
`;
const id = await crypto.randomUUID();
await conn.runQuery(sql, [
id,
studentId,
testId,
accountId,
mark,
new MySQLDate()
]);
return new TestResult(conn, id);
}
} }
module.exports = TestResult; module.exports = TestResult;