Sina Media Lab
commited on
Commit
·
0c6844a
1
Parent(s):
1596f6d
Updates
Browse files
app.py
CHANGED
@@ -108,9 +108,11 @@ def navigate_question(direction):
|
|
108 |
if direction == "prev" and st.session_state.current_index > 0:
|
109 |
st.session_state.current_index -= 1
|
110 |
st.session_state.answered = True
|
111 |
-
elif direction == "next"
|
112 |
st.session_state.current_index += 1
|
113 |
-
st.session_state.
|
|
|
|
|
114 |
|
115 |
# Load all modules dynamically
|
116 |
modules = load_modules()
|
@@ -147,7 +149,7 @@ with col1:
|
|
147 |
if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
|
148 |
navigate_question("prev")
|
149 |
with col2:
|
150 |
-
if st.button("➡️ Next"
|
151 |
navigate_question("next")
|
152 |
with col3:
|
153 |
if len(st.session_state.questions) > 0:
|
@@ -160,9 +162,26 @@ with col3:
|
|
160 |
mime="application/pdf"
|
161 |
)
|
162 |
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
# Handle the selection of an option and check the answer immediately
|
166 |
selected_answer = st.radio(
|
167 |
"Choose an answer:",
|
168 |
options=current_question['options'],
|
@@ -187,11 +206,11 @@ if selected_answer is not None and not current_question['answered']:
|
|
187 |
# Show correct/incorrect feedback immediately
|
188 |
for option in current_question['options']:
|
189 |
if option == current_question['correct_answer']:
|
190 |
-
st.markdown(f"<
|
191 |
elif option == current_question['selected']:
|
192 |
-
st.markdown(f"<
|
193 |
else:
|
194 |
-
st.markdown(f"{option}")
|
195 |
|
196 |
# Show explanation and step-by-step solution with improved visuals
|
197 |
st.write(f"**Explanation:** {current_question['explanation']}")
|
|
|
108 |
if direction == "prev" and st.session_state.current_index > 0:
|
109 |
st.session_state.current_index -= 1
|
110 |
st.session_state.answered = True
|
111 |
+
elif direction == "next":
|
112 |
st.session_state.current_index += 1
|
113 |
+
if st.session_state.current_index >= len(st.session_state.questions):
|
114 |
+
st.session_state.questions.append(generate_new_question(st.session_state.current_module, modules[st.session_state.current_module]))
|
115 |
+
st.session_state.answered = False
|
116 |
|
117 |
# Load all modules dynamically
|
118 |
modules = load_modules()
|
|
|
149 |
if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
|
150 |
navigate_question("prev")
|
151 |
with col2:
|
152 |
+
if st.button("➡️ Next"):
|
153 |
navigate_question("next")
|
154 |
with col3:
|
155 |
if len(st.session_state.questions) > 0:
|
|
|
162 |
mime="application/pdf"
|
163 |
)
|
164 |
|
165 |
+
# Apply styles with borders and gray background
|
166 |
+
st.markdown("""
|
167 |
+
<style>
|
168 |
+
.question-box {
|
169 |
+
border: 2px solid #ccc;
|
170 |
+
padding: 15px;
|
171 |
+
background-color: #f9f9f9;
|
172 |
+
margin-bottom: 20px;
|
173 |
+
}
|
174 |
+
.option-box {
|
175 |
+
border: 1px solid #ccc;
|
176 |
+
padding: 10px;
|
177 |
+
background-color: #f0f0f0;
|
178 |
+
margin-bottom: 10px;
|
179 |
+
}
|
180 |
+
</style>
|
181 |
+
""", unsafe_allow_html=True)
|
182 |
+
|
183 |
+
st.markdown(f"<div class='question-box'><strong>Q:</strong> {current_question['question']}</div>", unsafe_allow_html=True)
|
184 |
|
|
|
185 |
selected_answer = st.radio(
|
186 |
"Choose an answer:",
|
187 |
options=current_question['options'],
|
|
|
206 |
# Show correct/incorrect feedback immediately
|
207 |
for option in current_question['options']:
|
208 |
if option == current_question['correct_answer']:
|
209 |
+
st.markdown(f"<div class='option-box' style='color:green;'>{option} ✅</div>", unsafe_allow_html=True)
|
210 |
elif option == current_question['selected']:
|
211 |
+
st.markdown(f"<div class='option-box' style='color:red;'>{option} ❌</div>", unsafe_allow_html=True)
|
212 |
else:
|
213 |
+
st.markdown(f"<div class='option-box'>{option}</div>", unsafe_allow_html=True)
|
214 |
|
215 |
# Show explanation and step-by-step solution with improved visuals
|
216 |
st.write(f"**Explanation:** {current_question['explanation']}")
|