Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -808,58 +808,71 @@ def enhanced_likert_scale(question_data):
|
|
| 808 |
if selected_value is not None:
|
| 809 |
st.session_state[key] = selected_value
|
| 810 |
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
<style>
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
|
|
|
|
|
|
|
|
|
| 850 |
</style>
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
|
|
|
|
|
|
| 860 |
)
|
| 861 |
|
| 862 |
-
# نمایش
|
| 863 |
status = f"پاسخ شما: {st.session_state[key]}" if st.session_state.get(key) else "پاسخ شما: هنوز انتخاب نشده"
|
| 864 |
st.markdown(f"<p style='text-align:right; color:#6a0dad; direction: rtl; margin-top:10px;'>{status}</p>",
|
| 865 |
unsafe_allow_html=True)
|
|
|
|
| 808 |
if selected_value is not None:
|
| 809 |
st.session_state[key] = selected_value
|
| 810 |
|
| 811 |
+
# ایجاد دکمههای سفارشی با JavaScript اختصاصی
|
| 812 |
+
components.html(
|
| 813 |
+
f"""
|
| 814 |
+
<script>
|
| 815 |
+
function selectOption(value) {{
|
| 816 |
+
const radioInput = parent.document.querySelector('input[type="radio"][value="' + value + '"]');
|
| 817 |
+
if (radioInput) {{
|
| 818 |
+
radioInput.click();
|
| 819 |
+
}}
|
| 820 |
+
}}
|
| 821 |
+
</script>
|
| 822 |
+
|
| 823 |
<style>
|
| 824 |
+
.likert-container {{
|
| 825 |
+
display: flex;
|
| 826 |
+
justify-content: space-between;
|
| 827 |
+
width: 100%;
|
| 828 |
+
max-width: 475px;
|
| 829 |
+
margin: 0 auto;
|
| 830 |
+
direction: rtl;
|
| 831 |
+
}}
|
| 832 |
+
.likert-option {{
|
| 833 |
+
width: 32px;
|
| 834 |
+
height: 32px;
|
| 835 |
+
border-radius: 50%;
|
| 836 |
+
background: white;
|
| 837 |
+
border: 2px solid #6a0dad;
|
| 838 |
+
display: flex;
|
| 839 |
+
align-items: center;
|
| 840 |
+
justify-content: center;
|
| 841 |
+
cursor: pointer;
|
| 842 |
+
margin: 0 2px;
|
| 843 |
+
transition: all 0.2s;
|
| 844 |
+
}}
|
| 845 |
+
.likert-option:hover {{
|
| 846 |
+
transform: scale(1.1);
|
| 847 |
+
box-shadow: 0 0 8px rgba(106, 13, 173, 0.3);
|
| 848 |
+
}}
|
| 849 |
+
.likert-option.selected {{
|
| 850 |
+
background: #6a0dad;
|
| 851 |
+
}}
|
| 852 |
+
.likert-number {{
|
| 853 |
+
color: #6a0dad;
|
| 854 |
+
font-weight: bold;
|
| 855 |
+
font-size: 14px;
|
| 856 |
+
user-select: none;
|
| 857 |
+
}}
|
| 858 |
+
.likert-option.selected .likert-number {{
|
| 859 |
+
color: white;
|
| 860 |
+
}}
|
| 861 |
</style>
|
| 862 |
+
|
| 863 |
+
<div class="likert-container">
|
| 864 |
+
{"".join([
|
| 865 |
+
f'<div class="likert-option {"selected" if st.session_state.get(key) == i+1 else ""}" onclick="selectOption({i+1})">'
|
| 866 |
+
f'<span class="likert-number">{i+1}</span>'
|
| 867 |
+
'</div>'
|
| 868 |
+
for i in range(scale)
|
| 869 |
+
])}
|
| 870 |
+
</div>
|
| 871 |
+
""",
|
| 872 |
+
height=50
|
| 873 |
)
|
| 874 |
|
| 875 |
+
# نمایش وضعیت انتخاب
|
| 876 |
status = f"پاسخ شما: {st.session_state[key]}" if st.session_state.get(key) else "پاسخ شما: هنوز انتخاب نشده"
|
| 877 |
st.markdown(f"<p style='text-align:right; color:#6a0dad; direction: rtl; margin-top:10px;'>{status}</p>",
|
| 878 |
unsafe_allow_html=True)
|