Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -739,54 +739,73 @@ h3 {
|
|
| 739 |
|
| 740 |
# ========== توابع اصلی ==========
|
| 741 |
def enhanced_likert_scale(question_data):
|
| 742 |
-
"""لیکرت اسکیل
|
| 743 |
question = question_data["question"]
|
| 744 |
key = question_data["key"]
|
| 745 |
scale = question_data["scale"]
|
| 746 |
labels = question_data.get("labels", ["کاملاً مخالفم", "کاملاً موافقم"])
|
| 747 |
|
| 748 |
-
# مقداردهی اولیه
|
| 749 |
if key not in st.session_state:
|
| 750 |
st.session_state[key] = None
|
| 751 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
# نمایش سوال
|
| 753 |
st.markdown(f"**{question}**")
|
| 754 |
-
|
| 755 |
# نمایش برچسبها در یک ردیف
|
| 756 |
-
|
| 757 |
-
with
|
| 758 |
-
st.markdown(
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 781 |
# نمایش پاسخ انتخاب شده
|
| 782 |
-
if st.session_state.get(key)
|
| 783 |
st.markdown(
|
| 784 |
-
f"<div style='text-align:center; color:#6a0dad; font-weight:bold; margin-top:
|
| 785 |
f"پاسخ شما: {st.session_state[key]}"
|
| 786 |
f"</div>",
|
| 787 |
unsafe_allow_html=True
|
| 788 |
)
|
| 789 |
-
|
| 790 |
return st.session_state.get(key)
|
| 791 |
def create_ride_map():
|
| 792 |
"""ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
|
|
|
|
| 739 |
|
| 740 |
# ========== توابع اصلی ==========
|
| 741 |
def enhanced_likert_scale(question_data):
|
| 742 |
+
"""لیکرت اسکیل بهینهشده برای موبایل و دسکتاپ"""
|
| 743 |
question = question_data["question"]
|
| 744 |
key = question_data["key"]
|
| 745 |
scale = question_data["scale"]
|
| 746 |
labels = question_data.get("labels", ["کاملاً مخالفم", "کاملاً موافقم"])
|
| 747 |
|
|
|
|
| 748 |
if key not in st.session_state:
|
| 749 |
st.session_state[key] = None
|
| 750 |
+
|
| 751 |
+
# استایلدهی واکنشگرا
|
| 752 |
+
st.markdown(f"""
|
| 753 |
+
<style>
|
| 754 |
+
@media (max-width: 768px) {{
|
| 755 |
+
.likert-btn-container {{
|
| 756 |
+
flex-direction: column;
|
| 757 |
+
align-items: center;
|
| 758 |
+
}}
|
| 759 |
+
.likert-btn {{
|
| 760 |
+
margin: 3px 0;
|
| 761 |
+
}}
|
| 762 |
+
}}
|
| 763 |
+
</style>
|
| 764 |
+
""", unsafe_allow_html=True)
|
| 765 |
+
|
| 766 |
# نمایش سوال
|
| 767 |
st.markdown(f"**{question}**")
|
| 768 |
+
|
| 769 |
# نمایش برچسبها در یک ردیف
|
| 770 |
+
label_col = st.columns(1)[0]
|
| 771 |
+
with label_col:
|
| 772 |
+
st.markdown(
|
| 773 |
+
f"<div style='display: flex; justify-content: space-between; direction: rtl; margin-bottom: 8px;'>"
|
| 774 |
+
f"<span style='font-size: 14px; color: #555;'>{labels[1]}</span>"
|
| 775 |
+
f"<span style='font-size: 14px; color: #555;'>{labels[0]}</span>"
|
| 776 |
+
f"</div>",
|
| 777 |
+
unsafe_allow_html=True
|
| 778 |
+
)
|
| 779 |
+
|
| 780 |
+
# ایجاد دکمهها
|
| 781 |
+
btn_container = st.container()
|
| 782 |
+
with btn_container:
|
| 783 |
+
cols = st.columns(scale)
|
| 784 |
+
for i in range(scale):
|
| 785 |
+
with cols[i]:
|
| 786 |
+
value = scale - i
|
| 787 |
+
is_selected = st.session_state.get(key) == value
|
| 788 |
+
btn_type = "primary" if is_selected else "secondary"
|
| 789 |
+
|
| 790 |
+
if st.button(
|
| 791 |
+
str(value),
|
| 792 |
+
key=f"{key}_btn_{value}",
|
| 793 |
+
type=btn_type,
|
| 794 |
+
use_container_width=True,
|
| 795 |
+
help=f"مقدار: {value}"
|
| 796 |
+
):
|
| 797 |
+
st.session_state[key] = value
|
| 798 |
+
st.rerun()
|
| 799 |
+
|
| 800 |
# نمایش پاسخ انتخاب شده
|
| 801 |
+
if st.session_state.get(key):
|
| 802 |
st.markdown(
|
| 803 |
+
f"<div style='text-align: center; color: #6a0dad; font-weight: bold; margin-top: 8px;'>"
|
| 804 |
f"پاسخ شما: {st.session_state[key]}"
|
| 805 |
f"</div>",
|
| 806 |
unsafe_allow_html=True
|
| 807 |
)
|
| 808 |
+
|
| 809 |
return st.session_state.get(key)
|
| 810 |
def create_ride_map():
|
| 811 |
"""ایجاد نقشه سفر با Folium - نسخه اصلاح شده با مناطق عمومی"""
|