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