Sina Media Lab commited on
Commit
27d1943
·
1 Parent(s): 085d082
Files changed (1) hide show
  1. app.py +31 -30
app.py CHANGED
@@ -99,36 +99,7 @@ if module_name:
99
  st.title(title)
100
  st.write(description)
101
 
102
- # Display the "Next", "Prev", and "Download PDF Report" buttons above the question
103
- col1, col2, col3 = st.columns([1, 1, 2])
104
- with col1:
105
- if st.session_state.submitted:
106
- if st.button("➡️ Next"):
107
- st.session_state.current_question = None
108
- logging.info("Navigated to next question.")
109
- with col2:
110
- if st.session_state.question_count > 1:
111
- if st.button("⬅️ Prev"):
112
- st.session_state.question_count -= 1
113
- st.session_state.submitted = False
114
- question_data = st.session_state.question_queue[st.session_state.question_count - 1]
115
- st.session_state.current_question = question_data[0]
116
- st.session_state.options = question_data[1]
117
- st.session_state.selected_answer = question_data[2]
118
- st.session_state.correct_answer = question_data[3]
119
- st.session_state.explanation = question_data[4]
120
- logging.info("Navigated to previous question.")
121
- with col3:
122
- if st.session_state.question_count > 0:
123
- pdf = generate_pdf_report()
124
- st.download_button(
125
- label="Download PDF Report 📄",
126
- data=pdf,
127
- file_name="quiz_report.pdf",
128
- mime="application/pdf"
129
- )
130
- logging.info("PDF report generated.")
131
-
132
  if st.session_state.current_question is None or st.session_state.submitted:
133
  st.session_state.current_question, st.session_state.options, st.session_state.correct_answer, st.session_state.explanation = generate_question()
134
  st.session_state.submitted = False
@@ -173,6 +144,36 @@ if module_name:
173
  unsafe_allow_html=True
174
  )
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  except ModuleNotFoundError as e:
177
  st.error(f"The module '{module_name}' was not found. Please select another module.")
178
  logging.error(f"Error: {e}")
 
99
  st.title(title)
100
  st.write(description)
101
 
102
+ # Handle question generation and submission
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  if st.session_state.current_question is None or st.session_state.submitted:
104
  st.session_state.current_question, st.session_state.options, st.session_state.correct_answer, st.session_state.explanation = generate_question()
105
  st.session_state.submitted = False
 
144
  unsafe_allow_html=True
145
  )
146
 
147
+ # Display the "Next", "Prev", and "Download PDF Report" buttons above the question
148
+ col1, col2, col3 = st.columns([1, 1, 2])
149
+ with col1:
150
+ if st.session_state.submitted:
151
+ if st.button("➡️ Next"):
152
+ st.session_state.current_question = None
153
+ logging.info("Navigated to next question.")
154
+ with col2:
155
+ if st.session_state.question_count > 1:
156
+ if st.button("⬅️ Prev"):
157
+ st.session_state.question_count -= 1
158
+ st.session_state.submitted = False
159
+ question_data = st.session_state.question_queue[st.session_state.question_count - 1]
160
+ st.session_state.current_question = question_data[0]
161
+ st.session_state.options = question_data[1]
162
+ st.session_state.selected_answer = question_data[2]
163
+ st.session_state.correct_answer = question_data[3]
164
+ st.session_state.explanation = question_data[4]
165
+ logging.info("Navigated to previous question.")
166
+ with col3:
167
+ if st.session_state.question_count > 0:
168
+ pdf = generate_pdf_report()
169
+ st.download_button(
170
+ label="Download PDF Report 📄",
171
+ data=pdf,
172
+ file_name="quiz_report.pdf",
173
+ mime="application/pdf"
174
+ )
175
+ logging.info("PDF report generated.")
176
+
177
  except ModuleNotFoundError as e:
178
  st.error(f"The module '{module_name}' was not found. Please select another module.")
179
  logging.error(f"Error: {e}")