Sina Media Lab
commited on
Commit
·
976f4d1
1
Parent(s):
72b1ec2
Updates
Browse files
app.py
CHANGED
@@ -29,6 +29,8 @@ if 'submit_click_count' not in st.session_state:
|
|
29 |
st.session_state.submit_click_count = 0
|
30 |
if 'show_next_button' not in st.session_state:
|
31 |
st.session_state.show_next_button = False
|
|
|
|
|
32 |
|
33 |
def reset_pdf_cache():
|
34 |
st.session_state.pdf_data = None
|
@@ -139,6 +141,7 @@ if selected_module != st.session_state.current_module:
|
|
139 |
st.session_state.answered = False
|
140 |
st.session_state.submit_click_count = 0 # Reset the submit click count
|
141 |
st.session_state.show_next_button = False # Reset the next button visibility
|
|
|
142 |
|
143 |
# Load the current module's question
|
144 |
current_question = st.session_state.questions[st.session_state.current_index]
|
@@ -229,17 +232,21 @@ if not st.session_state.show_next_button:
|
|
229 |
|
230 |
# Replace question and Submit/Next with Next button
|
231 |
st.session_state.show_next_button = True
|
232 |
-
st.experimental_rerun()
|
233 |
|
234 |
# Show the Next button to generate a new question
|
235 |
if st.session_state.show_next_button:
|
236 |
if st.button("Next"):
|
237 |
-
|
238 |
-
new_question = generate_new_question(selected_module, modules[selected_module])
|
239 |
-
st.session_state.questions.append(new_question)
|
240 |
-
st.session_state.current_index = len(st.session_state.questions) - 1
|
241 |
-
st.session_state.answered = False
|
242 |
-
st.session_state.submit_click_count = 0 # Reset the click count
|
243 |
-
st.session_state.selected_answer = None # Reset the selected answer
|
244 |
st.session_state.show_next_button = False # Hide the Next button
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
st.session_state.submit_click_count = 0
|
30 |
if 'show_next_button' not in st.session_state:
|
31 |
st.session_state.show_next_button = False
|
32 |
+
if 'show_report' not in st.session_state:
|
33 |
+
st.session_state.show_report = False
|
34 |
|
35 |
def reset_pdf_cache():
|
36 |
st.session_state.pdf_data = None
|
|
|
141 |
st.session_state.answered = False
|
142 |
st.session_state.submit_click_count = 0 # Reset the submit click count
|
143 |
st.session_state.show_next_button = False # Reset the next button visibility
|
144 |
+
st.session_state.show_report = False # Reset the report visibility
|
145 |
|
146 |
# Load the current module's question
|
147 |
current_question = st.session_state.questions[st.session_state.current_index]
|
|
|
232 |
|
233 |
# Replace question and Submit/Next with Next button
|
234 |
st.session_state.show_next_button = True
|
|
|
235 |
|
236 |
# Show the Next button to generate a new question
|
237 |
if st.session_state.show_next_button:
|
238 |
if st.button("Next"):
|
239 |
+
st.session_state.show_report = True
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
st.session_state.show_next_button = False # Hide the Next button
|
241 |
+
|
242 |
+
# Show the report after clicking Next
|
243 |
+
if st.session_state.show_report:
|
244 |
+
st.write("### Report")
|
245 |
+
for module in modules:
|
246 |
+
total_questions = st.session_state.module_question_count.get(module, 0)
|
247 |
+
correct_answers = st.session_state.module_correct_count.get(module, 0)
|
248 |
+
if total_questions > 0:
|
249 |
+
percentage = (correct_answers / total_questions) * 100
|
250 |
+
st.write(f"**{modules[module]['title']}**: {correct_answers}/{total_questions} correct ({percentage:.2f}%)")
|
251 |
+
else:
|
252 |
+
st.write(f"**{modules[module]['title']}**: No questions answered yet.")
|