## 后端实现 - 添加考试数据模型 (Exam) - 实现考试生成API (/api/exam/generate) - 实现获取考试详情API (/api/exam/:id) - 实现提交考试API (/api/exam/:id/submit) - 支持按题型随机抽取题目 - AI智能评分(简答题和论述题) - 自动计算总分和详细评分 ## 前端实现 - 首页添加"模拟考试"入口 - 考试准备页:显示考试说明,选择在线/打印模式 - 在线答题页:按题型分组显示,支持论述题二选一 - 试卷打印页:A4排版,支持打印试卷/答案 - 成绩报告页:显示总分、详细评分、错题分析 ## 核心特性 - 随机组卷:填空10题、判断10题、单选10题、多选10题、简答2题、论述题2选1 - 智能评分:使用AI评分论述题,给出分数、评语和建议 - 答题进度保存:使用localStorage防止刷新丢失 - 打印优化:A4纸张、黑白打印、合理排版 - 响应式设计:适配移动端、平板和PC端 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
2.7 KiB
Go
63 lines
2.7 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Exam 考试记录
|
|
type Exam struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
UserID uint `json:"user_id"` // 用户ID
|
|
QuestionIDs string `gorm:"type:text" json:"question_ids"` // 题目ID列表(JSON数组)
|
|
Answers string `gorm:"type:text" json:"answers"` // 用户答案(JSON对象)
|
|
Score float64 `json:"score"` // 总分
|
|
Status string `gorm:"default:'draft'" json:"status"` // 状态: draft/submitted
|
|
SubmittedAt *time.Time `json:"submitted_at"` // 提交时间
|
|
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
|
}
|
|
|
|
// ExamQuestionConfig 考试题目配置
|
|
type ExamQuestionConfig struct {
|
|
FillInBlank int `json:"fill_in_blank"` // 填空题数量
|
|
TrueFalse int `json:"true_false"` // 判断题数量
|
|
MultipleChoice int `json:"multiple_choice"` // 单选题数量
|
|
MultipleSelection int `json:"multiple_selection"` // 多选题数量
|
|
ShortAnswer int `json:"short_answer"` // 简答题数量
|
|
OrdinaryEssay int `json:"ordinary_essay"` // 普通涉密人员论述题数量
|
|
ManagementEssay int `json:"management_essay"` // 保密管理人员论述题数量
|
|
}
|
|
|
|
// DefaultExamConfig 默认考试配置
|
|
var DefaultExamConfig = ExamQuestionConfig{
|
|
FillInBlank: 10, // 填空题10道
|
|
TrueFalse: 10, // 判断题10道
|
|
MultipleChoice: 10, // 单选题10道
|
|
MultipleSelection: 10, // 多选题10道
|
|
ShortAnswer: 2, // 简答题2道
|
|
OrdinaryEssay: 1, // 普通论述题1道
|
|
ManagementEssay: 1, // 管理论述题1道
|
|
}
|
|
|
|
// ExamScoreConfig 考试分值配置
|
|
type ExamScoreConfig struct {
|
|
FillInBlank float64 `json:"fill_in_blank"` // 填空题分值
|
|
TrueFalse float64 `json:"true_false"` // 判断题分值
|
|
MultipleChoice float64 `json:"multiple_choice"` // 单选题分值
|
|
MultipleSelection float64 `json:"multiple_selection"` // 多选题分值
|
|
Essay float64 `json:"essay"` // 论述题分值
|
|
}
|
|
|
|
// DefaultScoreConfig 默认分值配置
|
|
var DefaultScoreConfig = ExamScoreConfig{
|
|
FillInBlank: 2.0, // 填空题每题2分 (共20分)
|
|
TrueFalse: 2.0, // 判断题每题2分 (共20分)
|
|
MultipleChoice: 1.0, // 单选题每题1分 (共10分)
|
|
MultipleSelection: 2.5, // 多选题每题2.5分 (共25分)
|
|
Essay: 25.0, // 论述题25分
|
|
}
|