调整填空题下划线最小长度为8个字符
1. 将填空题下划线最小宽度从2个字符(8px)调整为8个字符(32px) 2. 更新默认宽度策略:单个填空32px,多个填空30-40px循环 3. 确保无论答案长度如何,下划线都有足够的空间供用户书写 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
2c090d5fbd
commit
78413e98d7
@ -156,23 +156,23 @@ const ExamPrint: React.FC = () => {
|
|||||||
// 优先使用 answer_lengths 字段(在 show_answer=false 时也会返回)
|
// 优先使用 answer_lengths 字段(在 show_answer=false 时也会返回)
|
||||||
if (question.answer_lengths && question.answer_lengths[blankIndex] !== undefined) {
|
if (question.answer_lengths && question.answer_lengths[blankIndex] !== undefined) {
|
||||||
const answerLength = question.answer_lengths[blankIndex]
|
const answerLength = question.answer_lengths[blankIndex]
|
||||||
// 每个字符对应约4px宽度,最少2个字符=8px,最多60px
|
// 每个字符对应约4px宽度,最少8个字符=32px,最多60px
|
||||||
return Math.max(Math.max(answerLength, 2) * 4, 8)
|
return Math.max(Math.max(answerLength, 8) * 4, 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有实际的答案数据,使用答案长度
|
// 如果有实际的答案数据,使用答案长度
|
||||||
if (answers[blankIndex]) {
|
if (answers[blankIndex]) {
|
||||||
const answerText = String(answers[blankIndex])
|
const answerText = String(answers[blankIndex])
|
||||||
// 每个字符对应约4px宽度,最少2个字符=8px
|
// 每个字符对应约4px宽度,最少8个字符=32px
|
||||||
return Math.max(Math.max(answerText.length, 2) * 4, 8)
|
return Math.max(Math.max(answerText.length, 8) * 4, 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有任何答案数据,使用默认策略
|
// 如果没有任何答案数据,使用默认策略
|
||||||
if (totalBlanks === 1) {
|
if (totalBlanks === 1) {
|
||||||
return 20 // 单个填空:20px(约5个字符)
|
return 32 // 单个填空:32px(约8个字符)
|
||||||
} else {
|
} else {
|
||||||
// 多个填空:15-25px循环(4-6个字符)
|
// 多个填空:30-40px循环(约8-10个字符)
|
||||||
const widths = [15, 20, 25, 18, 22]
|
const widths = [32, 36, 40, 34, 38]
|
||||||
return widths[blankIndex % widths.length]
|
return widths[blankIndex % widths.length]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user