- 使用 distributeScores 智能整数分配题目分数 - 格式化分数显示,避免显示长小数 - 总分100分,根据题目数量智能分配整数分数 例如:11道题 = [10,10,10,10,10,10,10,10,10,5,5] 而不是 [9.09...,9.09...]
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<el-tag :type="getQuestionTypeTag(currentQuestion.type)">
|
||||
{{ getQuestionTypeText(currentQuestion.type) }}
|
||||
</el-tag>
|
||||
<span class="question-score">{{ currentQuestion.score }} 分</span>
|
||||
<span class="question-score">{{ formatScore(currentQuestion.score) }} 分</span>
|
||||
</div>
|
||||
|
||||
<div class="question-content">
|
||||
@@ -235,6 +235,7 @@ import { courseApi } from '@/api/course'
|
||||
import { generateExam, judgeAnswer, recordMistake, getMistakes, updateRoundScore, type MistakeRecordItem } from '@/api/exam'
|
||||
import { marked } from 'marked'
|
||||
import DOMPurify from 'dompurify'
|
||||
import { distributeScores, formatScore } from '@/utils/scoreFormatter'
|
||||
|
||||
// 路由相关
|
||||
const route = useRoute()
|
||||
@@ -358,6 +359,10 @@ const clearAnswer = () => {
|
||||
* 数据格式转换:Dify格式转前端格式
|
||||
*/
|
||||
const transformDifyQuestions = (difyQuestions: any[]): any[] => {
|
||||
// 使用智能分数分配,避免小数(总分100分)
|
||||
const totalScore = 100
|
||||
const scores = distributeScores(totalScore, difyQuestions.length)
|
||||
|
||||
return difyQuestions.map((q, index) => {
|
||||
const typeMap: Record<string, string> = {
|
||||
'single_choice': 'single',
|
||||
@@ -371,7 +376,7 @@ const transformDifyQuestions = (difyQuestions: any[]): any[] => {
|
||||
id: index + 1,
|
||||
type: typeMap[q.type] || q.type,
|
||||
title: q.topic?.title || q.topic || '',
|
||||
score: 10 / difyQuestions.length, // 平均分配分值,总分10分
|
||||
score: scores[index], // 使用智能整数分配
|
||||
explanation: q.analysis || '',
|
||||
knowledge_point_id: q.knowledge_point_id ? parseInt(q.knowledge_point_id) : null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user