mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 17:59:25 +00:00
Added TestResult.create
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
|
||||
const MySQLDate = require('./MySQLDate');
|
||||
|
||||
class TestResult {
|
||||
@@ -110,6 +112,34 @@ class TestResult {
|
||||
//TODO get actual grades
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user