Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1195,15 +1195,14 @@ def random_likert_questions():
|
|
| 1195 |
|
| 1196 |
|
| 1197 |
def explanation_questions():
|
| 1198 |
-
"""نمایش سوالات تکمیلی به صورت مرحلهای"""
|
| 1199 |
st.markdown("### 📋 سوالات تکمیلی")
|
| 1200 |
|
| 1201 |
-
# لیست سوالات و کلید آنها
|
| 1202 |
questions = [
|
| 1203 |
{
|
| 1204 |
-
"key": "
|
| 1205 |
-
"label": "آیا
|
| 1206 |
-
"options": ["بله", "خیر", "ن
|
| 1207 |
},
|
| 1208 |
{
|
| 1209 |
"key": "pricing_method_radio",
|
|
@@ -1216,9 +1215,9 @@ def explanation_questions():
|
|
| 1216 |
]
|
| 1217 |
},
|
| 1218 |
{
|
| 1219 |
-
"key": "
|
| 1220 |
-
"label": "آیا
|
| 1221 |
-
"options": ["بله", "خیر", "
|
| 1222 |
},
|
| 1223 |
{
|
| 1224 |
"key": "explanation_received_radio",
|
|
@@ -1246,14 +1245,14 @@ def explanation_questions():
|
|
| 1246 |
if current_step < len(questions):
|
| 1247 |
q = questions[current_step]
|
| 1248 |
|
| 1249 |
-
# شرط نمایش
|
| 1250 |
if "condition" in q and not q["condition"]():
|
| 1251 |
st.session_state.explanation_step += 1
|
| 1252 |
st.rerun()
|
| 1253 |
return
|
| 1254 |
|
| 1255 |
# نمایش سوال فعلی
|
| 1256 |
-
st.radio(
|
| 1257 |
q["label"],
|
| 1258 |
q["options"],
|
| 1259 |
index=None,
|
|
@@ -1261,14 +1260,15 @@ def explanation_questions():
|
|
| 1261 |
)
|
| 1262 |
|
| 1263 |
if st.button("ادامه", key=f"continue_{current_step}"):
|
| 1264 |
-
if
|
| 1265 |
st.warning("لطفاً یک گزینه را انتخاب کنید")
|
| 1266 |
else:
|
|
|
|
|
|
|
| 1267 |
st.session_state.explanation_step += 1
|
| 1268 |
st.rerun()
|
| 1269 |
else:
|
| 1270 |
-
#
|
| 1271 |
-
# ذخیره نهایی دادهها
|
| 1272 |
st.session_state.trust = st.session_state.get("trust_radio")
|
| 1273 |
st.session_state.pricing_method = st.session_state.get("pricing_method_radio")
|
| 1274 |
st.session_state.price_increase = st.session_state.get("price_increase_radio")
|
|
@@ -1276,8 +1276,11 @@ def explanation_questions():
|
|
| 1276 |
st.session_state.explanation_type = (
|
| 1277 |
st.session_state.get("explanation_type_radio") if st.session_state.explanation_received == "بله" else "N/A"
|
| 1278 |
)
|
|
|
|
|
|
|
| 1279 |
st.session_state.current_page = "demographic"
|
| 1280 |
st.rerun()
|
|
|
|
| 1281 |
|
| 1282 |
def demographic_form():
|
| 1283 |
"""فرم اطلاعات دموگرافیک"""
|
|
|
|
| 1195 |
|
| 1196 |
|
| 1197 |
def explanation_questions():
|
| 1198 |
+
"""نمایش سوالات تکمیلی به صورت مرحلهای (و ذخیرهی مرحلهای)"""
|
| 1199 |
st.markdown("### 📋 سوالات تکمیلی")
|
| 1200 |
|
|
|
|
| 1201 |
questions = [
|
| 1202 |
{
|
| 1203 |
+
"key": "price_increase_radio",
|
| 1204 |
+
"label": "آیا به نظر شما در این سفر افزایش قیمت نسبت به حالت طبیعی وجود داشته است؟",
|
| 1205 |
+
"options": ["بله", "خیر", "مطمئن نیستم"]
|
| 1206 |
},
|
| 1207 |
{
|
| 1208 |
"key": "pricing_method_radio",
|
|
|
|
| 1215 |
]
|
| 1216 |
},
|
| 1217 |
{
|
| 1218 |
+
"key": "trust_radio",
|
| 1219 |
+
"label": "آیا شما به تصمیم گیری هایی که توسط هوش مصنوعی انجام می شود اعتماد دارید؟",
|
| 1220 |
+
"options": ["بله", "خیر", "نظری ندارم"]
|
| 1221 |
},
|
| 1222 |
{
|
| 1223 |
"key": "explanation_received_radio",
|
|
|
|
| 1245 |
if current_step < len(questions):
|
| 1246 |
q = questions[current_step]
|
| 1247 |
|
| 1248 |
+
# بررسی شرط نمایش
|
| 1249 |
if "condition" in q and not q["condition"]():
|
| 1250 |
st.session_state.explanation_step += 1
|
| 1251 |
st.rerun()
|
| 1252 |
return
|
| 1253 |
|
| 1254 |
# نمایش سوال فعلی
|
| 1255 |
+
response = st.radio(
|
| 1256 |
q["label"],
|
| 1257 |
q["options"],
|
| 1258 |
index=None,
|
|
|
|
| 1260 |
)
|
| 1261 |
|
| 1262 |
if st.button("ادامه", key=f"continue_{current_step}"):
|
| 1263 |
+
if response is None:
|
| 1264 |
st.warning("لطفاً یک گزینه را انتخاب کنید")
|
| 1265 |
else:
|
| 1266 |
+
# ذخیره پاسخ (مطمئن شو که همیشه ذخیره میشه)
|
| 1267 |
+
st.session_state[q["key"]] = response
|
| 1268 |
st.session_state.explanation_step += 1
|
| 1269 |
st.rerun()
|
| 1270 |
else:
|
| 1271 |
+
# مرحله آخر: ذخیره در session_state برای استفاده بعدی
|
|
|
|
| 1272 |
st.session_state.trust = st.session_state.get("trust_radio")
|
| 1273 |
st.session_state.pricing_method = st.session_state.get("pricing_method_radio")
|
| 1274 |
st.session_state.price_increase = st.session_state.get("price_increase_radio")
|
|
|
|
| 1276 |
st.session_state.explanation_type = (
|
| 1277 |
st.session_state.get("explanation_type_radio") if st.session_state.explanation_received == "بله" else "N/A"
|
| 1278 |
)
|
| 1279 |
+
|
| 1280 |
+
# رفتن به صفحه بعدی
|
| 1281 |
st.session_state.current_page = "demographic"
|
| 1282 |
st.rerun()
|
| 1283 |
+
|
| 1284 |
|
| 1285 |
def demographic_form():
|
| 1286 |
"""فرم اطلاعات دموگرافیک"""
|