Sina Media Lab commited on
Commit
34e799a
·
1 Parent(s): a086503
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -104,6 +104,12 @@ def generate_new_question(module_name, module):
104
  st.warning(f"Question in module '{module_name}' does not have 4 options. Found {len(question_data['options'])}.")
105
  return question_data
106
 
 
 
 
 
 
 
107
  # Load all modules dynamically
108
  modules = load_modules()
109
 
@@ -133,6 +139,27 @@ current_question = st.session_state.questions[st.session_state.current_index]
133
  st.title(modules[selected_module]["title"])
134
  st.write(modules[selected_module]["description"])
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  # Create the form for the question
137
  with st.form(key=f'question_form_{st.session_state.current_index}'):
138
  selected_answer = st.radio(
 
104
  st.warning(f"Question in module '{module_name}' does not have 4 options. Found {len(question_data['options'])}.")
105
  return question_data
106
 
107
+ def navigate_question(direction):
108
+ if direction == "prev" and st.session_state.current_index > 0:
109
+ st.session_state.current_index -= 1
110
+ elif direction == "next" and st.session_state.current_index < len(st.session_state.questions) - 1:
111
+ st.session_state.current_index += 1
112
+
113
  # Load all modules dynamically
114
  modules = load_modules()
115
 
 
139
  st.title(modules[selected_module]["title"])
140
  st.write(modules[selected_module]["description"])
141
 
142
+ # Navigation and PDF report buttons
143
+ col1, col2, col3 = st.columns([1, 1, 2])
144
+ with col1:
145
+ if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
146
+ navigate_question("prev")
147
+ with col2:
148
+ if st.button("➡️ Next", disabled=st.session_state.current_index >= len(st.session_state.questions) - 1):
149
+ navigate_question("next")
150
+ with col3:
151
+ if len(st.session_state.questions) > 0:
152
+ pdf = generate_pdf_report()
153
+ st.session_state.pdf_data = pdf # Reset PDF cache
154
+ st.download_button(
155
+ label="Download PDF Report 📄",
156
+ data=st.session_state.pdf_data,
157
+ file_name="quiz_report.pdf",
158
+ mime="application/pdf"
159
+ )
160
+
161
+ st.write(current_question["question"])
162
+
163
  # Create the form for the question
164
  with st.form(key=f'question_form_{st.session_state.current_index}'):
165
  selected_answer = st.radio(