Spaces:
Sleeping
Sleeping
Maryam Ilka commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -496,30 +496,11 @@ def welcome_page():
|
|
| 496 |
""", unsafe_allow_html=True)
|
| 497 |
|
| 498 |
if st.button("شروع پرسشنامه", key="start_btn", type="primary"):
|
| 499 |
-
st.session_state.current_page = "
|
| 500 |
st.session_state.start_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 501 |
st.rerun()
|
| 502 |
|
| 503 |
|
| 504 |
-
def user_contact():
|
| 505 |
-
"""راه ارتباطی ساده"""
|
| 506 |
-
st.markdown("""
|
| 507 |
-
<div style="text-align: center; margin-bottom: 30px;">
|
| 508 |
-
<h3>📩 راه ارتباطی شما (اختیاری)</h3>
|
| 509 |
-
<p>در صورت تمایل به شرکت در قرعهکشی میتوانید آیدی تلگرام، شماره تماس یا ایمیل خود را وارد کنید:</p>
|
| 510 |
-
</div>
|
| 511 |
-
""", unsafe_allow_html=True)
|
| 512 |
-
|
| 513 |
-
contact_info = st.text_input(
|
| 514 |
-
"راه ارتباطی (اختیاری)",
|
| 515 |
-
placeholder="مثال: @username یا 09123456789 یا example@email.com",
|
| 516 |
-
key="user_contact_input"
|
| 517 |
-
)
|
| 518 |
-
|
| 519 |
-
if st.button("ادامه", key="continue_btn", type="primary"):
|
| 520 |
-
st.session_state.user_contact = contact_info
|
| 521 |
-
st.session_state.current_page = "demographic"
|
| 522 |
-
st.rerun()
|
| 523 |
|
| 524 |
def demographic_form():
|
| 525 |
"""فرم اطلاعات دموگرافیک"""
|
|
@@ -545,8 +526,28 @@ def demographic_form():
|
|
| 545 |
"ride_frequency": ride_frequency,
|
| 546 |
"related_education_job": related_education_job
|
| 547 |
}
|
| 548 |
-
st.session_state.current_page = "
|
| 549 |
-
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
|
| 551 |
def scenario_explanation():
|
| 552 |
"""توضیح سناریو"""
|
|
@@ -796,8 +797,8 @@ def explanation_questions():
|
|
| 796 |
index=None,
|
| 797 |
key="explanation_type_radio"
|
| 798 |
)
|
| 799 |
-
|
| 800 |
-
if st.button("
|
| 801 |
# استفاده از مقادیر مستقیماً از session_state
|
| 802 |
st.session_state.trust = st.session_state.get("trust_radio")
|
| 803 |
st.session_state.pricing_method = st.session_state.get("pricing_method_radio")
|
|
@@ -845,10 +846,9 @@ def explanation_questions():
|
|
| 845 |
save_data[q["label"]] = st.session_state.get(q["key"], None)
|
| 846 |
|
| 847 |
if save_to_sheet(save_data):
|
| 848 |
-
st.session_state.current_page = "
|
| 849 |
st.rerun()
|
| 850 |
-
|
| 851 |
-
st.error("خطا در ذخیرهسازی دادهها. لطفاً دوباره تلاش کنید.")
|
| 852 |
|
| 853 |
def thank_you_page():
|
| 854 |
"""صفحه تشکر"""
|
|
@@ -873,16 +873,17 @@ def main():
|
|
| 873 |
st.session_state.demographic_data = None
|
| 874 |
st.session_state.price_accepted = 0
|
| 875 |
|
| 876 |
-
|
|
|
|
| 877 |
"welcome": welcome_page,
|
| 878 |
-
"contact": user_contact,
|
| 879 |
-
"demographic": demographic_form,
|
| 880 |
"scenario_explanation": scenario_explanation,
|
| 881 |
"map_view": map_view,
|
| 882 |
"attention_check1": attention_check1,
|
| 883 |
"random_likert_questions": random_likert_questions,
|
| 884 |
"attention_check2": attention_check2,
|
| 885 |
"explanation_questions": explanation_questions,
|
|
|
|
|
|
|
| 886 |
"thank_you": thank_you_page
|
| 887 |
}
|
| 888 |
|
|
|
|
| 496 |
""", unsafe_allow_html=True)
|
| 497 |
|
| 498 |
if st.button("شروع پرسشنامه", key="start_btn", type="primary"):
|
| 499 |
+
st.session_state.current_page = "scenario_explanation"
|
| 500 |
st.session_state.start_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 501 |
st.rerun()
|
| 502 |
|
| 503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
|
| 505 |
def demographic_form():
|
| 506 |
"""فرم اطلاعات دموگرافیک"""
|
|
|
|
| 526 |
"ride_frequency": ride_frequency,
|
| 527 |
"related_education_job": related_education_job
|
| 528 |
}
|
| 529 |
+
st.session_state.current_page = "contact"
|
| 530 |
+
st.rerun()
|
| 531 |
+
|
| 532 |
+
def user_contact():
|
| 533 |
+
"""راه ارتباطی ساده"""
|
| 534 |
+
st.markdown("""
|
| 535 |
+
<div style="text-align: center; margin-bottom: 30px;">
|
| 536 |
+
<h3>📩 راه ارتباطی شما (اختیاری)</h3>
|
| 537 |
+
<p>در صورت تمایل به شرکت در قرعهکشی میتوانید آیدی تلگرام، شماره تماس یا ایمیل خود را وارد کنید:</p>
|
| 538 |
+
</div>
|
| 539 |
+
""", unsafe_allow_html=True)
|
| 540 |
+
|
| 541 |
+
contact_info = st.text_input(
|
| 542 |
+
"راه ارتباطی (اختیاری)",
|
| 543 |
+
placeholder="مثال: @username یا 09123456789 یا example@email.com",
|
| 544 |
+
key="user_contact_input"
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
if st.button("ثبت نهایی", key="final_submit", type="primary"): # تغییر متن دکمه
|
| 548 |
+
st.session_state.user_contact = contact_info
|
| 549 |
+
st.session_state.current_page = "thank_you" # رفتن به صفحه تشکر
|
| 550 |
+
st.rerun()
|
| 551 |
|
| 552 |
def scenario_explanation():
|
| 553 |
"""توضیح سناریو"""
|
|
|
|
| 797 |
index=None,
|
| 798 |
key="explanation_type_radio"
|
| 799 |
)
|
| 800 |
+
|
| 801 |
+
if st.button("ادامه", type="primary", key="submit_explanation"):
|
| 802 |
# استفاده از مقادیر مستقیماً از session_state
|
| 803 |
st.session_state.trust = st.session_state.get("trust_radio")
|
| 804 |
st.session_state.pricing_method = st.session_state.get("pricing_method_radio")
|
|
|
|
| 846 |
save_data[q["label"]] = st.session_state.get(q["key"], None)
|
| 847 |
|
| 848 |
if save_to_sheet(save_data):
|
| 849 |
+
st.session_state.current_page = "demographic" # تغییر مسیر به demographic
|
| 850 |
st.rerun()
|
| 851 |
+
|
|
|
|
| 852 |
|
| 853 |
def thank_you_page():
|
| 854 |
"""صفحه تشکر"""
|
|
|
|
| 873 |
st.session_state.demographic_data = None
|
| 874 |
st.session_state.price_accepted = 0
|
| 875 |
|
| 876 |
+
|
| 877 |
+
pages = {
|
| 878 |
"welcome": welcome_page,
|
|
|
|
|
|
|
| 879 |
"scenario_explanation": scenario_explanation,
|
| 880 |
"map_view": map_view,
|
| 881 |
"attention_check1": attention_check1,
|
| 882 |
"random_likert_questions": random_likert_questions,
|
| 883 |
"attention_check2": attention_check2,
|
| 884 |
"explanation_questions": explanation_questions,
|
| 885 |
+
"demographic": demographic_form, # دموگرافیک قبل از کانتکت
|
| 886 |
+
"contact": user_contact, # کانتکت در انتها
|
| 887 |
"thank_you": thank_you_page
|
| 888 |
}
|
| 889 |
|