aboutsummaryrefslogtreecommitdiff
path: root/admin/public
diff options
context:
space:
mode:
authorMarvin Borner2020-10-10 17:10:01 +0200
committerMarvin Borner2020-10-10 17:10:01 +0200
commitb2d9cf884f2aff3445d6619939186e48a683e5a9 (patch)
tree1f9c56a4a65c76e7fbb9b0d5916d61d2af391ac0 /admin/public
parent72f5731adeebf8d76c5c2dcc266f600ba57812d8 (diff)
Welp, formatting :D
Diffstat (limited to 'admin/public')
-rw-r--r--admin/public/index.html14
-rw-r--r--admin/public/script.js45
2 files changed, 32 insertions, 27 deletions
diff --git a/admin/public/index.html b/admin/public/index.html
index cf5d286..a611291 100644
--- a/admin/public/index.html
+++ b/admin/public/index.html
@@ -19,14 +19,14 @@
<a href="/auth/api/logout" class="pure-menu-item pure-menu-link">Logout</a>
</div>
- <!-- TODO: Class-based stats (easily solveable in frontend) -->
+ <!-- TODO: Class-based stats (easily solveable in frontend) -->
<div class="card">
- Welche/r Schüler/in...
- <ul id="pupil"></ul>
- Welche/r Lehrer/in...
- <ul id="teacher"></ul>
- </div>
+ Welche/r Schüler/in...
+ <ul id="pupil"></ul>
+ Welche/r Lehrer/in...
+ <ul id="teacher"></ul>
+ </div>
- <script src="script.js"></script>
+ <script src="script.js"></script>
</body>
</html>
diff --git a/admin/public/script.js b/admin/public/script.js
index ff6fa2b..d9fd30e 100644
--- a/admin/public/script.js
+++ b/admin/public/script.js
@@ -1,22 +1,27 @@
-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);
- });
-});
+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 += `<li>${answer.name} ${answer.middlename ? answer.middlename + " " : ""}${answer.surname}: ${answer.count}</li>`
- });
- list.insertAdjacentHTML("beforeend", `<li>${question.question}<br><ol>${answers}</ol></li>`);
- });
+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 += `<li>${answer.name} ${answer.middlename ? answer.middlename + " " : ""}${answer.surname}: ${
+ answer.count
+ }</li>`;
+ });
+ list.insertAdjacentHTML("beforeend", `<li>${question.question}<br><ol>${answers}</ol></li>`);
+ });
}