pbl_evidence/wwwroot/api/pbl_evidence_subject_summary.dspy
2026-09-22 14:13:03 +08:00

23 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# pbl_evidence/api/pbl_evidence_subject_summary.dspy
# M5b 契约④:学生 / 团队证据档案(设计 §3.2 list_evidence_by_student / by_team 等价实现)。
# 入参:subject_type=student|team + subject_id(或 student_id / team_id)+ blueprint_id(可选)
# 出参:四类分组明细 + 产出物计数 + 水位;预览/Playtest 数据默认过滤(Q-OPEN-10)。
# dspy 铁律:无 import、无 ServerEnv()、显式 return。
debug(f'pbl_evidence/api/pbl_evidence_subject_summary.dspy: START params_kw={dict(params_kw)}')
try:
kw = dict(params_kw)
if isinstance(kw.get('include_preview'), str):
kw['include_preview'] = kw['include_preview'].strip().lower() in ('1', 'true', 'yes', 'y')
if isinstance(kw.get('include_student_private'), str):
kw['include_student_private'] = kw['include_student_private'].strip().lower() in ('1', 'true', 'yes', 'y')
res = await pbl_evidence_subject_summary(**kw)
status = 'OK' if res.get('ok') else 'ERROR'
debug(f'pbl_evidence_subject_summary.dspy: DONE subject={res.get("subject_type")}:'
f'{res.get("subject_id")} total={res.get("evidence_total")}')
return {'status': status, 'data': res, 'message': res.get('message') or '',
'total': res.get('evidence_total')}
except Exception as e:
error(f'pbl_evidence_subject_summary.dspy: FAIL {format_exc()}')
return {'status': 'ERROR', 'data': None, 'message': str(e)}