Fausto Busuito
commited on
Commit
•
3a7f5ab
1
Parent(s):
d77ef80
Application changes
Browse files- app.py +3 -2
- templates/quiz.html +4 -2
app.py
CHANGED
@@ -27,7 +27,7 @@ def start():
|
|
27 |
session['current_question'] = 0
|
28 |
|
29 |
selected_file = request.form['file']
|
30 |
-
session['selected_file'] = selected_file
|
31 |
file_path = os.path.join(QUESTIONS_FOLDER, selected_file)
|
32 |
with open(file_path, 'r') as file:
|
33 |
questions = json.load(file)
|
@@ -61,7 +61,8 @@ def quiz():
|
|
61 |
return render_template('quiz.html', question=session['questions'][session['current_question']],
|
62 |
question_number=session['current_question'] + 1,
|
63 |
total_questions=len(session['questions']),
|
64 |
-
selected_file=session['selected_file']
|
|
|
65 |
|
66 |
@app.route('/results')
|
67 |
def results():
|
|
|
27 |
session['current_question'] = 0
|
28 |
|
29 |
selected_file = request.form['file']
|
30 |
+
session['selected_file'] = os.path.splitext(selected_file)[0] # Remove file extension
|
31 |
file_path = os.path.join(QUESTIONS_FOLDER, selected_file)
|
32 |
with open(file_path, 'r') as file:
|
33 |
questions = json.load(file)
|
|
|
61 |
return render_template('quiz.html', question=session['questions'][session['current_question']],
|
62 |
question_number=session['current_question'] + 1,
|
63 |
total_questions=len(session['questions']),
|
64 |
+
selected_file=session['selected_file'],
|
65 |
+
show_previous=session['current_question'] > 0)
|
66 |
|
67 |
@app.route('/results')
|
68 |
def results():
|
templates/quiz.html
CHANGED
@@ -11,11 +11,13 @@
|
|
11 |
<p>{{ question.question }}</p>
|
12 |
<form action="{{ url_for('quiz') }}" method="post">
|
13 |
{% for option in question.options %}
|
14 |
-
<input type="radio" id="{{ loop.index }}" name="answer" value="{{ loop.index }}"
|
15 |
<label for="{{ loop.index }}">{{ option }}</label><br>
|
16 |
{% endfor %}
|
17 |
<br>
|
18 |
-
|
|
|
|
|
19 |
<button type="submit" name="action" value="next">Next</button>
|
20 |
<button type="submit" name="action" value="end">End Session</button>
|
21 |
</form>
|
|
|
11 |
<p>{{ question.question }}</p>
|
12 |
<form action="{{ url_for('quiz') }}" method="post">
|
13 |
{% for option in question.options %}
|
14 |
+
<input type="radio" id="{{ loop.index }}" name="answer" value="{{ loop.index }}">
|
15 |
<label for="{{ loop.index }}">{{ option }}</label><br>
|
16 |
{% endfor %}
|
17 |
<br>
|
18 |
+
{% if show_previous %}
|
19 |
+
<button type="submit" name="action" value="previous">Previous</button>
|
20 |
+
{% endif %}
|
21 |
<button type="submit" name="action" value="next">Next</button>
|
22 |
<button type="submit" name="action" value="end">End Session</button>
|
23 |
</form>
|