Sina Media Lab commited on
Commit
8dd36e6
·
1 Parent(s): 10939a2
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -25,6 +25,8 @@ if 'selected_answer' not in st.session_state:
25
  st.session_state.selected_answer = None
26
  if 'answered' not in st.session_state:
27
  st.session_state.answered = False
 
 
28
 
29
  def reset_pdf_cache():
30
  st.session_state.pdf_data = None
@@ -70,7 +72,7 @@ def generate_pdf_report():
70
  pdf.multi_cell(0, 10, f"Explanation: {explanation}")
71
  pdf.ln(5)
72
  pdf.multi_cell(0, 10, "Step-by-Step Solution:")
73
- for step in step_by_step_solution:
74
  pdf.multi_cell(0, 10, step)
75
  pdf.ln(10)
76
 
@@ -133,6 +135,7 @@ if selected_module != st.session_state.current_module:
133
  st.session_state.module_correct_count[selected_module] = 0
134
  st.session_state.selected_answer = None
135
  st.session_state.answered = False
 
136
 
137
  # Load the current module's question
138
  current_question = st.session_state.questions[st.session_state.current_index]
@@ -190,6 +193,7 @@ if submit_button:
190
  # Set answered to true to disable options
191
  st.session_state.questions[st.session_state.current_index]['answered'] = True
192
  st.session_state.selected_answer = selected_answer
 
193
 
194
  else:
195
  # If already answered, move to the next question
@@ -197,6 +201,12 @@ if submit_button:
197
  st.session_state.questions.append(new_question)
198
  st.session_state.current_index = len(st.session_state.questions) - 1
199
  st.session_state.answered = False
 
 
 
 
 
 
200
 
201
  # Show correct/incorrect feedback after submission
202
  if current_question.get('answered', False):
 
25
  st.session_state.selected_answer = None
26
  if 'answered' not in st.session_state:
27
  st.session_state.answered = False
28
+ if 'button_clicked' not in st.session_state:
29
+ st.session_state.button_clicked = False
30
 
31
  def reset_pdf_cache():
32
  st.session_state.pdf_data = None
 
72
  pdf.multi_cell(0, 10, f"Explanation: {explanation}")
73
  pdf.ln(5)
74
  pdf.multi_cell(0, 10, "Step-by-Step Solution:")
75
+ for step in step_by-step_solution:
76
  pdf.multi_cell(0, 10, step)
77
  pdf.ln(10)
78
 
 
135
  st.session_state.module_correct_count[selected_module] = 0
136
  st.session_state.selected_answer = None
137
  st.session_state.answered = False
138
+ st.session_state.button_clicked = False
139
 
140
  # Load the current module's question
141
  current_question = st.session_state.questions[st.session_state.current_index]
 
193
  # Set answered to true to disable options
194
  st.session_state.questions[st.session_state.current_index]['answered'] = True
195
  st.session_state.selected_answer = selected_answer
196
+ st.session_state.button_clicked = True
197
 
198
  else:
199
  # If already answered, move to the next question
 
201
  st.session_state.questions.append(new_question)
202
  st.session_state.current_index = len(st.session_state.questions) - 1
203
  st.session_state.answered = False
204
+ st.session_state.button_clicked = False
205
+
206
+ # Re-render the form if the button was clicked to disable the options
207
+ if st.session_state.button_clicked:
208
+ st.session_state.button_clicked = False
209
+ st.experimental_rerun()
210
 
211
  # Show correct/incorrect feedback after submission
212
  if current_question.get('answered', False):