Spaces:
Paused
Paused
Maryam Ilka commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -500,86 +500,6 @@ def welcome_page():
|
|
| 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 |
-
"""فرم اطلاعات دموگرافیک"""
|
| 507 |
-
st.markdown("### 📝 اطلاعات دموگرافیک")
|
| 508 |
-
|
| 509 |
-
with st.form("demographic_form"):
|
| 510 |
-
age = st.number_input("سن", min_value=18, max_value=100)
|
| 511 |
-
gender = st.selectbox("جنسیت", ["مرد", "زن", "سایر"])
|
| 512 |
-
education = st.selectbox("تحصیلات", ["دیپلم", "لیسانس", "فوق لیسانس", "دکترا"])
|
| 513 |
-
ride_frequency = st.selectbox("دفعات استفاده از سرویسهای اشتراک سفر در ماه",
|
| 514 |
-
["کمتر از 5 بار", "5-10 بار", "بیش از 10 بار"])
|
| 515 |
-
related_education_job = st.text_input(
|
| 516 |
-
"اگر تحصیلات یا شغل مرتبط با مدیریت/بازاریابی دارید، لطفاً مشخص کنید (اختیاری):",
|
| 517 |
-
placeholder="مثال: مدیریت بازرگانی، بازاریابی دیجیتال، MBA و...",
|
| 518 |
-
key="related_education_job"
|
| 519 |
-
)
|
| 520 |
-
|
| 521 |
-
if st.form_submit_button("ادامه"):
|
| 522 |
-
st.session_state.demographic_data = {
|
| 523 |
-
"age": age,
|
| 524 |
-
"gender": gender,
|
| 525 |
-
"education": education,
|
| 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 |
-
|
| 548 |
-
|
| 549 |
-
if st.button("ثبت پاسخها", type="primary", key="submit_explanation"):
|
| 550 |
-
st.session_state.user_contact = contact_info
|
| 551 |
-
end_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 552 |
-
start_time = datetime.strptime(st.session_state.start_time, "%Y-%m-%d %H:%M:%S")
|
| 553 |
-
completion_time = (datetime.now() - start_time).total_seconds()
|
| 554 |
-
|
| 555 |
-
save_data = {
|
| 556 |
-
"start_time": st.session_state.start_time,
|
| 557 |
-
"end_time": end_time,
|
| 558 |
-
"completion_time": completion_time,
|
| 559 |
-
"scenario_type": st.session_state.scenario_type,
|
| 560 |
-
"price": st.session_state.price,
|
| 561 |
-
"user_contact": st.session_state.get("user_contact", ""),
|
| 562 |
-
"price_accepted": st.session_state.get("price_accepted", 0),
|
| 563 |
-
"attention_check1": st.session_state.attention_check1,
|
| 564 |
-
"attention_check2": st.session_state.attention_check2,
|
| 565 |
-
"trust": st.session_state.trust,
|
| 566 |
-
"pricing_method": st.session_state.pricing_method,
|
| 567 |
-
"price_increase": st.session_state.price_increase,
|
| 568 |
-
"explanation_received": st.session_state.explanation_received,
|
| 569 |
-
"explanation_type": st.session_state.explanation_type if st.session_state.explanation_received == "بله" else "N/A",
|
| 570 |
-
**st.session_state.demographic_data
|
| 571 |
-
}
|
| 572 |
-
|
| 573 |
-
# اضافه کردن پاسخهای لیکرت
|
| 574 |
-
for q in st.session_state.all_questions:
|
| 575 |
-
save_data[q["label"]] = st.session_state.get(q["key"], None)
|
| 576 |
-
|
| 577 |
-
if save_to_sheet(save_data):
|
| 578 |
-
st.session_state.current_page = "thank_you"
|
| 579 |
-
st.rerun()
|
| 580 |
-
else:
|
| 581 |
-
st.error("خطا در ذخیرهسازی دادهها. لطفاً دوباره تلاش کنید.")
|
| 582 |
-
|
| 583 |
|
| 584 |
def scenario_explanation():
|
| 585 |
"""توضیح سناریو"""
|
|
@@ -769,8 +689,6 @@ def explanation_questions():
|
|
| 769 |
st.session_state.explanation_received = None
|
| 770 |
if 'explanation_type' not in st.session_state:
|
| 771 |
st.session_state.explanation_type = None
|
| 772 |
-
|
| 773 |
-
|
| 774 |
|
| 775 |
trust = st.radio(
|
| 776 |
"آیا شما به تصمیم گیری هایی که توسط هوش مصنوعی انجام می شود اعتماد دارید؟",
|
|
@@ -851,6 +769,86 @@ def explanation_questions():
|
|
| 851 |
elif st.session_state.explanation_received == "بله" and st.session_state.explanation_type is None:
|
| 852 |
st.warning("لطفاً به سوال تکمیلی پنجم پاسخ دهید")
|
| 853 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
|
| 855 |
def thank_you_page():
|
| 856 |
"""صفحه تشکر"""
|
|
|
|
| 500 |
st.session_state.start_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 501 |
st.rerun()
|
| 502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
|
| 504 |
def scenario_explanation():
|
| 505 |
"""توضیح سناریو"""
|
|
|
|
| 689 |
st.session_state.explanation_received = None
|
| 690 |
if 'explanation_type' not in st.session_state:
|
| 691 |
st.session_state.explanation_type = None
|
|
|
|
|
|
|
| 692 |
|
| 693 |
trust = st.radio(
|
| 694 |
"آیا شما به تصمیم گیری هایی که توسط هوش مصنوعی انجام می شود اعتماد دارید؟",
|
|
|
|
| 769 |
elif st.session_state.explanation_received == "بله" and st.session_state.explanation_type is None:
|
| 770 |
st.warning("لطفاً به سوال تکمیلی پنجم پاسخ دهید")
|
| 771 |
|
| 772 |
+
st.session_state.current_page = "demographic"
|
| 773 |
+
st.rerun()
|
| 774 |
+
|
| 775 |
+
|
| 776 |
+
def demographic_form():
|
| 777 |
+
"""فرم اطلاعات دموگرافیک"""
|
| 778 |
+
st.markdown("### 📝 اطلاعات دموگرافیک")
|
| 779 |
+
|
| 780 |
+
with st.form("demographic_form"):
|
| 781 |
+
age = st.number_input("سن", min_value=18, max_value=100)
|
| 782 |
+
gender = st.selectbox("جنسیت", ["مرد", "زن", "سایر"])
|
| 783 |
+
education = st.selectbox("تحصیلات", ["دیپلم", "لیسانس", "فوق لیسانس", "دکترا"])
|
| 784 |
+
ride_frequency = st.selectbox("دفعات استفاده از سرویسهای اشتراک سفر در ماه",
|
| 785 |
+
["کمتر از 5 بار", "5-10 بار", "بیش از 10 بار"])
|
| 786 |
+
related_education_job = st.text_input(
|
| 787 |
+
"اگر تحصیلات یا شغل مرتبط با مدیریت/بازاریابی دارید، لطفاً مشخص کنید (اختیاری):",
|
| 788 |
+
placeholder="مثال: مدیریت بازرگانی، بازاریابی دیجیتال، MBA و...",
|
| 789 |
+
key="related_education_job"
|
| 790 |
+
)
|
| 791 |
+
|
| 792 |
+
if st.form_submit_button("ادامه"):
|
| 793 |
+
st.session_state.demographic_data = {
|
| 794 |
+
"age": age,
|
| 795 |
+
"gender": gender,
|
| 796 |
+
"education": education,
|
| 797 |
+
"ride_frequency": ride_frequency,
|
| 798 |
+
"related_education_job": related_education_job
|
| 799 |
+
}
|
| 800 |
+
st.session_state.current_page = "contact"
|
| 801 |
+
st.rerun()
|
| 802 |
+
|
| 803 |
+
def user_contact():
|
| 804 |
+
"""راه ارتباطی ساده"""
|
| 805 |
+
st.markdown("""
|
| 806 |
+
<div style="text-align: center; margin-bottom: 30px;">
|
| 807 |
+
<h3>📩 راه ارتباطی شما (اختیاری)</h3>
|
| 808 |
+
<p>در صورت تمایل به شرکت در قرعهکشی میتوانید آیدی تلگرام، شماره تماس یا ایمیل خود را وارد کنید:</p>
|
| 809 |
+
</div>
|
| 810 |
+
""", unsafe_allow_html=True)
|
| 811 |
+
|
| 812 |
+
contact_info = st.text_input(
|
| 813 |
+
"راه ارتباطی (اختیاری)",
|
| 814 |
+
placeholder="مثال: @username یا 09123456789 یا example@email.com",
|
| 815 |
+
key="user_contact_input"
|
| 816 |
+
)
|
| 817 |
+
|
| 818 |
+
if st.button("ثبت پاسخها", type="primary", key="submit_explanation"):
|
| 819 |
+
st.session_state.user_contact = contact_info
|
| 820 |
+
end_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 821 |
+
start_time = datetime.strptime(st.session_state.start_time, "%Y-%m-%d %H:%M:%S")
|
| 822 |
+
completion_time = (datetime.now() - start_time).total_seconds()
|
| 823 |
+
|
| 824 |
+
save_data = {
|
| 825 |
+
"start_time": st.session_state.start_time,
|
| 826 |
+
"end_time": end_time,
|
| 827 |
+
"completion_time": completion_time,
|
| 828 |
+
"scenario_type": st.session_state.scenario_type,
|
| 829 |
+
"price": st.session_state.price,
|
| 830 |
+
"user_contact": st.session_state.get("user_contact", ""),
|
| 831 |
+
"price_accepted": st.session_state.get("price_accepted", 0),
|
| 832 |
+
"attention_check1": st.session_state.attention_check1,
|
| 833 |
+
"attention_check2": st.session_state.attention_check2,
|
| 834 |
+
"trust": st.session_state.trust,
|
| 835 |
+
"pricing_method": st.session_state.pricing_method,
|
| 836 |
+
"price_increase": st.session_state.price_increase,
|
| 837 |
+
"explanation_received": st.session_state.explanation_received,
|
| 838 |
+
"explanation_type": st.session_state.explanation_type if st.session_state.explanation_received == "بله" else "N/A",
|
| 839 |
+
**st.session_state.demographic_data
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
# اضافه کردن پاسخهای لیکرت
|
| 843 |
+
for q in st.session_state.all_questions:
|
| 844 |
+
save_data[q["label"]] = st.session_state.get(q["key"], None)
|
| 845 |
+
|
| 846 |
+
if save_to_sheet(save_data):
|
| 847 |
+
st.session_state.current_page = "thank_you"
|
| 848 |
+
st.rerun()
|
| 849 |
+
else:
|
| 850 |
+
st.error("خطا در ذخیرهسازی دادهها. لطفاً دوباره تلاش کنید.")
|
| 851 |
+
|
| 852 |
|
| 853 |
def thank_you_page():
|
| 854 |
"""صفحه تشکر"""
|