aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarsVomMars2020-10-07 23:11:08 +0200
committerLarsVomMars2020-10-07 23:11:08 +0200
commit68b06d4cdd24607cee4f016425c4380aea6d556d (patch)
tree620dbbd7f0e58c09dd8f2c11369241d7c684ef3d
parent62a64e6e2379a555fc3f26677bdd497da3a41f1c (diff)
Fixed duplicated entry for teacher polls
-rw-r--r--db.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/db.js b/db.js
index eea9fae..16f2970 100644
--- a/db.js
+++ b/db.js
@@ -35,7 +35,7 @@ class DB {
fs.readFile(__dirname + "/names.csv", "utf8", async (err, data) => {
if (err) throw err;
- await this.query("INSERT INTO types (name) VALUES ('teacher'), ('pupil')");
+ await this.query("INSERT INTO types (name) VALUES ('pupil'), ('teacher')");
await this.query(
"INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), ('TGTM13.1'), ('TGI13.1'), ('TGI13.2'), ('teacher')"
);
@@ -43,10 +43,13 @@ class DB {
fs.readFile(__dirname + "/poll.txt", "utf8", (err, data) => {
if (err) throw err;
- const questions = data.split("\n");
- questions.forEach((question) => {
- if (question.length > 0)
- this.query("INSERT INTO ranking_questions (question, type_id) VALUE (?,?)", [question, 2]);
+ const parts = data.split("--");
+ parts.forEach((part, i) => {
+ const questions = part.split("\n");
+ questions.forEach((question) => {
+ if (question.length > 0)
+ this.query("INSERT INTO ranking_questions (question, type_id) VALUE (?,?)", [question, i+1]);
+ });
});
});