- UI框架:从 antd-mobile 迁移到 Ant Design,支持更好的跨平台体验 - 响应式设计:实现移动端、平板、PC端全方位适配 - 移动端:保留底部导航栏,优化触摸交互 - PC端:隐藏底部导航,采用居中布局 - 样式重构:所有组件样式迁移到 CSS Modules(.module.less) - 功能优化: - 练习题答题改进:始终返回正确答案便于用户学习 - 添加题目编号字段(question_id) - 修复判断题选项:由 A/B 改为 true/false - 组件优化: - TabBarLayout 重构,支持响应式显示/隐藏 - 所有页面组件采用 Ant Design 组件替换原 antd-mobile 组件 - 统一使用 @ant-design/icons 图标库 - 文档同步:更新 CLAUDE.md 中 UI 组件使用规范和响应式设计说明 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
54 lines
2.4 KiB
Go
54 lines
2.4 KiB
Go
package models
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
// PracticeQuestionType 题目类型
|
|
type PracticeQuestionType string
|
|
|
|
const (
|
|
FillInBlank PracticeQuestionType = "fill-in-blank" // 填空题
|
|
TrueFalseType PracticeQuestionType = "true-false" // 判断题
|
|
MultipleChoiceQ PracticeQuestionType = "multiple-choice" // 单选题
|
|
MultipleSelection PracticeQuestionType = "multiple-selection" // 多选题
|
|
ShortAnswer PracticeQuestionType = "short-answer" // 简答题
|
|
)
|
|
|
|
// PracticeQuestion 练习题目模型
|
|
type PracticeQuestion struct {
|
|
gorm.Model
|
|
QuestionID string `gorm:"size:50;not null" json:"question_id"` // 题目ID (原JSON中的id字段)
|
|
Type PracticeQuestionType `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:text;not null" json:"-"` // 答案数据(JSON格式存储)
|
|
OptionsData string `gorm:"type:text" json:"-"` // 选项数据(JSON格式存储,用于选择题)
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (PracticeQuestion) TableName() string {
|
|
return "practice_questions"
|
|
}
|
|
|
|
// PracticeQuestionDTO 用于前端返回的数据传输对象
|
|
type PracticeQuestionDTO struct {
|
|
ID uint `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"` // 题目分类
|
|
}
|
|
|
|
// PracticeAnswerSubmit 练习题答案提交
|
|
type PracticeAnswerSubmit struct {
|
|
QuestionID uint `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"` // 正确答案(仅在错误时返回)
|
|
}
|