diff --git a/lib/TestTemplate.js b/lib/TestTemplate.js index 3d90089..7e2bdfb 100644 --- a/lib/TestTemplate.js +++ b/lib/TestTemplate.js @@ -1,6 +1,8 @@ /* eslint-disable no-empty-function, getter-return */ 'use strict'; +const crypto = require('crypto'); + // Import user defined modules const DatabaseConnectionPool = require('./DatabaseConnectionPool'); @@ -86,8 +88,31 @@ class TestTemplate { } - static createTestTemplate() { + static async createTestTemplate(accountId, name, maxMark) { + const a = await new (require('./Account'))(accountId); + const id = crypto.randomUUID(); + + const conn = await new DatabaseConnectionPool(); + + const sql = ` + insert into testTemplate( + testTemplateId, + accountId, + name, + maxMark) + values + (?, ?, ?, ?); + `; + + await conn.runQuery(sql, [ + id, + a.id, + name, + maxMark + ]); + + return new TestTemplate(id); } }