From 167600b52eb03801bb7051a09dcb0e4f159cfb2a Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Sat, 10 Oct 2020 13:51:42 +0200
Subject: Added note if finished

---
 poll/public/script.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'poll/public')

diff --git a/poll/public/script.js b/poll/public/script.js
index 8c56894..09f8c93 100644
--- a/poll/public/script.js
+++ b/poll/public/script.js
@@ -29,7 +29,19 @@ fetch("/auth/api/list" + (type == "teacher" ? "?class=teacher" : ""))
     .then((response) => appendOption(response));
 
 fetch("/poll/api/get?type=" + type)
-    .then((response) => response.json())
+    .then(async (response) => {
+        let json;
+        try {
+            return await response.json();
+        } catch (e) {
+            document.querySelector("p").innerText = "";
+            question_label.innerText = "Du hast bereits alle Fragen beantwortet.";
+            document.querySelectorAll("label")[1].innerText = "Danke!";
+            document.querySelector("select").style.display = "none";
+            document.querySelector("button").style.display = "none";
+            throw "Oh nein, alle beantwortet!"; // :^)
+        }
+    })
     .then((response) => {
         question_label.innerText = response["question"];
         question_input.setAttribute("value", response["id"]);
-- 
cgit v1.2.3