Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -783,18 +783,37 @@ def enhanced_likert_scale(question_data):
|
|
| 783 |
st.markdown(f"<div style='text-align:right; font-weight:bold; margin-bottom:15px; direction: rtl;'>{question}</div>",
|
| 784 |
unsafe_allow_html=True)
|
| 785 |
|
| 786 |
-
# نمایش برچسبها
|
| 787 |
middle_label = ""
|
| 788 |
if scale % 2 == 1: # اگر مقیاس فرد باشد
|
| 789 |
middle_value = (scale // 2) + 1
|
| 790 |
-
middle_label = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 791 |
|
| 792 |
st.markdown(
|
| 793 |
f"""
|
| 794 |
-
<div style='
|
| 795 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 796 |
{middle_label}
|
| 797 |
-
<
|
|
|
|
|
|
|
|
|
|
| 798 |
</div>
|
| 799 |
""",
|
| 800 |
unsafe_allow_html=True
|
|
@@ -838,12 +857,15 @@ def enhanced_likert_scale(question_data):
|
|
| 838 |
</script>
|
| 839 |
"""
|
| 840 |
|
| 841 |
-
# ایجاد دکمههای سفارشی با
|
| 842 |
options_html = "".join([
|
|
|
|
| 843 |
f'<div class="likert-option {"selected" if st.session_state.get(key) == i+1 else ""}" '
|
| 844 |
f'onclick="handleLikertClick({i})">'
|
| 845 |
f'<span class="likert-number">{i+1}</span>'
|
| 846 |
-
'</div>'
|
|
|
|
|
|
|
| 847 |
for i in range(scale)
|
| 848 |
])
|
| 849 |
|
|
@@ -859,6 +881,12 @@ def enhanced_likert_scale(question_data):
|
|
| 859 |
max-width: 475px;
|
| 860 |
margin: 0 auto;
|
| 861 |
direction: rtl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 862 |
}}
|
| 863 |
.likert-option {{
|
| 864 |
width: 36px;
|
|
@@ -873,6 +901,7 @@ def enhanced_likert_scale(question_data):
|
|
| 873 |
margin: 0 3px;
|
| 874 |
transition: all 0.2s;
|
| 875 |
position: relative;
|
|
|
|
| 876 |
}}
|
| 877 |
.likert-option:hover {{
|
| 878 |
transform: scale(1.1);
|
|
@@ -891,22 +920,20 @@ def enhanced_likert_scale(question_data):
|
|
| 891 |
.likert-option.selected .likert-number {{
|
| 892 |
color: white;
|
| 893 |
}}
|
| 894 |
-
|
| 895 |
-
.likert-option.middle-option::after {{
|
| 896 |
-
content: "متوسط";
|
| 897 |
position: absolute;
|
| 898 |
bottom: -25px;
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
}}
|
| 904 |
</style>
|
| 905 |
<div class="likert-container">
|
| 906 |
{options_html}
|
| 907 |
</div>
|
| 908 |
""",
|
| 909 |
-
height=
|
| 910 |
)
|
| 911 |
|
| 912 |
# نمایش وضعیت انتخاب با استایل بهبود یافته
|
|
@@ -917,7 +944,7 @@ def enhanced_likert_scale(question_data):
|
|
| 917 |
text-align: right;
|
| 918 |
color: #6a0dad;
|
| 919 |
direction: rtl;
|
| 920 |
-
margin-top:
|
| 921 |
padding: 10px;
|
| 922 |
background-color: #f8f0ff;
|
| 923 |
border-radius: 8px;
|
|
|
|
| 783 |
st.markdown(f"<div style='text-align:right; font-weight:bold; margin-bottom:15px; direction: rtl;'>{question}</div>",
|
| 784 |
unsafe_allow_html=True)
|
| 785 |
|
| 786 |
+
# نمایش برچسبها با خطوط راهنما
|
| 787 |
middle_label = ""
|
| 788 |
if scale % 2 == 1: # اگر مقیاس فرد باشد
|
| 789 |
middle_value = (scale // 2) + 1
|
| 790 |
+
middle_label = f"""
|
| 791 |
+
<div style='position: absolute; left: 50%; transform: translateX(-50%);'>
|
| 792 |
+
<span style='font-size: 14px; font-weight: bold; color: #6a0dad;'>متوسط</span>
|
| 793 |
+
<div style='height: 15px; width: 2px; background: #6a0dad; margin: 2px auto;'></div>
|
| 794 |
+
</div>
|
| 795 |
+
"""
|
| 796 |
|
| 797 |
st.markdown(
|
| 798 |
f"""
|
| 799 |
+
<div style='
|
| 800 |
+
display: flex;
|
| 801 |
+
justify-content: space-between;
|
| 802 |
+
max-width: 475px;
|
| 803 |
+
margin: 0 auto 25px;
|
| 804 |
+
direction: rtl;
|
| 805 |
+
position: relative;
|
| 806 |
+
height: 30px;
|
| 807 |
+
'>
|
| 808 |
+
<div style='position: absolute; right: 0; text-align: center;'>
|
| 809 |
+
<span style='font-size: 14px; font-weight: bold; color: #6a0dad;'>{labels[0]}</span>
|
| 810 |
+
<div style='height: 15px; width: 2px; background: #6a0dad; margin: 2px auto;'></div>
|
| 811 |
+
</div>
|
| 812 |
{middle_label}
|
| 813 |
+
<div style='position: absolute; left: 0; text-align: center;'>
|
| 814 |
+
<span style='font-size: 14px; font-weight: bold; color: #6a0dad;'>{labels[1]}</span>
|
| 815 |
+
<div style='height: 15px; width: 2px; background: #6a0dad; margin: 2px auto;'></div>
|
| 816 |
+
</div>
|
| 817 |
</div>
|
| 818 |
""",
|
| 819 |
unsafe_allow_html=True
|
|
|
|
| 857 |
</script>
|
| 858 |
"""
|
| 859 |
|
| 860 |
+
# ایجاد دکمههای سفارشی با خطوط راهنما
|
| 861 |
options_html = "".join([
|
| 862 |
+
f'<div class="likert-option-container" style="position: relative;">'
|
| 863 |
f'<div class="likert-option {"selected" if st.session_state.get(key) == i+1 else ""}" '
|
| 864 |
f'onclick="handleLikertClick({i})">'
|
| 865 |
f'<span class="likert-number">{i+1}</span>'
|
| 866 |
+
f'</div>'
|
| 867 |
+
f'{"<div class=\'likert-guide-line\'></div>" if i+1 == 1 or i+1 == scale or (scale % 2 == 1 and i+1 == Math.ceil(scale/2)) else ""}'
|
| 868 |
+
f'</div>'
|
| 869 |
for i in range(scale)
|
| 870 |
])
|
| 871 |
|
|
|
|
| 881 |
max-width: 475px;
|
| 882 |
margin: 0 auto;
|
| 883 |
direction: rtl;
|
| 884 |
+
position: relative;
|
| 885 |
+
}}
|
| 886 |
+
.likert-option-container {{
|
| 887 |
+
display: flex;
|
| 888 |
+
flex-direction: column;
|
| 889 |
+
align-items: center;
|
| 890 |
}}
|
| 891 |
.likert-option {{
|
| 892 |
width: 36px;
|
|
|
|
| 901 |
margin: 0 3px;
|
| 902 |
transition: all 0.2s;
|
| 903 |
position: relative;
|
| 904 |
+
z-index: 2;
|
| 905 |
}}
|
| 906 |
.likert-option:hover {{
|
| 907 |
transform: scale(1.1);
|
|
|
|
| 920 |
.likert-option.selected .likert-number {{
|
| 921 |
color: white;
|
| 922 |
}}
|
| 923 |
+
.likert-guide-line {{
|
|
|
|
|
|
|
| 924 |
position: absolute;
|
| 925 |
bottom: -25px;
|
| 926 |
+
height: 15px;
|
| 927 |
+
width: 2px;
|
| 928 |
+
background: #6a0dad;
|
| 929 |
+
z-index: 1;
|
| 930 |
}}
|
| 931 |
</style>
|
| 932 |
<div class="likert-container">
|
| 933 |
{options_html}
|
| 934 |
</div>
|
| 935 |
""",
|
| 936 |
+
height=100 # افزایش ارتفاع برای جا دادن خطوط راهنما
|
| 937 |
)
|
| 938 |
|
| 939 |
# نمایش وضعیت انتخاب با استایل بهبود یافته
|
|
|
|
| 944 |
text-align: right;
|
| 945 |
color: #6a0dad;
|
| 946 |
direction: rtl;
|
| 947 |
+
margin-top: 30px;
|
| 948 |
padding: 10px;
|
| 949 |
background-color: #f8f0ff;
|
| 950 |
border-radius: 8px;
|