40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
export type VisualEvaluatorResponse = {
|
|
id: string
|
|
participantKey?: string | null
|
|
respondentName?: string | null
|
|
totalScore?: unknown
|
|
comment?: string | null
|
|
workflowRole?: string | null
|
|
createdAt?: string | Date | null
|
|
}
|
|
|
|
export type VisualEvaluatorWorkItem = {
|
|
id: string
|
|
title?: string | null
|
|
scores?: Array<{
|
|
id: string
|
|
participantKey?: string | null
|
|
totalScore?: unknown
|
|
scores?: unknown
|
|
comment?: string | null
|
|
workflowRole?: string | null
|
|
createdAt?: string | Date | null
|
|
}>
|
|
}
|
|
|
|
export function groupVisualScoresByEvaluator(
|
|
responses: VisualEvaluatorResponse[],
|
|
workItems: VisualEvaluatorWorkItem[],
|
|
) {
|
|
return responses.map((response) => ({
|
|
...response,
|
|
workItemScores: workItems.map((workItem, index) => ({
|
|
workItemId: workItem.id,
|
|
workItemTitle: workItem.title || `作品 ${index + 1}`,
|
|
score: (workItem.scores || []).find(
|
|
(item) => Boolean(response.participantKey) && item.participantKey === response.participantKey,
|
|
) || null,
|
|
})),
|
|
}))
|
|
}
|