From e9a1261423f2c503c3dc9d2c564367b719713ab0 Mon Sep 17 00:00:00 2001
From: BR
Date: Mon, 18 Dec 2023 08:15:20 +0100
Subject: [PATCH] ignor und upload flasK
---
.gitignore | 2 +-
quiz/.env | 3 +++
quiz/csv-read.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++
quiz/quiz-run.conf | 1 +
quiz/quiz.html | 18 ++++++++++++++++++
quiz/quiz.py | 39 ++++++++++++++++++++++++++++++++++++++
robo/csv-read.py | 12 +++++++++---
robo/fragen1.csv | 3 ++-
8 files changed, 120 insertions(+), 5 deletions(-)
create mode 100644 quiz/.env
create mode 100644 quiz/csv-read.py
create mode 120000 quiz/quiz-run.conf
create mode 100644 quiz/quiz.html
create mode 100644 quiz/quiz.py
diff --git a/.gitignore b/.gitignore
index 4e7c99b..f289448 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-quiz/__pycache__/
+quiz/__pycache__
diff --git a/quiz/.env b/quiz/.env
new file mode 100644
index 0000000..f58c968
--- /dev/null
+++ b/quiz/.env
@@ -0,0 +1,3 @@
+FLASK_APP=quiz.py
+FLASK_ENV=development
+FLASK_RUN_PORT=5003
diff --git a/quiz/csv-read.py b/quiz/csv-read.py
new file mode 100644
index 0000000..c5c38b2
--- /dev/null
+++ b/quiz/csv-read.py
@@ -0,0 +1,47 @@
+import csv # CSV handling
+import random
+import os
+
+#file = "C:/Users/bruno/Documents/__CODING__/0-git (Group)/robotik-wise23/robo/fragen1.csv"
+#file = os.getcwd() + "fragen1.csv"
+#file = os.path.join(os.getcwd(), "robo", "fragen1.csv") # Windows Entwicklung
+file = os.path.join(os.getcwd(), "fragen1.csv") # Raspi
+
+#with open(file, newline="", encoding="utf-8") as csvfile: #
+with open(file, newline="", encoding="cp1252") as csvfile: # Code wird als Excel Windows-1252 Input CSV gelesen
+ database = csv.reader(csvfile, delimiter=";") # Validating the "csvfile" into "database" with the delimiter "," (Comma Seperated Values)
+
+ q_a = [] # Empty list for all questions and answers
+
+ for row in database: # alle Zeilen in der Datenbank durchlaufen
+ index = int(row[0]) # Laufende Nummer
+ question = str(row[1]) # Frage (ist der erste Teil)
+ answer = str(row[2]) # Antwort (3. Spalte in der CSV Datenbank)
+ q_a.append({"index": index,"question": question, "answer": answer}) # Eine Liste bauen
+
+# for i in q_a: # For every element in "q_a"
+# print("[" + str(i["index"]) + "] Frage: " + i["question"] + "\n[" + str(i["index"]) + "] Antwort: " + i["answer"] + "\n") # Print "question", "answer" and "index" for current element
+
+
+while True:
+ # Zufällig eine Frage auswählen
+ zufallige_frage = random.choice(q_a)
+ ID = zufallige_frage["index"]
+ frage = zufallige_frage["question"]
+ antwort = zufallige_frage["answer"]
+
+ #print(f"wir sind in {os.getcwd()}")
+
+ # Frage und Antwort ausgeben
+ print(f"Frage:\t({ID})\t{frage}")
+# print(f"Antwort:\t{antwort}")
+
+ # Auf Eingabe warten
+ # input("Drücke Enter für die nächste Frage...")
+ DieAntwort= input(" > ")
+ if ( DieAntwort == antwort ):
+ print ("Sehr gut!")
+ else :
+ print ("Nein! Nochmal. (Setzen, 6) ")
+
+
diff --git a/quiz/quiz-run.conf b/quiz/quiz-run.conf
new file mode 120000
index 0000000..2eea525
--- /dev/null
+++ b/quiz/quiz-run.conf
@@ -0,0 +1 @@
+.env
\ No newline at end of file
diff --git a/quiz/quiz.html b/quiz/quiz.html
new file mode 100644
index 0000000..b785fbf
--- /dev/null
+++ b/quiz/quiz.html
@@ -0,0 +1,18 @@
+
+
+