diff --git a/app/performance-survey/[[...path]]/page.tsx b/app/performance-survey/[[...path]]/page.tsx index e513183a..7c4f2211 100644 --- a/app/performance-survey/[[...path]]/page.tsx +++ b/app/performance-survey/[[...path]]/page.tsx @@ -8,6 +8,7 @@ import { useSession } from 'next-auth/react' import { pinyin } from 'pinyin-pro' import { createPortal } from 'react-dom' import { sortPerformanceSurveyImagesByName } from '@/lib/performance-survey-image-order' +import { calculatePerformanceSurveyResponseProgress } from '@/lib/performance-survey-response-progress' type ApiState = { loading: boolean @@ -3850,9 +3851,13 @@ function SurveySubmit({ surveyId, session }: { surveyId: string; session: any }) const activeTarget = detail.data.targets.find((target: any) => target.id === activeTargetId) const submitted = activeTarget?.currentAssignment?.status === 'submitted' - const scoreValues = questions.map((question) => Number(scores[question.id] ?? 0)) - const scoreTotal = scoreValues.reduce((sum, value) => sum + value, 0) - const ratedCount = questions.filter((question) => Number.isFinite(scores[question.id])).length + const submittedScores = activeTarget?.currentAssignment?.response?.scores + const progress = calculatePerformanceSurveyResponseProgress({ + questions, + draftScores: scores, + submittedScores: submittedScores && typeof submittedScores === 'object' ? submittedScores : {}, + submitted, + }) const surveyStatusLabel = getSurveyStatusLabel(detail.data.status) const dueLabel = detail.data.dueAt ? `截止 ${formatDate(detail.data.dueAt)}` : '无截止时间' const viewer = session?.user || {} @@ -3913,12 +3918,12 @@ function SurveySubmit({ surveyId, session }: { surveyId: string; session: any })
填写进度 - {ratedCount}/{questions.length || 0} · {scoreTotal} 分 + {progress.ratedCount}/{progress.totalCount} · {progress.totalScore} 分
0 ? Math.min(100, (ratedCount / questions.length) * 100) : 0}%` }} + style={{ width: `${progress.percent}%` }} />
@@ -4078,7 +4083,7 @@ function SurveySubmit({ surveyId, session }: { surveyId: string; session: any })