Sina Media Lab commited on
Commit
d8bd1c9
·
1 Parent(s): 0c6844a
Files changed (1) hide show
  1. app.py +8 -27
app.py CHANGED
@@ -108,11 +108,9 @@ 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
- 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,7 +147,7 @@ with col1:
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,26 +160,9 @@ with col3:
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,11 +187,11 @@ if selected_answer is not None and not current_question['answered']:
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']}")
 
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" and st.session_state.current_index < len(st.session_state.questions) - 1:
112
  st.session_state.current_index += 1
113
+ st.session_state.answered = True
 
 
114
 
115
  # Load all modules dynamically
116
  modules = load_modules()
 
147
  if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
148
  navigate_question("prev")
149
  with col2:
150
+ if st.button("➡️ Next", disabled=st.session_state.current_index >= len(st.session_state.questions) - 1):
151
  navigate_question("next")
152
  with col3:
153
  if len(st.session_state.questions) > 0:
 
160
  mime="application/pdf"
161
  )
162
 
163
+ st.write(current_question["question"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  # Show correct/incorrect feedback immediately
188
  for option in current_question['options']:
189
  if option == current_question['correct_answer']:
190
+ st.markdown(f"<span style='color:green;'>{option} ✅</span>", unsafe_allow_html=True)
191
  elif option == current_question['selected']:
192
+ st.markdown(f"<span style='color:red;'>{option} ❌</span>", unsafe_allow_html=True)
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']}")