Update app.py
Browse files
app.py
CHANGED
|
@@ -313,7 +313,7 @@ def handle_agree_and_start(name, gender, age, education, request: gr.Request):
|
|
| 313 |
except (ValueError, TypeError): error_messages_list.append("年龄必须是一个有效的数字。")
|
| 314 |
else:
|
| 315 |
if not (1 <= num_age <= 120): error_messages_list.append("年龄必须在 1 到 120 之间。")
|
| 316 |
-
if education is None or str(education).strip() == "": error_messages_list.append("学历 必须选择。") # 修正:如果选“其他”但希望是有效输入,这里的逻辑可能需要调整
|
| 317 |
if error_messages_list:
|
| 318 |
full_error_message = "请修正以下错误:\n" + "\n".join([f"- {msg}" for msg in error_messages_list])
|
| 319 |
print(f"用户输入验证失败: {full_error_message}")
|
|
@@ -339,7 +339,7 @@ with gr.Blocks(css=CSS, title="图像重建主观评估") as demo:
|
|
| 339 |
# ... (欢迎页UI,与您上一版代码相同) ...
|
| 340 |
gr.Markdown(welcome_page_markdown)
|
| 341 |
with gr.Row(): user_name_input = gr.Textbox(label="请输入您的姓名或代号 (例如 张三 或 User001)", placeholder="例如:张三 -> ZS"); user_gender_input = gr.Radio(label="性别", choices=["男", "女"])
|
| 342 |
-
with gr.Row(): user_age_input = gr.Number(label="年龄 (请输入1-120的整数)", minimum=1, maximum=120, step=1
|
| 343 |
welcome_error_msg = gr.Markdown(value="")
|
| 344 |
btn_agree_and_start = gr.Button("我已阅读上述说明并同意参与实验")
|
| 345 |
|
|
|
|
| 313 |
except (ValueError, TypeError): error_messages_list.append("年龄必须是一个有效的数字。")
|
| 314 |
else:
|
| 315 |
if not (1 <= num_age <= 120): error_messages_list.append("年龄必须在 1 到 120 之间。")
|
| 316 |
+
if education is None or str(education).strip() == "其他": error_messages_list.append("学历 必须选择。") # 修正:如果选“其他”但希望是有效输入,这里的逻辑可能需要调整
|
| 317 |
if error_messages_list:
|
| 318 |
full_error_message = "请修正以下错误:\n" + "\n".join([f"- {msg}" for msg in error_messages_list])
|
| 319 |
print(f"用户输入验证失败: {full_error_message}")
|
|
|
|
| 339 |
# ... (欢迎页UI,与您上一版代码相同) ...
|
| 340 |
gr.Markdown(welcome_page_markdown)
|
| 341 |
with gr.Row(): user_name_input = gr.Textbox(label="请输入您的姓名或代号 (例如 张三 或 User001)", placeholder="例如:张三 -> ZS"); user_gender_input = gr.Radio(label="性别", choices=["男", "女"])
|
| 342 |
+
with gr.Row(): user_age_input = gr.Number(label="年龄 (请输入1-120的整数)", minimum=1, maximum=120, step=1); user_education_input = gr.Dropdown(label="学历", choices=["其他","初中及以下","高中(含中专)", "大专(含在读)", "本科(含在读)", "硕士(含在读)", "博士(含在读)"])
|
| 343 |
welcome_error_msg = gr.Markdown(value="")
|
| 344 |
btn_agree_and_start = gr.Button("我已阅读上述说明并同意参与实验")
|
| 345 |
|