exam.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package models
  2. // 试卷表
  3. type ExamPaper struct {
  4. ExamName string `gorm:"type:varchar(100);not null;comment:试卷名称" json:"exam_name"`
  5. ExamType string `gorm:"type:varchar(50);not null;comment:试卷类型" json:"exam_type"`
  6. TotalScore int `gorm:"type:int;not null;comment:试卷总分" json:"total_score"`
  7. TotalQuestions int `gorm:"type:int;not null;comment:总题数" json:"total_questions"`
  8. GenerationMethod string `gorm:"type:varchar(20);not null;comment:生成方式" json:"generation_method"`
  9. GenerationTime string `gorm:"type:varchar(50);not null;comment:生成时间" json:"generation_time"`
  10. UserID *uint `gorm:"type:bigint;comment:用户ID" json:"user_id"`
  11. Status int8 `gorm:"type:tinyint;default:1;comment:状态" json:"status"`
  12. BaseModel
  13. // 关联字段
  14. QuestionConfigs []ExamQuestionConfig `gorm:"foreignKey:ExamPapersID" json:"question_configs"`
  15. Questions []ExamQuestion `gorm:"foreignKey:ExamPapersID" json:"questions"`
  16. }
  17. // 题型配置表
  18. type ExamQuestionConfig struct {
  19. ExamPapersID uint `gorm:"type:bigint;not null;comment:试卷ID" json:"exam_papers_id"`
  20. QuestionType string `gorm:"type:varchar(20);not null;comment:题型" json:"question_type"`
  21. ScorePerQuestion int `gorm:"type:int;not null;comment:每题分值" json:"score_per_question"`
  22. TotalScore int `gorm:"type:int;not null;comment:该题型总分" json:"total_score"`
  23. QuestionCount int `gorm:"type:int;not null;comment:题目数量" json:"question_count"`
  24. BaseModel
  25. }
  26. // 题目表
  27. type ExamQuestion struct {
  28. ExamPapersID uint `gorm:"type:bigint;not null;comment:试卷ID" json:"exam_papers_id"`
  29. QuestionType string `gorm:"type:varchar(20);not null;comment:题型" json:"question_type"`
  30. QuestionIndex int `gorm:"type:int;not null;comment:题目序号" json:"question_index"`
  31. QuestionText string `gorm:"type:text;not null;comment:题目内容" json:"question_text"`
  32. Options []byte `gorm:"type:json;comment:选项" json:"options"`
  33. CorrectAnswer string `gorm:"type:varchar(50);comment:正确答案" json:"correct_answer"`
  34. CorrectAnswers []byte `gorm:"type:json;comment:正确答案(多选题)" json:"correct_answers"`
  35. AnswerOutline []byte `gorm:"type:json;comment:答题要点" json:"answer_outline"`
  36. BaseModel
  37. }
  38. // 用户答案表
  39. type ExamUserAnswer struct {
  40. ExamPapersID uint `gorm:"type:bigint;not null;comment:试卷ID" json:"exam_papers_id"`
  41. UserID uint `gorm:"type:bigint;not null;comment:用户ID" json:"user_id"`
  42. ExamQuestionsID uint `gorm:"type:bigint;not null;comment:题目ID" json:"exam_questions_id"`
  43. UserAnswer string `gorm:"type:varchar(50);comment:用户答案" json:"user_answer"`
  44. UserAnswers []byte `gorm:"type:json;comment:用户答案(多选题)" json:"user_answers"`
  45. IsCorrect *int8 `gorm:"type:tinyint;comment:是否正确" json:"is_correct"`
  46. }