GSMEthesis commited on
Commit
cdf9ab8
·
verified ·
1 Parent(s): dd006d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
app.py CHANGED
@@ -1372,18 +1372,26 @@ def thank_you_page():
1372
  st.balloons()
1373
 
1374
  # ========== مدیریت وضعیت و صفحه‌بندی ==========
1375
-
1376
  def main():
1377
- # مقداردهی اولیه session_state
 
 
 
 
 
 
 
 
 
1378
  if 'current_page' not in st.session_state:
1379
  st.session_state.current_page = "welcome"
1380
- st.session_state.current_group = 0
1381
- st.session_state.current_question = 0
1382
- st.session_state.answers = {}
1383
  st.session_state.scenario_type = random.choice(["control", "input", "counterfactual"])
1384
  st.session_state.price = 200000
 
 
 
1385
 
1386
- # تعریف صفحات
1387
  pages = {
1388
  "welcome": welcome_page,
1389
  "scenario_explanation": scenario_explanation,
@@ -1391,19 +1399,12 @@ def main():
1391
  "attention_check1": attention_check1,
1392
  "random_likert_questions": random_likert_questions,
1393
  "explanation_questions": explanation_questions,
1394
- "demographic": demographic_form,
1395
- "contact": user_contact,
1396
  "thank_you": thank_you_page
1397
  }
1398
 
1399
- # نمایش صفحه جاری
1400
- try:
1401
- current_page = pages.get(st.session_state.current_page, welcome_page)
1402
- current_page()
1403
- except Exception as e:
1404
- st.error(f"خطای سیستمی: {str(e)}")
1405
- st.session_state.current_page = "welcome"
1406
- st.rerun()
1407
 
1408
  if __name__ == "__main__":
1409
  main()
 
1372
  st.balloons()
1373
 
1374
  # ========== مدیریت وضعیت و صفحه‌بندی ==========
 
1375
  def main():
1376
+ # تشخیص دستگاه
1377
+ user_agent = st.query_params.get("user_agent", [""])[0]
1378
+ st.session_state.is_desktop = "mobile" not in user_agent.lower()
1379
+
1380
+
1381
+ # اینجا می‌توانید از is_desktop برای تعیین اینکه نمایشگر موبایل اعمال شود، استفاده کنید
1382
+ if st.session_state.is_desktop:
1383
+ # اطمینان از نمایش همان حالت موبایل برای همه دستگاه‌ها
1384
+ st.session_state.is_desktop = False
1385
+
1386
  if 'current_page' not in st.session_state:
1387
  st.session_state.current_page = "welcome"
 
 
 
1388
  st.session_state.scenario_type = random.choice(["control", "input", "counterfactual"])
1389
  st.session_state.price = 200000
1390
+ st.session_state.user_contact = None
1391
+ st.session_state.demographic_data = None
1392
+ st.session_state.price_accepted = 0
1393
 
1394
+
1395
  pages = {
1396
  "welcome": welcome_page,
1397
  "scenario_explanation": scenario_explanation,
 
1399
  "attention_check1": attention_check1,
1400
  "random_likert_questions": random_likert_questions,
1401
  "explanation_questions": explanation_questions,
1402
+ "demographic": demographic_form, # دموگرافیک قبل از کانتکت
1403
+ "contact": user_contact, # کانتکت در انتها
1404
  "thank_you": thank_you_page
1405
  }
1406
 
1407
+ pages[st.session_state.current_page]()
 
 
 
 
 
 
 
1408
 
1409
  if __name__ == "__main__":
1410
  main()