Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1314,17 +1314,18 @@ def random_likert_questions():
|
|
| 1314 |
]
|
| 1315 |
}
|
| 1316 |
]
|
| 1317 |
-
# مقداردهی اولیه
|
| 1318 |
if 'current_likert_group' not in st.session_state:
|
| 1319 |
st.session_state.current_likert_group = 0
|
| 1320 |
-
|
|
|
|
|
|
|
| 1321 |
current_group = question_groups[st.session_state.current_likert_group]
|
| 1322 |
-
|
| 1323 |
-
|
| 1324 |
-
|
| 1325 |
-
|
| 1326 |
-
|
| 1327 |
-
# ترکیب CSS و HTML با جایگذاری امن
|
| 1328 |
guide_html = textwrap.dedent("""
|
| 1329 |
<div class="guide-text" style="
|
| 1330 |
display: flex;
|
|
@@ -1339,39 +1340,35 @@ def random_likert_questions():
|
|
| 1339 |
{}
|
| 1340 |
</div>
|
| 1341 |
""").format(current_group['guide'])
|
| 1342 |
-
|
| 1343 |
st.markdown(guide_html, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1344 |
|
| 1345 |
-
#
|
| 1346 |
-
|
| 1347 |
-
|
| 1348 |
-
st.session_state.
|
| 1349 |
-
|
| 1350 |
-
# دکمه ادامه/اتمام
|
| 1351 |
-
button_label = "ادامه" if st.session_state.current_likert_group < len(question_groups)-1 else "ادامه"
|
| 1352 |
-
|
| 1353 |
-
if st.button(button_label):
|
| 1354 |
-
# بررسی آیا همه سوالات این گروه پاسخ داده شدهاند و هیچ کدام صفر نیستند
|
| 1355 |
-
all_answered = all(
|
| 1356 |
-
question["key"] in st.session_state.answers and
|
| 1357 |
-
st.session_state.answers[question["key"]] is not None
|
| 1358 |
-
for question in current_group['questions']
|
| 1359 |
-
)
|
| 1360 |
|
| 1361 |
-
|
| 1362 |
-
|
| 1363 |
-
for question in current_group['questions']
|
| 1364 |
-
)
|
| 1365 |
|
| 1366 |
-
|
| 1367 |
-
|
|
|
|
| 1368 |
else:
|
| 1369 |
-
|
| 1370 |
-
|
| 1371 |
-
|
| 1372 |
-
|
|
|
|
|
|
|
|
|
|
| 1373 |
st.session_state.current_page = "explanation_questions"
|
| 1374 |
-
|
|
|
|
| 1375 |
|
| 1376 |
|
| 1377 |
def explanation_questions():
|
|
|
|
| 1314 |
]
|
| 1315 |
}
|
| 1316 |
]
|
| 1317 |
+
# مقداردهی اولیه
|
| 1318 |
if 'current_likert_group' not in st.session_state:
|
| 1319 |
st.session_state.current_likert_group = 0
|
| 1320 |
+
st.session_state.current_question_index = 0
|
| 1321 |
+
st.session_state.show_guide = True
|
| 1322 |
+
|
| 1323 |
current_group = question_groups[st.session_state.current_likert_group]
|
| 1324 |
+
current_question = current_group['questions'][st.session_state.current_question_index]
|
| 1325 |
+
|
| 1326 |
+
# نمایش راهنما فقط برای اولین سوال هر گروه
|
| 1327 |
+
if st.session_state.show_guide and 'guide' in current_group:
|
| 1328 |
+
st.markdown(f"## {current_group['title']}")
|
|
|
|
| 1329 |
guide_html = textwrap.dedent("""
|
| 1330 |
<div class="guide-text" style="
|
| 1331 |
display: flex;
|
|
|
|
| 1340 |
{}
|
| 1341 |
</div>
|
| 1342 |
""").format(current_group['guide'])
|
|
|
|
| 1343 |
st.markdown(guide_html, unsafe_allow_html=True)
|
| 1344 |
+
else:
|
| 1345 |
+
st.markdown(f"## {current_group['title']}")
|
| 1346 |
+
|
| 1347 |
+
# نمایش سوال جاری
|
| 1348 |
+
answer = enhanced_likert_scale(current_question)
|
| 1349 |
|
| 1350 |
+
# اگر پاسخ داده شد، به سوال بعدی برو
|
| 1351 |
+
if answer is not None:
|
| 1352 |
+
st.session_state.answers[current_question["key"]] = answer
|
| 1353 |
+
st.session_state.show_guide = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1354 |
|
| 1355 |
+
# تاخیر برای نمایش پاسخ قبل از رفتن به سوال بعدی
|
| 1356 |
+
time.sleep(0.5)
|
|
|
|
|
|
|
| 1357 |
|
| 1358 |
+
# بررسی آیا سوالات این گروه تمام شده یا نه
|
| 1359 |
+
if st.session_state.current_question_index < len(current_group['questions']) - 1:
|
| 1360 |
+
st.session_state.current_question_index += 1
|
| 1361 |
else:
|
| 1362 |
+
# رفتن به گروه بعدی
|
| 1363 |
+
st.session_state.current_likert_group += 1
|
| 1364 |
+
st.session_state.current_question_index = 0
|
| 1365 |
+
st.session_state.show_guide = True
|
| 1366 |
+
|
| 1367 |
+
# اگر همه گروهها تمام شدند، به صفحه بعدی برو
|
| 1368 |
+
if st.session_state.current_likert_group >= len(question_groups):
|
| 1369 |
st.session_state.current_page = "explanation_questions"
|
| 1370 |
+
|
| 1371 |
+
st.rerun()
|
| 1372 |
|
| 1373 |
|
| 1374 |
def explanation_questions():
|