Sina Media Lab
commited on
Commit
·
b003425
1
Parent(s):
bbafe5e
Updates
Browse files
app.py
CHANGED
@@ -83,32 +83,17 @@ if module_name:
|
|
83 |
st.title(title)
|
84 |
st.write(description)
|
85 |
|
86 |
-
#
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
st.session_state.correct_answer = question_data[3]
|
98 |
-
st.session_state.explanation = question_data[4]
|
99 |
-
with col_nav_2:
|
100 |
-
if st.session_state.submitted:
|
101 |
-
if st.button("➡️ Next"):
|
102 |
-
st.session_state.current_question = None
|
103 |
-
with col_pdf:
|
104 |
-
if st.session_state.question_count > 0:
|
105 |
-
pdf = generate_pdf_report()
|
106 |
-
st.download_button(
|
107 |
-
label="Download PDF Report 📄",
|
108 |
-
data=pdf,
|
109 |
-
file_name="quiz_report.pdf",
|
110 |
-
mime="application/pdf"
|
111 |
-
)
|
112 |
|
113 |
if st.session_state.current_question is None or st.session_state.submitted:
|
114 |
st.session_state.current_question, st.session_state.options, st.session_state.correct_answer, st.session_state.explanation = generate_question()
|
@@ -120,7 +105,7 @@ if module_name:
|
|
120 |
st.write(f"**Correct Answers:** {st.session_state.correct_count}/{st.session_state.question_count} ({correct_percentage:.2f}%)")
|
121 |
|
122 |
st.write(f"**Question {st.session_state.question_count + 1}:** {st.session_state.current_question}")
|
123 |
-
st.session_state.selected_answer = st.radio("Choose an answer:", st.session_state.options)
|
124 |
|
125 |
if st.button("Submit"):
|
126 |
st.session_state.submitted = True
|
@@ -149,5 +134,20 @@ if module_name:
|
|
149 |
unsafe_allow_html=True
|
150 |
)
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
except ModuleNotFoundError:
|
153 |
st.error(f"The module '{module_name}' was not found. Please select another module.")
|
|
|
83 |
st.title(title)
|
84 |
st.write(description)
|
85 |
|
86 |
+
# Show the "Prev" button after the first question has been answered
|
87 |
+
if st.session_state.question_count > 1:
|
88 |
+
if st.button("⬅️ Prev"):
|
89 |
+
st.session_state.question_count -= 1
|
90 |
+
st.session_state.submitted = False
|
91 |
+
question_data = st.session_state.question_queue[st.session_state.question_count - 1]
|
92 |
+
st.session_state.current_question = question_data[0]
|
93 |
+
st.session_state.options = question_data[1]
|
94 |
+
st.session_state.selected_answer = question_data[2]
|
95 |
+
st.session_state.correct_answer = question_data[3]
|
96 |
+
st.session_state.explanation = question_data[4]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
if st.session_state.current_question is None or st.session_state.submitted:
|
99 |
st.session_state.current_question, st.session_state.options, st.session_state.correct_answer, st.session_state.explanation = generate_question()
|
|
|
105 |
st.write(f"**Correct Answers:** {st.session_state.correct_count}/{st.session_state.question_count} ({correct_percentage:.2f}%)")
|
106 |
|
107 |
st.write(f"**Question {st.session_state.question_count + 1}:** {st.session_state.current_question}")
|
108 |
+
st.session_state.selected_answer = st.radio("Choose an answer:", st.session_state.options, key=st.session_state.question_count)
|
109 |
|
110 |
if st.button("Submit"):
|
111 |
st.session_state.submitted = True
|
|
|
134 |
unsafe_allow_html=True
|
135 |
)
|
136 |
|
137 |
+
# Show the "Next" button after the question has been answered
|
138 |
+
if st.session_state.submitted:
|
139 |
+
if st.button("➡️ Next"):
|
140 |
+
st.session_state.current_question = None
|
141 |
+
|
142 |
+
# Display the "Download PDF Report" button after at least one question has been answered
|
143 |
+
if st.session_state.question_count > 0:
|
144 |
+
pdf = generate_pdf_report()
|
145 |
+
st.download_button(
|
146 |
+
label="Download PDF Report 📄",
|
147 |
+
data=pdf,
|
148 |
+
file_name="quiz_report.pdf",
|
149 |
+
mime="application/pdf"
|
150 |
+
)
|
151 |
+
|
152 |
except ModuleNotFoundError:
|
153 |
st.error(f"The module '{module_name}' was not found. Please select another module.")
|