AnCao/internal/models/practice_question.go
yanlongqi 43680cce22 优化试卷打印功能并移除打印答案功能
1. 移除打印答案按钮及相关功能,简化界面
2. 优化填空题打印效果,使用答案长度计算下划线宽度
3. 改进试卷头部布局,添加日期和成绩栏
4. 更新考试说明,调整考试时间为60分钟
5. 优化打印样式,使用宋体字并减小间距
6. 完善论述题显示,添加用户类型提示
7. 后端支持同时返回两种论述题题目

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 02:39:48 +08:00

53 lines
2.6 KiB
Go

package models
// PracticeQuestion 练习题目模型
type PracticeQuestion struct {
ID int64 `gorm:"primarykey"`
QuestionID string `gorm:"size:50;not null" json:"question_id"` // 题目ID (原JSON中的id字段)
Type string `gorm:"index;size:30;not null" json:"type"` // 题目类型
TypeName string `gorm:"size:50" json:"type_name"` // 题型名称(中文)
Question string `gorm:"type:text;not null" json:"question"` // 题目内容
AnswerData string `gorm:"type:jsonb" json:"-"` // 答案数据(JSON格式存储)
OptionsData string `gorm:"type:jsonb" json:"-"` // 选项数据(JSON格式存储,用于选择题)
}
// TableName 指定表名
func (PracticeQuestion) TableName() string {
return "practice_questions"
}
// PracticeQuestionDTO 用于前端返回的数据传输对象
type PracticeQuestionDTO struct {
ID int64 `json:"id"` // 数据库自增ID
QuestionID string `json:"question_id"` // 题目编号(原JSON中的id)
Type string `json:"type"` // 前端使用的简化类型: single, multiple, judge, fill
Content string `json:"content"` // 题目内容
Options []Option `json:"options"` // 选择题选项数组
Category string `json:"category"` // 题目分类
Answer interface{} `json:"answer"` // 正确答案(用于题目管理编辑)
AnswerLengths []int `json:"answer_lengths,omitempty"` // 答案长度数组(用于打印时计算横线长度)
}
// PracticeAnswerSubmit 练习题答案提交
type PracticeAnswerSubmit struct {
QuestionID int64 `json:"question_id" binding:"required"` // 数据库ID
Answer interface{} `json:"answer" binding:"required"` // 用户答案
}
// PracticeAnswerResult 练习题答案结果
type PracticeAnswerResult struct {
Correct bool `json:"correct"` // 是否正确
UserAnswer interface{} `json:"user_answer"` // 用户答案
CorrectAnswer interface{} `json:"correct_answer,omitempty"` // 正确答案(仅在错误时返回)
AIGrading *AIGrading `json:"ai_grading,omitempty"` // AI评分结果(仅简答题)
}
// AIGrading AI评分结果
type AIGrading struct {
Score float64 `json:"score"` // 得分 (0-100)
Feedback string `json:"feedback"` // 评语
Suggestion string `json:"suggestion"` // 改进建议
ReferenceAnswer string `json:"reference_answer,omitempty"` // 参考答案(论述题)
ScoringRationale string `json:"scoring_rationale,omitempty"` // 评分依据
}