Maryam Ilka commited on
Commit
388d2df
·
verified ·
1 Parent(s): c07759d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -487,6 +487,7 @@ def explanation_questions():
487
  )
488
 
489
  # سوال دوم (فقط اگر پاسخ بله باشد)
 
490
  if explanation_received == "بله":
491
  st.markdown("""
492
  <div class="survey-section">
@@ -504,8 +505,6 @@ def explanation_questions():
504
  index=None,
505
  key="explanation_type"
506
  )
507
- else:
508
- explanation_type = None
509
 
510
  if st.button("ثبت پاسخ‌ها", type="primary"):
511
  if explanation_received is None:
@@ -516,10 +515,27 @@ def explanation_questions():
516
  # ذخیره پاسخ‌ها در session state
517
  st.session_state.explanation_data = {
518
  "explanation_received": explanation_received,
519
- "explanation_type": explanation_type if explanation_received == "بله" else None
520
  }
521
- st.session_state.current_page = "thank_you"
522
- st.rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
 
524
  def thank_you_page():
525
  """صفحه تشکر"""
 
487
  )
488
 
489
  # سوال دوم (فقط اگر پاسخ بله باشد)
490
+ explanation_type = None
491
  if explanation_received == "بله":
492
  st.markdown("""
493
  <div class="survey-section">
 
505
  index=None,
506
  key="explanation_type"
507
  )
 
 
508
 
509
  if st.button("ثبت پاسخ‌ها", type="primary"):
510
  if explanation_received is None:
 
515
  # ذخیره پاسخ‌ها در session state
516
  st.session_state.explanation_data = {
517
  "explanation_received": explanation_received,
518
+ "explanation_type": explanation_type if explanation_received == "بله" else "N/A"
519
  }
520
+
521
+ # جمع‌آوری تمام داده‌ها برای ذخیره‌سازی
522
+ all_data = {
523
+ "scenario_type": st.session_state.scenario_type,
524
+ "price": st.session_state.price,
525
+ **st.session_state.demographic_data,
526
+ "user_contact": st.session_state.get("user_contact", ""),
527
+ "transparency_answers": st.session_state.transparency_answers,
528
+ "fairness_answers": st.session_state.fairness_answers,
529
+ "explanation_received": explanation_received,
530
+ "explanation_type": explanation_type if explanation_received == "بله" else "N/A"
531
+ }
532
+
533
+ # ذخیره در Google Sheets
534
+ if save_to_sheet(all_data):
535
+ st.session_state.current_page = "thank_you"
536
+ st.rerun()
537
+ else:
538
+ st.error("خطا در ذخیره‌سازی داده‌ها. لطفاً دوباره تلاش کنید.")
539
 
540
  def thank_you_page():
541
  """صفحه تشکر"""