Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1194,6 +1194,7 @@ def random_likert_questions():
|
|
| 1194 |
st.rerun()
|
| 1195 |
|
| 1196 |
def explanation_questions():
|
|
|
|
| 1197 |
st.markdown("### 📋 سوالات تکمیلی")
|
| 1198 |
|
| 1199 |
questions = [
|
|
@@ -1239,11 +1240,13 @@ def explanation_questions():
|
|
| 1239 |
}
|
| 1240 |
]
|
| 1241 |
|
|
|
|
| 1242 |
if "explanation_step" not in st.session_state:
|
| 1243 |
st.session_state.explanation_step = 0
|
| 1244 |
|
| 1245 |
step = st.session_state.explanation_step
|
| 1246 |
|
|
|
|
| 1247 |
if step >= len(questions):
|
| 1248 |
st.session_state.current_page = "demographic"
|
| 1249 |
st.rerun()
|
|
@@ -1251,29 +1254,30 @@ def explanation_questions():
|
|
| 1251 |
|
| 1252 |
current_q = questions[step]
|
| 1253 |
|
| 1254 |
-
# اگر شرط
|
| 1255 |
if "condition" in current_q and not current_q["condition"]():
|
|
|
|
| 1256 |
st.session_state.explanation_step += 1
|
| 1257 |
st.rerun()
|
| 1258 |
return
|
| 1259 |
|
|
|
|
| 1260 |
st.radio(
|
| 1261 |
current_q["label"],
|
| 1262 |
current_q["options"],
|
| 1263 |
index=None,
|
| 1264 |
-
key=
|
| 1265 |
)
|
| 1266 |
|
|
|
|
| 1267 |
if st.button("ادامه", key=f"continue_{step}"):
|
| 1268 |
-
|
| 1269 |
-
if
|
| 1270 |
st.warning("لطفاً یک گزینه را انتخاب کنید")
|
| 1271 |
else:
|
| 1272 |
-
|
| 1273 |
-
st.session_state[logical_key] = response
|
| 1274 |
st.session_state.explanation_step += 1
|
| 1275 |
st.rerun()
|
| 1276 |
-
|
| 1277 |
|
| 1278 |
def demographic_form():
|
| 1279 |
"""فرم اطلاعات دموگرافیک"""
|
|
|
|
| 1194 |
st.rerun()
|
| 1195 |
|
| 1196 |
def explanation_questions():
|
| 1197 |
+
"""نمایش سوالات تکمیلی به صورت مرحلهای با دکمه ادامه"""
|
| 1198 |
st.markdown("### 📋 سوالات تکمیلی")
|
| 1199 |
|
| 1200 |
questions = [
|
|
|
|
| 1240 |
}
|
| 1241 |
]
|
| 1242 |
|
| 1243 |
+
# مرحله فعلی
|
| 1244 |
if "explanation_step" not in st.session_state:
|
| 1245 |
st.session_state.explanation_step = 0
|
| 1246 |
|
| 1247 |
step = st.session_state.explanation_step
|
| 1248 |
|
| 1249 |
+
# اگر همه سوالها پاسخ داده شدن
|
| 1250 |
if step >= len(questions):
|
| 1251 |
st.session_state.current_page = "demographic"
|
| 1252 |
st.rerun()
|
|
|
|
| 1254 |
|
| 1255 |
current_q = questions[step]
|
| 1256 |
|
| 1257 |
+
# اگر شرط نمایش برقرار نیست (مثل سوال آخر فقط در صورت بله)
|
| 1258 |
if "condition" in current_q and not current_q["condition"]():
|
| 1259 |
+
st.session_state[current_q["logical_key"]] = "N/A"
|
| 1260 |
st.session_state.explanation_step += 1
|
| 1261 |
st.rerun()
|
| 1262 |
return
|
| 1263 |
|
| 1264 |
+
# نمایش سوال فعلی
|
| 1265 |
st.radio(
|
| 1266 |
current_q["label"],
|
| 1267 |
current_q["options"],
|
| 1268 |
index=None,
|
| 1269 |
+
key=f"explanation_ui_{step}"
|
| 1270 |
)
|
| 1271 |
|
| 1272 |
+
# دکمه ادامه
|
| 1273 |
if st.button("ادامه", key=f"continue_{step}"):
|
| 1274 |
+
value = st.session_state.get(f"explanation_ui_{step}")
|
| 1275 |
+
if value is None:
|
| 1276 |
st.warning("لطفاً یک گزینه را انتخاب کنید")
|
| 1277 |
else:
|
| 1278 |
+
st.session_state[current_q["logical_key"]] = value
|
|
|
|
| 1279 |
st.session_state.explanation_step += 1
|
| 1280 |
st.rerun()
|
|
|
|
| 1281 |
|
| 1282 |
def demographic_form():
|
| 1283 |
"""فرم اطلاعات دموگرافیک"""
|