Spaces:
Sleeping
Sleeping
gr.Markdown("### 📝 作業管理")
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ OPEN_AI_CLIENT = OpenAI(api_key=OPEN_AI_KEY)
|
|
46 |
CUTOR_OPEN_AI_CLIENT = OpenAI(api_key=CUTOR_OPEN_AI_KEY)
|
47 |
OPEN_AI_MODERATION_CLIENT = OpenAI(api_key=OPEN_AI_MODERATION_BOT1)
|
48 |
|
49 |
-
#
|
50 |
GCS_SERVICE = GoogleCloudStorage(GCS_KEY)
|
51 |
GCS_CLIENT = GCS_SERVICE.client
|
52 |
|
@@ -970,7 +970,7 @@ def generate_chinese_paragraph_practice_history(
|
|
970 |
|
971 |
def submit_assignment(user_data, assignment_id, submission_content, file_name):
|
972 |
"""
|
973 |
-
|
974 |
|
975 |
参数:
|
976 |
user_data (str): 用户ID
|
@@ -1357,7 +1357,7 @@ def init_params(request: gr.Request):
|
|
1357 |
admin_group = gr.update(visible=False)
|
1358 |
english_group = gr.update(visible=True)
|
1359 |
chinese_group = gr.update(visible=True)
|
1360 |
-
|
1361 |
|
1362 |
user_data = gr.update(value="")
|
1363 |
|
@@ -1392,18 +1392,18 @@ def init_params(request: gr.Request):
|
|
1392 |
print(f"language: english")
|
1393 |
english_group = gr.update(visible=True)
|
1394 |
chinese_group = gr.update(visible=False)
|
1395 |
-
|
1396 |
|
1397 |
if "language" in query_params and query_params["language"] == "chinese":
|
1398 |
print(f"language: chinese")
|
1399 |
english_group = gr.update(visible=False)
|
1400 |
chinese_group = gr.update(visible=True)
|
1401 |
-
|
1402 |
|
1403 |
if "assignment_mode" in query_params and query_params["assignment_mode"] == "true":
|
1404 |
english_group = gr.update(visible=False)
|
1405 |
chinese_group = gr.update(visible=False)
|
1406 |
-
|
1407 |
|
1408 |
assignment_id_value = None
|
1409 |
assignment_json_value = None
|
@@ -1440,7 +1440,7 @@ def init_params(request: gr.Request):
|
|
1440 |
admin_group, session_timestamp, request_origin, \
|
1441 |
assignment_id_input, assignment_json, \
|
1442 |
chinese_assignment_row, chinese_assignment_grade, chinese_assignment_topic, chinese_assignment_introduction, chinese_assignment_description, \
|
1443 |
-
english_group, chinese_group,
|
1444 |
|
1445 |
CSS = """
|
1446 |
.accordion-prompts {
|
@@ -3363,10 +3363,14 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3363 |
outputs=chinese_essay_idea_output
|
3364 |
)
|
3365 |
|
3366 |
-
with gr.
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
|
|
|
|
|
|
|
|
3370 |
|
3371 |
demo.load(
|
3372 |
init_params,
|
@@ -3385,7 +3389,7 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3385 |
chinese_assignment_description,
|
3386 |
english_group,
|
3387 |
chinese_group,
|
3388 |
-
|
3389 |
]
|
3390 |
)
|
3391 |
|
|
|
46 |
CUTOR_OPEN_AI_CLIENT = OpenAI(api_key=CUTOR_OPEN_AI_KEY)
|
47 |
OPEN_AI_MODERATION_CLIENT = OpenAI(api_key=OPEN_AI_MODERATION_BOT1)
|
48 |
|
49 |
+
# 設置 Google Cloud Storage 客户端
|
50 |
GCS_SERVICE = GoogleCloudStorage(GCS_KEY)
|
51 |
GCS_CLIENT = GCS_SERVICE.client
|
52 |
|
|
|
970 |
|
971 |
def submit_assignment(user_data, assignment_id, submission_content, file_name):
|
972 |
"""
|
973 |
+
提��作业并更新相关数据。
|
974 |
|
975 |
参数:
|
976 |
user_data (str): 用户ID
|
|
|
1357 |
admin_group = gr.update(visible=False)
|
1358 |
english_group = gr.update(visible=True)
|
1359 |
chinese_group = gr.update(visible=True)
|
1360 |
+
assignment_group = gr.update(visible=False)
|
1361 |
|
1362 |
user_data = gr.update(value="")
|
1363 |
|
|
|
1392 |
print(f"language: english")
|
1393 |
english_group = gr.update(visible=True)
|
1394 |
chinese_group = gr.update(visible=False)
|
1395 |
+
assignment_group = gr.update(visible=False)
|
1396 |
|
1397 |
if "language" in query_params and query_params["language"] == "chinese":
|
1398 |
print(f"language: chinese")
|
1399 |
english_group = gr.update(visible=False)
|
1400 |
chinese_group = gr.update(visible=True)
|
1401 |
+
assignment_group = gr.update(visible=False)
|
1402 |
|
1403 |
if "assignment_mode" in query_params and query_params["assignment_mode"] == "true":
|
1404 |
english_group = gr.update(visible=False)
|
1405 |
chinese_group = gr.update(visible=False)
|
1406 |
+
assignment_group = gr.update(visible=True)
|
1407 |
|
1408 |
assignment_id_value = None
|
1409 |
assignment_json_value = None
|
|
|
1440 |
admin_group, session_timestamp, request_origin, \
|
1441 |
assignment_id_input, assignment_json, \
|
1442 |
chinese_assignment_row, chinese_assignment_grade, chinese_assignment_topic, chinese_assignment_introduction, chinese_assignment_description, \
|
1443 |
+
english_group, chinese_group, assignment_group
|
1444 |
|
1445 |
CSS = """
|
1446 |
.accordion-prompts {
|
|
|
3363 |
outputs=chinese_essay_idea_output
|
3364 |
)
|
3365 |
|
3366 |
+
with gr.Row(visible=False) as assignment_group:
|
3367 |
+
with gr.Column():
|
3368 |
+
with gr.Row():
|
3369 |
+
gr.Markdown("# 📝 作業管理")
|
3370 |
+
with gr.Row():
|
3371 |
+
assignment_service = AssignmentService(GCS_SERVICE)
|
3372 |
+
submission_service = SubmissionService(GCS_SERVICE)
|
3373 |
+
assignment_interface = create_assignment_ui(user_data, assignment_service, submission_service)
|
3374 |
|
3375 |
demo.load(
|
3376 |
init_params,
|
|
|
3389 |
chinese_assignment_description,
|
3390 |
english_group,
|
3391 |
chinese_group,
|
3392 |
+
assignment_group
|
3393 |
]
|
3394 |
)
|
3395 |
|