Update app.py
Browse files
app.py
CHANGED
|
@@ -248,7 +248,7 @@ def handle_agree_and_start(name, gender, age, education, request: gr.Request):
|
|
| 248 |
# 简单验证
|
| 249 |
error_messages_list = []
|
| 250 |
if not name or str(name).strip() == "":
|
| 251 |
-
error_messages_list.append("
|
| 252 |
|
| 253 |
# 对于 Radio 和 Dropdown,如果初始没有值且用户未选择,它们可能返回 None
|
| 254 |
if gender is None or str(gender).strip() == "": # Radio 可能返回None或空字符串
|
|
@@ -265,7 +265,7 @@ def handle_agree_and_start(name, gender, age, education, request: gr.Request):
|
|
| 265 |
except (ValueError, TypeError):
|
| 266 |
error_messages_list.append("年龄必须是一个有效的数字。")
|
| 267 |
|
| 268 |
-
if education is None or str(education).strip() == "": # Dropdown 可能返回None或空字符串
|
| 269 |
error_messages_list.append("学历 必须选择。")
|
| 270 |
|
| 271 |
if error_messages_list:
|
|
@@ -320,7 +320,7 @@ with gr.Blocks(css=CSS, title="图像重建主观评估") as demo:
|
|
| 320 |
user_age_input = gr.Number(label="年龄 (请输入整数)", minimum=1, maximum=120, step=1)
|
| 321 |
user_education_input = gr.Dropdown(
|
| 322 |
label="学历",
|
| 323 |
-
choices=["初中及以下","高中(含在读)", "大专(含在读)", "本科(含在读)", "硕士(含在读)", "博士(含在读)"
|
| 324 |
)
|
| 325 |
welcome_error_msg = gr.Markdown(value="") # 用于显示欢迎页的错误信息
|
| 326 |
btn_agree_and_start = gr.Button("我已阅读上述说明并同意参与实验")
|
|
|
|
| 248 |
# 简单验证
|
| 249 |
error_messages_list = []
|
| 250 |
if not name or str(name).strip() == "":
|
| 251 |
+
error_messages_list.append("姓名 不能为空。")
|
| 252 |
|
| 253 |
# 对于 Radio 和 Dropdown,如果初始没有值且用户未选择,它们可能返回 None
|
| 254 |
if gender is None or str(gender).strip() == "": # Radio 可能返回None或空字符串
|
|
|
|
| 265 |
except (ValueError, TypeError):
|
| 266 |
error_messages_list.append("年龄必须是一个有效的数字。")
|
| 267 |
|
| 268 |
+
if education is None or str(education).strip() == "其他": # Dropdown 可能返回None或空字符串
|
| 269 |
error_messages_list.append("学历 必须选择。")
|
| 270 |
|
| 271 |
if error_messages_list:
|
|
|
|
| 320 |
user_age_input = gr.Number(label="年龄 (请输入整数)", minimum=1, maximum=120, step=1)
|
| 321 |
user_education_input = gr.Dropdown(
|
| 322 |
label="学历",
|
| 323 |
+
choices=["其他","初中及以下","高中(含在读)", "大专(含在读)", "本科(含在读)", "硕士(含在读)", "博士(含在读)"]
|
| 324 |
)
|
| 325 |
welcome_error_msg = gr.Markdown(value="") # 用于显示欢迎页的错误信息
|
| 326 |
btn_agree_and_start = gr.Button("我已阅读上述说明并同意参与实验")
|