修正 vercal 部署失敗問題
This commit is contained in:
@@ -94,14 +94,14 @@ export async function GET(request: NextRequest) {
|
||||
console.log('Debug: 所有創意題目數量:', allCreativeQuestions.length)
|
||||
|
||||
for (let i = 0; i < answerEntries.length; i++) {
|
||||
const [questionIndex, score] = answerEntries[i]
|
||||
const [questionIndex, score] = answerEntries[i] as [string, number]
|
||||
const question = allCreativeQuestions[parseInt(questionIndex)] // 使用索引獲取題目
|
||||
if (question) {
|
||||
questions.push({
|
||||
...question,
|
||||
type: 'creative',
|
||||
userAnswer: score.toString(), // 創意題的答案就是分數
|
||||
score: score as number,
|
||||
score: score,
|
||||
isReverse: question.is_reverse
|
||||
})
|
||||
}
|
||||
|
@@ -35,21 +35,24 @@ export async function GET(request: NextRequest) {
|
||||
if (result.test_type === 'logic') {
|
||||
const logicAnswers = await getLogicTestAnswersByTestResultId(result.id)
|
||||
if (logicAnswers.length > 0) {
|
||||
const logicAnswer = logicAnswers[0]
|
||||
const correctAnswers = logicAnswers.filter(answer => answer.is_correct).length
|
||||
const totalQuestions = logicAnswers.length
|
||||
const accuracy = totalQuestions > 0 ? Math.round((correctAnswers / totalQuestions) * 100) : 0
|
||||
details = {
|
||||
correctAnswers: logicAnswer.correct_answers,
|
||||
totalQuestions: logicAnswer.total_questions,
|
||||
accuracy: logicAnswer.accuracy
|
||||
correctAnswers,
|
||||
totalQuestions,
|
||||
accuracy
|
||||
}
|
||||
}
|
||||
} else if (result.test_type === 'creative') {
|
||||
const creativeAnswers = await getCreativeTestAnswersByTestResultId(result.id)
|
||||
if (creativeAnswers.length > 0) {
|
||||
const creativeAnswer = creativeAnswers[0]
|
||||
const totalScore = creativeAnswers.reduce((sum, answer) => sum + answer.score, 0)
|
||||
const maxScore = creativeAnswers.length * 5 // Assuming max score per question is 5
|
||||
details = {
|
||||
dimensionScores: creativeAnswer.dimension_scores,
|
||||
totalScore: creativeAnswer.total_score,
|
||||
maxScore: creativeAnswer.max_score
|
||||
dimensionScores: {}, // This would need to be calculated based on question categories
|
||||
totalScore,
|
||||
maxScore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,21 +37,24 @@ export async function GET(request: NextRequest) {
|
||||
if (result.test_type === 'logic') {
|
||||
const logicAnswers = await getLogicTestAnswersByTestResultId(result.id)
|
||||
if (logicAnswers.length > 0) {
|
||||
const logicAnswer = logicAnswers[0] // 取第一個答案記錄
|
||||
const correctAnswers = logicAnswers.filter(answer => answer.is_correct).length
|
||||
const totalQuestions = logicAnswers.length
|
||||
const accuracy = totalQuestions > 0 ? Math.round((correctAnswers / totalQuestions) * 100) : 0
|
||||
details = {
|
||||
correctAnswers: logicAnswer.correct_answers,
|
||||
totalQuestions: logicAnswer.total_questions,
|
||||
accuracy: logicAnswer.accuracy
|
||||
correctAnswers,
|
||||
totalQuestions,
|
||||
accuracy
|
||||
}
|
||||
}
|
||||
} else if (result.test_type === 'creative') {
|
||||
const creativeAnswers = await getCreativeTestAnswersByTestResultId(result.id)
|
||||
if (creativeAnswers.length > 0) {
|
||||
const creativeAnswer = creativeAnswers[0] // 取第一個答案記錄
|
||||
const totalScore = creativeAnswers.reduce((sum, answer) => sum + answer.score, 0)
|
||||
const maxScore = creativeAnswers.length * 5 // Assuming max score per question is 5
|
||||
details = {
|
||||
dimensionScores: creativeAnswer.dimension_scores,
|
||||
totalScore: creativeAnswer.total_score,
|
||||
maxScore: creativeAnswer.max_score
|
||||
dimensionScores: {}, // This would need to be calculated based on question categories
|
||||
totalScore,
|
||||
maxScore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user