rashid01 commited on
Commit
e1a18fa
·
verified ·
1 Parent(s): 2fc2874

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -281,23 +281,25 @@ if st.button("Generate Questions", key="generate_questions"):
281
  with st.spinner("Generating questions..."):
282
  questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
283
  if questions:
284
- question_index = st.session_state.get('question_index', 0)
285
  st.session_state['questions'] = questions
286
- st.session_state['question_index'] = question_index
287
  st.session_state['questions_count'] = len(questions)
288
 
289
- if question_index < len(questions):
290
- st.markdown(style_output("Question:", "#4CAF50"), unsafe_allow_html=True)
291
- st.write(st.session_state['questions'][question_index])
292
- col1, col2 = st.columns([3, 1])
293
- with col2:
294
- if st.button("Next", key="next_question"):
295
- if question_index + 1 < len(st.session_state['questions']):
296
- st.session_state['question_index'] += 1
297
- else:
298
- st.session_state['question_index'] = 0 # Loop back to first question
299
- st.success("You have reached the end of the questions.")
300
- progress_data["questions_solved"][question_type] += num_questions
 
 
 
301
 
302
  st.header("🗣️ Provide Feedback")
303
  answer = st.text_area("Submit Your Answer", key="text_area_answer")
@@ -336,4 +338,3 @@ st.markdown("""
336
  </div>
337
  """, unsafe_allow_html=True)
338
 
339
-
 
281
  with st.spinner("Generating questions..."):
282
  questions = generate_questions(model_choice, role, question_type, num_questions, difficulty)
283
  if questions:
 
284
  st.session_state['questions'] = questions
285
+ st.session_state['question_index'] = 0 # Reset index to start
286
  st.session_state['questions_count'] = len(questions)
287
 
288
+ st.markdown(style_output("Question:", "#4CAF50"), unsafe_allow_html=True)
289
+ st.write(st.session_state['questions'][st.session_state['question_index']])
290
+
291
+ col1, col2 = st.columns([3, 1])
292
+ with col2:
293
+ if st.button("Next", key="next_question"):
294
+ if st.session_state['question_index'] + 1 < len(st.session_state['questions']):
295
+ st.session_state['question_index'] += 1
296
+ else:
297
+ st.session_state['question_index'] = 0 # Loop back to first question
298
+ st.success("You have reached the end of the questions.")
299
+ st.markdown(style_output("Question:", "#4CAF50"), unsafe_allow_html=True)
300
+ st.write(st.session_state['questions'][st.session_state['question_index']])
301
+
302
+ progress_data["questions_solved"][question_type] += num_questions
303
 
304
  st.header("🗣️ Provide Feedback")
305
  answer = st.text_area("Submit Your Answer", key="text_area_answer")
 
338
  </div>
339
  """, unsafe_allow_html=True)
340