GSMEthesis commited on
Commit
ea22cb8
·
verified ·
1 Parent(s): 99f56dd

Update app.py

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