diff options
Diffstat (limited to 'db.js')
-rw-r--r-- | db.js | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -40,6 +40,10 @@ class DB { "INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), ('TGTM13.1'), ('TGI13.1'), ('TGI13.2'), ('teacher')", ); + + const types = ["number", "file", "date", "text", "color"]; + await this.query("INSERT INTO profile_input_types (type) VALUES (?), (?), (?), (?), (?)", types); + // User polls fs.readFile(__dirname + "/poll.txt", "utf8", (err, data) => { if (err) throw err; @@ -68,21 +72,16 @@ class DB { }); }); + // User profile fs.readFile(__dirname + "/profile.txt", "utf8", (err, data) => { if (err) throw err; const questions = data.split("\n"); questions.forEach((question) => { - if (question) this.query("INSERT INTO profile_questions (question) VALUE (?)", [question]); - }); - }); - - fs.readFile(__dirname + "/profile.txt", "utf8", (err, data) => { - if (err) throw err; - - const questions = data.split("\n"); - questions.forEach((question) => { - if (question) this.query("INSERT INTO profile_questions (question) VALUE (?)", [question]); + if (question) { + const [q, type] = question.split(" - "); + this.query("INSERT INTO profile_questions (question, question_type) VALUE (?, ?)", [q, types.indexOf(type) + 1]); + } }); }); |