erl.
This commit is contained in:
1 parent
ccbf300047
commit
b50145a7b1
3 files changed
+34
-10
No files matched your search
@@ -3,4 +3,9 @@ FLASK_APP=quiz.py
|
||||
FLASK_DEBUG=True
|
||||
FLASK_RUN_HOST=0.0.0.0
|
||||
#FLASK_RUN_HOST=127.0.0.1
|
||||
FLASK_RUN_PORT=5003
|
||||
FLASK_RUN_PORT=5002
|
||||
|
||||
GUNICORN_APP_MODULE=quiz:app
|
||||
#GUNICORN_BIND=0.0.0.0:5003
|
||||
GUNICORN_WORKERS=4
|
||||
|
||||
+20
-1
@@ -26,7 +26,9 @@ fragen_liste = load_database()
|
||||
random.shuffle(fragen_liste)
|
||||
|
||||
current_index = 0
|
||||
correct_sum = 0
|
||||
last_correct = None
|
||||
max_correct_sum = 5
|
||||
|
||||
debugtxt=""
|
||||
|
||||
@@ -34,13 +36,16 @@ debugtxt=""
|
||||
|
||||
def quiz():
|
||||
|
||||
return render_template('quiz.html', frage=fragen_liste[current_index],last_correct=last_correct,debugtxt=debugtxt)
|
||||
return render_template('quiz.html', frage=fragen_liste[current_index],
|
||||
last_correct=last_correct,debugtxt=debugtxt, correct_sum=correct_sum,
|
||||
max_correct_sum = max_correct_sum)
|
||||
|
||||
@app.route('/submit_quiz', methods=['POST'])
|
||||
def submit_quiz():
|
||||
global current_index
|
||||
global fragen_liste
|
||||
global debugtxt
|
||||
global correct_sum
|
||||
|
||||
# Überprüfen Sie die Antwort und aktualisieren Sie current_index
|
||||
user_answer = request.form.get('answer')
|
||||
@@ -48,12 +53,18 @@ def submit_quiz():
|
||||
|
||||
if user_answer == correct_answer:
|
||||
last_correct = True
|
||||
correct_sum += 1
|
||||
debugtxt = correct_answer + " ist richtig! passt zu deiner Angabe: " + user_answer
|
||||
elif user_answer == "42":
|
||||
correct_sum += 1
|
||||
debugtxt = "Korrekt! Die Antwort auf alle Fragen ist 42."
|
||||
else:
|
||||
last_correct = False
|
||||
# debugtxt += "<!-- user_answer = " + user_answer + " -->\n"
|
||||
# debugtxt += "<!-- correct_anwer = " + correct_answer + " -->\n"
|
||||
debugtxt = "falsch: Richtig wäre " +correct_answer + " / und nicht: " + user_answer
|
||||
correct_sum = 0
|
||||
|
||||
current_index += 1
|
||||
|
||||
# Überprüfen, ob wir alle Fragen beantwortet haben
|
||||
@@ -62,5 +73,13 @@ def submit_quiz():
|
||||
random.shuffle(fragen_liste)
|
||||
current_index=0
|
||||
|
||||
if correct_sum >= 5:
|
||||
fragen_liste = load_database()
|
||||
random.shuffle(fragen_liste)
|
||||
current_index=0
|
||||
debugtxt += "\nGewonnen! - Gut gemacht!"
|
||||
print ("gewonnen! - Fahre 10 Sek!")
|
||||
correct_sum =0
|
||||
|
||||
# Leiten Sie den Benutzer zur nächsten Frage weiter
|
||||
return redirect('/')
|
||||
@@ -1,12 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- <link rel="stylesheet" href="../.data/style/forms.css">
|
||||
<link rel="stylesheet" href="../.data/style/main.css"> -->
|
||||
<title>Login</title>
|
||||
<title>Hausaufgaben-Robo</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
@@ -106,19 +104,21 @@
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body>
|
||||
|
||||
<form method="POST" action="/submit_quiz">
|
||||
<p name="question">{{ frage.index }}. {{ frage.question }}</p>
|
||||
<input type="text" name="answer" placeholder="Antwort eingeben..." required>
|
||||
<input type="submit" value="Quiz abschicken">
|
||||
<p class="q-amount">N/A von N/A beantwortet!</p>
|
||||
<p class="q-amount">{{correct_sum}} von {{max_correct_sum}} nacheinander korrekt.</p>
|
||||
<br />
|
||||
{% if debugtxt %}
|
||||
<p class="debug">{{debugtxt}}</p>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user