Fausto Busuito
commited on
Commit
·
04033e9
1
Parent(s):
e0c2fd7
Application changes
Browse files
app.py
CHANGED
@@ -24,8 +24,8 @@ def start():
|
|
24 |
session['questions'] = []
|
25 |
session['answers'] = []
|
26 |
session['current_question'] = 0
|
|
|
27 |
session['start_time'] = time.time()
|
28 |
-
session['user_answers'] = []
|
29 |
|
30 |
selected_file = request.form['file']
|
31 |
session['selected_file'] = os.path.splitext(selected_file)[0] # Remove file extension
|
@@ -43,7 +43,7 @@ def quiz():
|
|
43 |
return redirect(url_for('index'))
|
44 |
|
45 |
if 'user_answers' not in session:
|
46 |
-
session['user_answers'] = []
|
47 |
|
48 |
if request.method == 'POST':
|
49 |
action = request.form.get('action')
|
@@ -54,10 +54,10 @@ def quiz():
|
|
54 |
if multiple_selection:
|
55 |
required_answers = 2
|
56 |
if len(answers) == required_answers:
|
57 |
-
session['user_answers']
|
58 |
else:
|
59 |
if answers:
|
60 |
-
session['user_answers']
|
61 |
session['current_question'] += 1
|
62 |
if session['current_question'] >= len(session['questions']):
|
63 |
return redirect(url_for('results'))
|
@@ -73,12 +73,7 @@ def quiz():
|
|
73 |
elapsed_time = time.time() - session['start_time']
|
74 |
elapsed_time_str = time.strftime('%H:%M:%S', time.gmtime(elapsed_time))
|
75 |
|
76 |
-
|
77 |
-
previous_answers = []
|
78 |
-
for q_index, answers in session['user_answers']:
|
79 |
-
if q_index == session['current_question']:
|
80 |
-
previous_answers = answers
|
81 |
-
break
|
82 |
|
83 |
# Debugging statements
|
84 |
print(f"Current question index: {session['current_question']}")
|
|
|
24 |
session['questions'] = []
|
25 |
session['answers'] = []
|
26 |
session['current_question'] = 0
|
27 |
+
session['current_answers'] = []
|
28 |
session['start_time'] = time.time()
|
|
|
29 |
|
30 |
selected_file = request.form['file']
|
31 |
session['selected_file'] = os.path.splitext(selected_file)[0] # Remove file extension
|
|
|
43 |
return redirect(url_for('index'))
|
44 |
|
45 |
if 'user_answers' not in session:
|
46 |
+
session['user_answers'] = [None] * len(session['questions'])
|
47 |
|
48 |
if request.method == 'POST':
|
49 |
action = request.form.get('action')
|
|
|
54 |
if multiple_selection:
|
55 |
required_answers = 2
|
56 |
if len(answers) == required_answers:
|
57 |
+
session['user_answers'][session['current_question']] = answers
|
58 |
else:
|
59 |
if answers:
|
60 |
+
session['user_answers'][session['current_question']] = answers
|
61 |
session['current_question'] += 1
|
62 |
if session['current_question'] >= len(session['questions']):
|
63 |
return redirect(url_for('results'))
|
|
|
73 |
elapsed_time = time.time() - session['start_time']
|
74 |
elapsed_time_str = time.strftime('%H:%M:%S', time.gmtime(elapsed_time))
|
75 |
|
76 |
+
previous_answers = session['user_answers'][session['current_question']] if session['user_answers'][session['current_question']] is not None else []
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
# Debugging statements
|
79 |
print(f"Current question index: {session['current_question']}")
|