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_DEBUG=True
|
||||||
FLASK_RUN_HOST=0.0.0.0
|
FLASK_RUN_HOST=0.0.0.0
|
||||||
#FLASK_RUN_HOST=127.0.0.1
|
#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)
|
random.shuffle(fragen_liste)
|
||||||
|
|
||||||
current_index = 0
|
current_index = 0
|
||||||
|
correct_sum = 0
|
||||||
last_correct = None
|
last_correct = None
|
||||||
|
max_correct_sum = 5
|
||||||
|
|
||||||
debugtxt=""
|
debugtxt=""
|
||||||
|
|
||||||
@@ -34,13 +36,16 @@ debugtxt=""
|
|||||||
|
|
||||||
def quiz():
|
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'])
|
@app.route('/submit_quiz', methods=['POST'])
|
||||||
def submit_quiz():
|
def submit_quiz():
|
||||||
global current_index
|
global current_index
|
||||||
global fragen_liste
|
global fragen_liste
|
||||||
global debugtxt
|
global debugtxt
|
||||||
|
global correct_sum
|
||||||
|
|
||||||
# Überprüfen Sie die Antwort und aktualisieren Sie current_index
|
# Überprüfen Sie die Antwort und aktualisieren Sie current_index
|
||||||
user_answer = request.form.get('answer')
|
user_answer = request.form.get('answer')
|
||||||
@@ -48,12 +53,18 @@ def submit_quiz():
|
|||||||
|
|
||||||
if user_answer == correct_answer:
|
if user_answer == correct_answer:
|
||||||
last_correct = True
|
last_correct = True
|
||||||
|
correct_sum += 1
|
||||||
debugtxt = correct_answer + " ist richtig! passt zu deiner Angabe: " + user_answer
|
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:
|
else:
|
||||||
last_correct = False
|
last_correct = False
|
||||||
# debugtxt += "<!-- user_answer = " + user_answer + " -->\n"
|
# debugtxt += "<!-- user_answer = " + user_answer + " -->\n"
|
||||||
# debugtxt += "<!-- correct_anwer = " + correct_answer + " -->\n"
|
# debugtxt += "<!-- correct_anwer = " + correct_answer + " -->\n"
|
||||||
debugtxt = "falsch: Richtig wäre " +correct_answer + " / und nicht: " + user_answer
|
debugtxt = "falsch: Richtig wäre " +correct_answer + " / und nicht: " + user_answer
|
||||||
|
correct_sum = 0
|
||||||
|
|
||||||
current_index += 1
|
current_index += 1
|
||||||
|
|
||||||
# Überprüfen, ob wir alle Fragen beantwortet haben
|
# Überprüfen, ob wir alle Fragen beantwortet haben
|
||||||
@@ -62,5 +73,13 @@ def submit_quiz():
|
|||||||
random.shuffle(fragen_liste)
|
random.shuffle(fragen_liste)
|
||||||
current_index=0
|
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
|
# Leiten Sie den Benutzer zur nächsten Frage weiter
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<!-- <link rel="stylesheet" href="../.data/style/forms.css">
|
<title>Hausaufgaben-Robo</title>
|
||||||
<link rel="stylesheet" href="../.data/style/main.css"> -->
|
|
||||||
<title>Login</title>
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: 'Arial', sans-serif;
|
font-family: 'Arial', sans-serif;
|
||||||
@@ -106,19 +104,21 @@
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<form method="POST" action="/submit_quiz">
|
<form method="POST" action="/submit_quiz">
|
||||||
<p name="question">{{ frage.index }}. {{ frage.question }}</p>
|
<p name="question">{{ frage.index }}. {{ frage.question }}</p>
|
||||||
<input type="text" name="answer" placeholder="Antwort eingeben..." required>
|
<input type="text" name="answer" placeholder="Antwort eingeben..." required>
|
||||||
<input type="submit" value="Quiz abschicken">
|
<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 />
|
<br />
|
||||||
|
{% if debugtxt %}
|
||||||
<p class="debug">{{debugtxt}}</p>
|
<p class="debug">{{debugtxt}}</p>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user