修正獎勵資訊評分詳細呈現
This commit is contained in:
@@ -75,17 +75,23 @@ export async function GET(
|
||||
scores = await db.query(sql, [award.proposal_id]);
|
||||
console.log('📊 從 proposal_judge_scores 獲取到:', scores.length, '筆');
|
||||
} else if (award.competition_type === 'team' && award.app_id) {
|
||||
// 查詢 judge_scores (團隊賽)
|
||||
// 查詢 judge_scores (團隊賽) 並包含評分詳情
|
||||
const sql = `
|
||||
SELECT
|
||||
js.*,
|
||||
j.name as judge_name,
|
||||
j.title as judge_title,
|
||||
j.avatar as judge_avatar,
|
||||
j.department as judge_department
|
||||
j.department as judge_department,
|
||||
GROUP_CONCAT(
|
||||
CONCAT(jsd.rule_name, ':', jsd.score, ':', jsd.weight)
|
||||
SEPARATOR '|'
|
||||
) as score_details
|
||||
FROM judge_scores js
|
||||
LEFT JOIN judges j ON js.judge_id = j.id
|
||||
LEFT JOIN judge_score_details jsd ON js.id = jsd.judge_score_id
|
||||
WHERE js.app_id = ?
|
||||
GROUP BY js.id
|
||||
ORDER BY js.submitted_at DESC
|
||||
`;
|
||||
console.log('🔍 執行團隊賽 SQL:', sql, '參數:', [award.app_id]);
|
||||
@@ -129,19 +135,33 @@ export async function GET(
|
||||
} else if (award.competition_type === 'team') {
|
||||
// judge_scores (團隊賽) 的處理
|
||||
overallScore = score.overall_score || score.total_score || 0;
|
||||
// 嘗試解析 criteria 欄位,如果沒有則使用預設的團隊評分標準
|
||||
if (score.criteria) {
|
||||
|
||||
// 解析 score_details 欄位,從 judge_score_details 表獲取動態評分細項
|
||||
if (score.score_details) {
|
||||
try {
|
||||
criteria = typeof score.criteria === 'string'
|
||||
? JSON.parse(score.criteria)
|
||||
: score.criteria;
|
||||
const details = score.score_details.split('|');
|
||||
criteria = details.map((detail: string) => {
|
||||
const parts = detail.split(':');
|
||||
if (parts.length >= 2) {
|
||||
const ruleName = parts[0];
|
||||
const scoreValue = parseFloat(parts[1]) || 0;
|
||||
const weight = parseFloat(parts[2]) || 1;
|
||||
return {
|
||||
name: ruleName,
|
||||
score: scoreValue,
|
||||
maxScore: 10,
|
||||
weight: weight
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}).filter(Boolean);
|
||||
} catch (e) {
|
||||
console.error('解析 criteria 失敗:', e);
|
||||
console.error('解析 score_details 失敗:', e);
|
||||
criteria = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 如果沒有 criteria 或解析失敗,使用預設的團隊評分標準
|
||||
// 如果沒有 score_details 或解析失敗,使用預設的團隊評分標準
|
||||
if (!criteria || criteria.length === 0) {
|
||||
criteria = [
|
||||
{ name: '團隊合作', score: score.teamwork_score || 0, maxScore: 10 },
|
||||
|
Reference in New Issue
Block a user