diff options
author | Lars Krönner | 2020-10-10 18:40:46 +0200 |
---|---|---|
committer | GitHub | 2020-10-10 18:40:46 +0200 |
commit | c2cb67575c8ee623b775d1f5fd28c0a60a9288dc (patch) | |
tree | a9285cef4e2dc3451ed609be2a34bbf21580c35e /db.js | |
parent | 16ebbb932c0b780c11d3e574bc24a515eb095f5f (diff) | |
parent | 1f45ede8253421439e07790375b72a31ceef33ed (diff) |
Merge pull request #4 from marvinborner/profile
Profile
Diffstat (limited to 'db.js')
-rw-r--r-- | db.js | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -40,6 +40,11 @@ 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; @@ -56,6 +61,7 @@ class DB { }); }); + // Motto votes fs.readFile(__dirname + "/mottos.txt", "utf8", (err, data) => { if (err) throw err; @@ -66,6 +72,19 @@ 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) { + const [q, type] = question.split(" - "); + this.query("INSERT INTO profile_questions (question, question_type) VALUE (?, ?)", [q, types.indexOf(type) + 1]); + } + }); + }); + const classes = data.split("--"); const userPasswords = {}; console.log("Generating users"); |