mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 20:19:30 +00:00
Added TestResult.create
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user