Sina Media Lab commited on
Commit
5bd3774
·
1 Parent(s): 1086036
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -107,10 +107,14 @@ def generate_new_question(module_name, module):
107
  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.button_label = "Next Question"
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.button_label = "Next Question"
 
 
 
 
114
 
115
  # Load all modules dynamically
116
  modules = load_modules()
@@ -147,7 +151,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", 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:
 
107
  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.button_label = "Submit"
111
+ elif direction == "next":
112
+ if st.session_state.current_index < len(st.session_state.questions) - 1:
113
+ st.session_state.current_index += 1
114
+ else:
115
+ st.session_state.questions.append(generate_new_question(st.session_state.current_module, modules[st.session_state.current_module]))
116
+ st.session_state.current_index = len(st.session_state.questions) - 1
117
+ st.session_state.button_label = "Submit"
118
 
119
  # Load all modules dynamically
120
  modules = load_modules()
 
151
  if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
152
  navigate_question("prev")
153
  with col2:
154
+ if st.button("➡️ Next"):
155
  navigate_question("next")
156
  with col3:
157
  if len(st.session_state.questions) > 0: