GSMEthesis commited on
Commit
55b2aac
·
verified ·
1 Parent(s): 622f9ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -19
app.py CHANGED
@@ -1267,27 +1267,18 @@ def random_likert_questions():
1267
  button_label = "ادامه به گروه بعدی" if st.session_state.current_likert_group < len(question_groups)-1 else "اتمام پرسشنامه"
1268
 
1269
  if st.button(button_label):
1270
- # بررسی آیا همه سوالات این گروه پاسخ داده شده‌اند و هیچ کدام صفر نیستند
1271
- all_answered = all(
1272
- question["key"] in st.session_state.answers and
1273
- st.session_state.answers[question["key"]] is not None
1274
- for question in current_group['questions']
1275
- )
1276
-
1277
- has_zero = any(
1278
- st.session_state.answers.get(question["key"]) == 0
1279
- for question in current_group['questions']
1280
- )
1281
 
1282
- if not all_answered or has_zero:
1283
- st.error("لطفاً به تمام سوالات این بخش پاسخ دهید (مقدار صفر مجاز نیست)")
 
 
1284
  else:
1285
- if st.session_state.current_likert_group < len(question_groups) - 1:
1286
- st.session_state.current_likert_group += 1
1287
- st.rerun()
1288
- else:
1289
- st.session_state.current_page = "explanation_questions"
1290
- st.rerun()
1291
 
1292
  def explanation_questions():
1293
  """نمایش سوالات تکمیلی به صورت مرحله‌ای با دکمه ادامه"""
 
1267
  button_label = "ادامه به گروه بعدی" if st.session_state.current_likert_group < len(question_groups)-1 else "اتمام پرسشنامه"
1268
 
1269
  if st.button(button_label):
1270
+ # ذخیره پاسخ‌ها قبل از رفتن به گروه بعدی
1271
+ for question in current_group['questions']:
1272
+ if question["key"] in st.session_state:
1273
+ st.session_state.answers[question["key"]] = st.session_state[question["key"]]
 
 
 
 
 
 
 
1274
 
1275
+ # رفتن به گروه بعدی یا صفحه پایانی
1276
+ if st.session_state.current_likert_group < len(question_groups) - 1:
1277
+ st.session_state.current_likert_group += 1
1278
+ st.rerun()
1279
  else:
1280
+ st.session_state.current_page = "explanation_questions"
1281
+ st.rerun()
 
 
 
 
1282
 
1283
  def explanation_questions():
1284
  """نمایش سوالات تکمیلی به صورت مرحله‌ای با دکمه ادامه"""