From 897b4173c5cc190805a96aafe5f9258610332e39 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 10 Oct 2020 17:49:51 +0200 Subject: Added vote stats --- admin/public/script.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 admin/public/script.js (limited to 'admin/public/script.js') diff --git a/admin/public/script.js b/admin/public/script.js deleted file mode 100644 index d9fd30e..0000000 --- a/admin/public/script.js +++ /dev/null @@ -1,27 +0,0 @@ -fetch("api/questions") - .then((questions) => questions.json()) - .then((questions) => { - fetch("api/answers") - .then((answers) => answers.json()) - .then((answers) => { - questions.forEach((question) => (question.answers = [])); - answers.forEach((answer) => questions[answer.question_id - 1].answers.push(answer)); - render(questions); - }); - }); - -function render(questions) { - console.log(questions); - const teacher = document.querySelector("ul#teacher"); - const pupil = document.querySelector("ul#pupil"); - questions.forEach((question) => { - const list = question.type === "teacher" ? teacher : pupil; - let answers = ""; - question.answers.forEach((answer) => { - answers += `
  • ${answer.name} ${answer.middlename ? answer.middlename + " " : ""}${answer.surname}: ${ - answer.count - }
  • `; - }); - list.insertAdjacentHTML("beforeend", `
  • ${question.question}
      ${answers}
  • `); - }); -} -- cgit v1.2.3