Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -826,16 +826,15 @@ def enhanced_likert_scale(question_data):
|
|
| 826 |
|
| 827 |
# نمایش کامپوننت HTML
|
| 828 |
components.html(scale_html, height=60)
|
| 829 |
-
|
| 830 |
-
# ورودی عددی با محدوده 0 تا scale
|
| 831 |
value = st.number_input(
|
| 832 |
"پاسخ شما (از 1 تا 7):",
|
| 833 |
min_value=0,
|
| 834 |
max_value=scale,
|
| 835 |
-
value=st.session_state.get(key),
|
| 836 |
step=1,
|
| 837 |
key=f"{key}_input",
|
| 838 |
-
placeholder="
|
| 839 |
format="%d",
|
| 840 |
on_change=lambda: st.session_state.update({key: st.session_state[f"{key}_input"]})
|
| 841 |
)
|
|
@@ -919,46 +918,6 @@ def show_explanation(exp_type):
|
|
| 919 |
for item in explanations.get(exp_type, []):
|
| 920 |
st.markdown(f"<p class='explanation-item'>• {item}</p>", unsafe_allow_html=True)
|
| 921 |
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
def create_likert_question(question, key, scale_type="5point"):
|
| 926 |
-
"""نمایش سوال لیکرت با اسلایدر نقطهای"""
|
| 927 |
-
left_label = "کاملاً مخالفم" if scale_type == "7point" else "کاملاً مخالفم"
|
| 928 |
-
right_label = "کاملاً موافقم" if scale_type == "7point" else "کاملاً موافقم"
|
| 929 |
-
|
| 930 |
-
st.markdown(f"<p style='font-size:16px; margin-bottom:5px;'>{question}</p>", unsafe_allow_html=True)
|
| 931 |
-
|
| 932 |
-
max_value = 7 if scale_type == "7point" else 5
|
| 933 |
-
|
| 934 |
-
# اضافه کردن attribute برای انتخاب استایل مناسب
|
| 935 |
-
slider_container = st.empty()
|
| 936 |
-
with slider_container:
|
| 937 |
-
st.markdown(f'<div data-testid="stSlider" data-discrete="{"seven-point" if scale_type=="7point" else "five-point"}">', unsafe_allow_html=True)
|
| 938 |
-
value = st.slider(
|
| 939 |
-
"",
|
| 940 |
-
min_value=1,
|
| 941 |
-
max_value=max_value,
|
| 942 |
-
value=(max_value+1)//2,
|
| 943 |
-
step=1,
|
| 944 |
-
key=f"slider_{key}"
|
| 945 |
-
)
|
| 946 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 947 |
-
|
| 948 |
-
st.markdown(
|
| 949 |
-
f"""
|
| 950 |
-
<div class="slider-labels">
|
| 951 |
-
<span>{left_label}</span>
|
| 952 |
-
<span>{right_label}</span>
|
| 953 |
-
</div>
|
| 954 |
-
<p style='text-align:center; color:#6a0dad; font-weight:bold;'>
|
| 955 |
-
پاسخ شما: {value} ({'کاملاً مخالفم' if value==1 else 'کاملاً موافقم' if value==max_value else 'خنثی' if value==((max_value+1)//2) else 'موافقم' if value>((max_value+1)//2) else 'مخالفم'})
|
| 956 |
-
</p>
|
| 957 |
-
""",
|
| 958 |
-
unsafe_allow_html=True
|
| 959 |
-
)
|
| 960 |
-
return value
|
| 961 |
-
|
| 962 |
# ========== توابع مدیریت دادهها ==========
|
| 963 |
|
| 964 |
def get_credentials():
|
|
|
|
| 826 |
|
| 827 |
# نمایش کامپوننت HTML
|
| 828 |
components.html(scale_html, height=60)
|
| 829 |
+
# ورودی عددی
|
|
|
|
| 830 |
value = st.number_input(
|
| 831 |
"پاسخ شما (از 1 تا 7):",
|
| 832 |
min_value=0,
|
| 833 |
max_value=scale,
|
| 834 |
+
value=st.session_state.get(key) if st.session_state.get(key) is not None else 0, # مقدار پیشفرض 0
|
| 835 |
step=1,
|
| 836 |
key=f"{key}_input",
|
| 837 |
+
placeholder="از 1 (کمترین) تا 7 (بیشترین)",
|
| 838 |
format="%d",
|
| 839 |
on_change=lambda: st.session_state.update({key: st.session_state[f"{key}_input"]})
|
| 840 |
)
|
|
|
|
| 918 |
for item in explanations.get(exp_type, []):
|
| 919 |
st.markdown(f"<p class='explanation-item'>• {item}</p>", unsafe_allow_html=True)
|
| 920 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 921 |
# ========== توابع مدیریت دادهها ==========
|
| 922 |
|
| 923 |
def get_credentials():
|