Spaces:
Sleeping
Sleeping
Maryam Ilka commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -544,10 +544,42 @@ def user_contact():
|
|
| 544 |
key="user_contact_input"
|
| 545 |
)
|
| 546 |
|
| 547 |
-
|
|
|
|
|
|
|
| 548 |
st.session_state.user_contact = contact_info
|
| 549 |
-
|
| 550 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
|
| 552 |
def scenario_explanation():
|
| 553 |
"""توضیح سناریو"""
|
|
@@ -738,6 +770,7 @@ def explanation_questions():
|
|
| 738 |
if 'explanation_type' not in st.session_state:
|
| 739 |
st.session_state.explanation_type = None
|
| 740 |
|
|
|
|
| 741 |
|
| 742 |
trust = st.radio(
|
| 743 |
"آیا شما به تصمیم گیری هایی که توسط هوش مصنوعی انجام می شود اعتماد دارید؟",
|
|
@@ -817,37 +850,6 @@ def explanation_questions():
|
|
| 817 |
st.warning("لطفاً به سوال تکمیلی چهارم پاسخ دهید")
|
| 818 |
elif st.session_state.explanation_received == "بله" and st.session_state.explanation_type is None:
|
| 819 |
st.warning("لطفاً به سوال تکمیلی پنجم پاسخ دهید")
|
| 820 |
-
else:
|
| 821 |
-
# جمعآوری تمام دادهها برای ذخیرهسازی
|
| 822 |
-
end_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 823 |
-
start_time = datetime.strptime(st.session_state.start_time, "%Y-%m-%d %H:%M:%S")
|
| 824 |
-
completion_time = (datetime.now() - start_time).total_seconds()
|
| 825 |
-
|
| 826 |
-
save_data = {
|
| 827 |
-
"start_time": st.session_state.start_time,
|
| 828 |
-
"end_time": end_time,
|
| 829 |
-
"completion_time": completion_time,
|
| 830 |
-
"scenario_type": st.session_state.scenario_type,
|
| 831 |
-
"price": st.session_state.price,
|
| 832 |
-
"user_contact": st.session_state.get("user_contact", ""),
|
| 833 |
-
"price_accepted": st.session_state.get("price_accepted", 0),
|
| 834 |
-
"attention_check1": st.session_state.attention_check1,
|
| 835 |
-
"attention_check2": st.session_state.attention_check2,
|
| 836 |
-
"trust": st.session_state.trust,
|
| 837 |
-
"pricing_method": st.session_state.pricing_method,
|
| 838 |
-
"price_increase": st.session_state.price_increase,
|
| 839 |
-
"explanation_received": st.session_state.explanation_received,
|
| 840 |
-
"explanation_type": st.session_state.explanation_type if st.session_state.explanation_received == "بله" else "N/A",
|
| 841 |
-
**st.session_state.demographic_data
|
| 842 |
-
}
|
| 843 |
-
|
| 844 |
-
# اضافه کردن پاسخهای لیکرت
|
| 845 |
-
for q in st.session_state.all_questions:
|
| 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():
|
|
|
|
| 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 |
"""توضیح سناریو"""
|
|
|
|
| 770 |
if 'explanation_type' not in st.session_state:
|
| 771 |
st.session_state.explanation_type = None
|
| 772 |
|
| 773 |
+
|
| 774 |
|
| 775 |
trust = st.radio(
|
| 776 |
"آیا شما به تصمیم گیری هایی که توسط هوش مصنوعی انجام می شود اعتماد دارید؟",
|
|
|
|
| 850 |
st.warning("لطفاً به سوال تکمیلی چهارم پاسخ دهید")
|
| 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():
|