diff --git a/lib/Student.js b/lib/Student.js index ea7a920..83b75d6 100644 --- a/lib/Student.js +++ b/lib/Student.js @@ -8,12 +8,26 @@ class Student extends User { super(conn, id, 'student'); } - get classes() { + async getTestResults() { + const sql = ` + select + testResultId + from + testResult + where + studentId = ? + order by + time desc; + `; - } - - get parents() { + const records = await this._conn.runQuery(sql, [ this.id ]); + return Promise.all(records.map(r => { + return new (require('./TestResult'))( + this._conn, + r.testResultId + ); + })); } static async createStudent(conn, fname, oname, lname, email, password) {