TMS项目数据结构说明文档
本文档详细描述了TMS(Teaching Management System)项目中model目录下的数据结构,包括各个模型的字段说明和用途。
1. 用户管理模块
1.1 用户表 (Users)
type Users struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;type:bigint;column:id;" json:"id"` // 用户唯一标识符,主键,自增
Account string `gorm:"column:account;type:varchar;size:50;uniqueIndex;" json:"account"` // 用户登录账号,需唯一,可考虑添加索引以优化查询
UserNo string `gorm:"column:user_no;type:varchar;size:150;" json:"user_no"` // 用户编号,例如学号或员工号
Username string `gorm:"column:username;type:varchar;size:50;" json:"username"` // 用户昵称或显示名称
Password string `gorm:"column:password;type:varchar;size:100;" json:"password"` // BCrypt加密后的密码哈希值,确保密码安全存储
Email string `gorm:"column:email;type:varchar;size:100;" json:"email"` // 用户邮箱,可用于找回密码或通知
Phone string `gorm:"column:phone;type:varchar;size:20;" json:"phone"`
Status string `gorm:"column:status;type:char;size:6;default:1;" json:"status"` // 用户状态,例如:1-正常,0-禁用
CreatedAt int64 `gorm:"column:created_at" json:"created_at"` // 记录创建时间,默认当前时间戳
UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at"` // 记录更新时间
Salt string `gorm:"column:salt;type:varchar;size:100;" json:"salt"` // 密码加盐,增加安全性
}
1.2 角色表 (Roles)
type Roles struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;" json:"id"`
RoleName string `gorm:"column:role_name;type:varchar;size:50;" json:"role_name"` // 角色名称
Description string `gorm:"column:description;type:text;" json:"description"` // 角色描述
IsSystem bool `gorm:"column:is_system;type:boolean;" json:"is_system"` // 是否为系统内置角色,默认false
SysCode string `gorm:"column:sys_code;type:varchar;size:50;" json:"sys_code"` // 系统标识
RoleCode string `gorm:"column:role_code;type:varchar;size:50;index:idx_role_code;" json:"role_code"` // 角色编码
CreatedAt int64 `gorm:"column:created_at" json:"created_at"` // 记录创建时间,默认当前时间戳
}
1.3 菜单表 (Menus)
type Menus struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
ParentID int64 `gorm:"column:parent_id;type:bigint;default:0;index;" json:"parent_id"` // 父菜单ID
MenuName string `gorm:"column:menu_name;type:varchar;size:50;" json:"menu_name"` // 菜单名称
Path string `gorm:"column:path;type:varchar;size:255;index;" json:"path"` // 路由路径
Icon string `gorm:"column:icon;type:varchar;size:150;" json:"icon"` // 图标名称
OrderNum int64 `gorm:"column:order_num;type:int;" json:"order_num"` // 排序字段,用于前端菜单的顺序排列
SysCode string `gorm:"column:sys_code;type:varchar;size:50;" json:"sys_code"` // 角色编码,用于权限控制
CreatedAt int64 `gorm:"column:created_at" json:"created_at"` // 自动创建时间
UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at"` // 自动更新时间
}
2. 课程管理模块
2.1 课程表 (Courses)
type Courses struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id" comment:"主键ID"`
PlanID int64 `gorm:"column:plan_id;type:bigint;" json:"plan_id" comment:"关联的教学计划ID"` // 关联的教学计划ID
MajorID int64 `gorm:"column:major_id;type:bigint;" json:"major_id" comment:"专业ID"` // 专业ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id" comment:"关联章节ID"` // 关联总章节ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id" comment:"用户ID"` // 用户ID
CourseCode string `gorm:"column:course_code;type:varchar;size:50;" json:"course_code" comment:"课程编码"` // 课程编码,唯一标识一门课程
Name string `gorm:"column:name;type:varchar;size:255;" json:"name" comment:"课程名称"` // 课程名称(中文)
Description string `gorm:"column:description;type:text;" json:"description" comment:"课程描述信息"` // 课程描述信息
TotalHours int `gorm:"column:total_hours;type:int;" json:"total_hours" comment:"总课时数(单位:个)"` // 总课时数
TotalStudyTime int `gorm:"column:total_study_time;type:int;default:0;" json:"total_study_time"` // 总学习时长(小时)
Status string `gorm:"column:status;varchar;size:50;" json:"status" comment:"课程状态"` // 课程状态
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at" comment:"创建时间"` // 创建时间
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" comment:"更新时间"` // 更新时间
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at" comment:"提交时间"` // 提交时间
PublishedAt int64 `gorm:"column:published_at;" json:"published_at" comment:"发布时间"` // 发布时间
Version string `gorm:"column:version;type:varchar(30);default:v1.0;" json:"version" comment:"版本号"` // 版本号
}
2.2 课件表 (Courseware)
type Courseware struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"` // 关联课程ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 关联章节ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 创建人ID
Title string `gorm:"column:title;type:varchar;size:255;" json:"title"` // 课件标题
FileName string `gorm:"column:file_name;type:varchar;size:255;" json:"file_name"` // 文件名
FileType string `gorm:"column:file_type;type:varchar;size:10;" json:"file_type"` // 文件类型(pptx/pdf/mp4等)
CoursewareType string `gorm:"column:courseware_type;type:varchar;size:20;" json:"courseware_type"` // 课件类型(theory/virtual)
FilePath string `gorm:"column:file_path;type:varchar;size:600;" json:"file_path"` // 文件存储路径
UnzipPath string `gorm:"column:unzip_path;type:varchar;size:600;" json:"unzip_path"` // 解压后文件存储路径
Description string `gorm:"column:description;type:text;" json:"description"` // 课件描述
Target string `gorm:"column:target;type:varchar;size:50;" json:"target"` // 适用对象
Score int `gorm:"column:score;type:int;" json:"score"` // 参考分数
Minutes int `gorm:"column:minutes;type:int;" json:"minutes"` // 答题时间(分钟)
TotalStep int `gorm:"column:total_step;type:int;" json:"total_step"` // 完成虚拟课件总步数
Status string `gorm:"column:status;type:varchar;size:50;" json:"status"` // 课程状态(draft, reviewing, published)
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(Unix 时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(Unix 时间戳)
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
Version string `gorm:"column:version;type:varchar(30);default:v1.0;" json:"version"` // 版本号
}
2.3 章节表 (Chapters)
章节表用于组织课程内容的层次结构。
2.4 知识点表 (KnowledgePoints)
type KnowledgePoints struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
Title string `gorm:"column:title;type:varchar(200);" json:"title"` // 知识点标题
Content string `gorm:"column:content;type:text;" json:"content"` // 知识点内容(富文本)
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 授课教师ID
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"` // 关联课程ID
CoursewareID int64 `gorm:"column:courseware_id;type:bigint;" json:"courseware_id"` // 关联课件ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 关联章节ID
QuestionID int64 `gorm:"column:question_id;type:bigint;" json:"question_id"` // 关联题库ID
Status string `gorm:"column:status;type:varchar(20);" json:"status"` // 状态:draft, published
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
Version string `gorm:"column:version;type:varchar(20);default:v1.0;" json:"version"` // 版本号
}
3. 考试评估模块
3.1 试卷表 (Papers)
type Papers struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
Title string `gorm:"size:255;not null" json:"title"` // 试卷标题
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"` // 课程ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 章节ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
QuestionCount int `gorm:"column:question_count;type:int;" json:"question_count"` // 题目数量
TotalScore int `gorm:"column:total_score;type:int;" json:"total_score"` // 总分
TotalMinutes int64 `gorm:"column:total_minutes;type:int;" json:"total_minutes"` // 总时数(单位:分钟)
Status string `gorm:"column:status;varchar;size:50;" json:"status"` // 状态
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
Version string `gorm:"column:version;type:varchar;size:20;default:v1.0;" json:"version"` // 版本号
}
3.2 题目表 (Questions)
type Questions struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"` // 主键
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 创建人ID
Title string `gorm:"column:title;type:varchar(255);not null;" json:"title"` // 试题名称
QuestionType string `gorm:"column:question_type;type:varchar(20);not null;" json:"question_type"` // 试题类型(single, multiple, judge, fill, short)
Content string `gorm:"column:content;type:text;not null;" json:"content"` // 试题内容
Answer string `gorm:"column:answer;type:text;not null;" json:"answer"` // 试题答案
ScorePoints string `gorm:"column:score_points;type:text;" json:"score_points"` // 评分标准(仅适用于手工阅卷的类型)
Score int `gorm:"column:score;type:int;" json:"score"` // 参考分数
Minutes int `gorm:"column:minutes;type:int;" json:"minutes"` // 答题时间(分钟)
Options string `gorm:"column:options;type:text;" json:"options"` // 选项(JSON数组存储,仅适用于单选和多选题)
Status string `gorm:"column:status;type:varchar;size:50;" json:"status"` // 课程状态(draft, reviewing, published)
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(Unix 时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(Unix 时间戳)
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
Version string `gorm:"column:version;type:varchar;size:20;default:v1.0;" json:"version"` // 版本号
}
3.3 考试表 (Exams)
type Exams struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"` // 考试名称
ExamType string `gorm:"column:exam_type;varchar;size:50;" json:"exam_type"` // 考试类型
PaperID int64 `gorm:"column:paper_id;type:bigint;" json:"paper_id"` // 试卷ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"`
TotalMinutes int64 `gorm:"column:total_minutes;type:int;" json:"total_minutes"` // 总时数(单位:分钟)
StartAt int64 `gorm:"column:start_at;" json:"start_at"` // 开始时间(考试开始时间)
EndAt int64 `gorm:"column:end_at;" json:"end_at"` // 结束时间(考试截止时间)
Location string `gorm:"column:location;type:varchar;size:100;" json:"location"` // 考核地点
Status string `gorm:"column:status;varchar;size:50;" json:"status"` // 状态
Iscertificate bool `gorm:"column:is_certificate;type:bool;" json:"is_certificate"` // 是否颁发证书
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间(审核通过时间)
}
3.4 评估配置表 (EvaluationConfig)
type EvaluationConfig struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
CourseID int64 `gorm:"column:course_id;type:bigint;not null" json:"course_id"` // 课程ID
ExamID int64 `gorm:"column:exam_id;type:bigint;not null" json:"exam_id"` // 考试ID
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"` // 用户ID
EvaluationType string `gorm:"column:evaluation_type;type:varchar(50);not null" json:"evaluation_type"` // 评估类型: exam, homework, self_study
Name string `gorm:"column:name;type:varchar(100);not null" json:"name"` // 标准名称
PassScoreRate float64 `gorm:"column:pass_score_rate;type:decimal(5,2);not null" json:"pass_score_rate"` // 及格分数百分比
ExcellentScoreRate float64 `gorm:"column:excellent_score_rate;type:decimal(5,2);not null" json:"excellent_score_rate"` // 优秀分数百分比
PassDurationRate float64 `gorm:"column:pass_duration_rate;type:decimal(5,2);not null" json:"pass_duration_rate"` // 及格时长百分比
ExcellentDurationRate float64 `gorm:"column:excellent_duration_rate;type:decimal(5,2);not null" json:"excellent_duration_rate"` // 优秀时长百分比
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
}
4. 学习进度模块
4.1 学习进度表 (LearningProgress)
type LearningProgress struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
AssignmentID int64 `gorm:"column:assignment_id;type:bigint;" json:"assignment_id"` // 关联作业ID
AssignmentActionID int64 `gorm:"column:assignment_action_id;type:bigint;" json:"assignment_action_id"` // 关联作业动作ID
ClassScheduleID int64 `gorm:"column:class_schedule_id;type:bigint;" json:"class_schedule_id"` // 课表ID
SummaryID int64 `gorm:"column:summary_id;type:bigint;" json:"summary_id"` // 关联作业进度汇总ID
StudentID int64 `gorm:"column:student_id;type:bigint;" json:"student_id"` // 学生ID
TeacherID int64 `gorm:"column:teacher_id;type:bigint;" json:"teacher_id"` // 批阅教师ID
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"`
MajorID int64 `gorm:"column:major_id;type:bigint;" json:"major_id"`
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"`
ActionType string `gorm:"column:action_type;type:varchar;size:20;" json:"action_type"` // 动作类型(courseware、questions、resources)
Status string `gorm:"column:status;type:varchar;size:20;default:not_started;" json:"status"`
RefID int64 `gorm:"column:ref_id;type:bigint;" json:"ref_id"` // 关联ID(试题ID、课件ID、资料ID等)
Content string `gorm:"column:content;type:text;" json:"content"` // 内容描述
Answer string `gorm:"column:answer;type:text;" json:"answer"` // 答案
CompleteTime int64 `gorm:"column:complete_time;type:bigint;" json:"complete_time"` // 完成时间
StartTime int64 `gorm:"column:start_time;type:bigint;" json:"start_time"` // 开始时间(开始时间)
StartAt int64 `gorm:"column:start_at;" json:"start_at"` // 开始时间(开始时间)
EndAt int64 `gorm:"column:end_at;" json:"end_at"` // 结束时间(截止时间)
Required bool `gorm:"column:required;type:boolean;" json:"required"` // 是否必做
OrderNum int `gorm:"column:order_num;type:int;" json:"order_num"` // 排序序号
Minutes int `gorm:"column:minutes;type:int;" json:"minutes"` // 学习时长(分钟)
UseTime int `gorm:"column:use_time;type:int;" json:"use_time"` // 使用时长(分)
GetScore int `gorm:"column:get_score;type:int;" json:"get_score"` //获得分数
Score int `gorm:"column:score;type:int;" json:"score"` // 参考分数
RecordedBy string `gorm:"column:recorded_by;type:varchar;size:20;default:system;" json:"recorded_by"` // 记录来源(system/manual)
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
ReviewAt int64 `gorm:"column:review_at;" json:"review_at"` // 批阅时间
ReviewComment string `gorm:"column:review_comment;type:text;" json:"review_comment"` //批语
}
4.2 学习进度汇总表 (LearningProgressSummary)
type LearningProgressSummary struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
StudentID int64 `gorm:"column:student_id;type:bigint;" json:"student_id"` // 学生ID
ClassScheduleID int64 `gorm:"column:class_schedule_id;type:bigint;" json:"class_schedule_id"` // 课表ID
ClassID int64 `gorm:"column:class_id;type:bigint;" json:"class_id"` // 班级ID
MajorID int64 `gorm:"column:major_id;type:bigint;" json:"major_id"` // 专业ID
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"` // 课程ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 章节ID
TeacherID int64 `gorm:"column:teacher_id;type:bigint;" json:"teacher_id"` // 批阅教师ID
AssignmentID int64 `gorm:"column:assignment_id;type:bigint;" json:"assignment_id"` // 作业ID
Status string `gorm:"column:status;type:varchar;size:20;default:not_started;" json:"status"`
AssignmentName string `gorm:"column:assignment_name;type:varchar;size:255;" json:"assignment_name"` // 作业名称
AssignmentDescription string `gorm:"column:assignment_description;type:text;" json:"assignment_description"` // 作业描述
StartAt int64 `gorm:"column:start_at;" json:"start_at"` // 开始时间(开始时间)
EndAt int64 `gorm:"column:end_at;" json:"end_at"` // 结束时间(截止时间)
TotalStudyTime int `gorm:"column:total_study_time;type:int;default:0;" json:"total_study_time"` // 总学习时长(秒)
GetScore int `gorm:"column:get_score;type:int;" json:"get_score"` //获得分数
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
ReviewAt int64 `gorm:"column:review_at;" json:"review_at"` // 批阅时间
ReviewComment string `gorm:"column:review_comment;type:text;" json:"review_comment"` //批语
}
5. 班级管理模块
5.1 班级表 (Classes)
用于管理学生班级信息。
type Class struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"` // 班级ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
ClassID string `gorm:"column:class_id;type:varchar(50);unique;not null" json:"class_id"` // 班级编号(唯一)
Name string `gorm:"column:name;type:varchar(100);not null" json:"name"` // 班级名称
Description string `gorm:"column:description;type:text" json:"description"` // 班级描述
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(秒级时间戳)
}
字段说明:
ID: 班级唯一标识符,主键,自增UserID: 创建该班级的用户IDClassID: 班级编号,唯一标识一个班级Name: 班级名称Description: 班级描述信息CreatedAt: 记录创建时间,使用秒级时间戳UpdatedAt: 记录更新时间,使用秒级时间戳
5.2 专业表 (Majors)
用于管理专业信息。
type Majors struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"` // 专业ID
ParentID int64 `gorm:"column:parent_id;type:bigint;" json:"parent_id"` // 父专业ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
MajorID string `gorm:"column:major_id;type:varchar(50);unique;not null" json:"major_id"` // 专业编号(唯一)
Name string `gorm:"column:name;type:varchar(100);not null" json:"name"` // 专业名称
Description string `gorm:"column:description;type:text" json:"description"` // 专业描述
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(秒级时间戳)
}
字段说明:
ID: 专业唯一标识符,主键,自增ParentID: 父专业ID,用于构建专业层次结构,0表示顶级专业UserID: 创建该专业的用户IDMajorID: 专业编号,唯一标识一个专业Name: 专业名称Description: 专业描述信息CreatedAt: 记录创建时间,使用秒级时间戳UpdatedAt: 记录更新时间,使用秒级时间戳
5.3 教室表 (Classroom)
用于管理教室资源信息。
type Classroom struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
Title string `gorm:"column:title;type:varchar;size:255;" json:"title"` // 教室名称
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
Description string `gorm:"column:description;type:varchar;size:255;" json:"description"` // 教室描述
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(秒级时间戳)
}
字段说明:
ID: 教室唯一标识符,主键,自增Title: 教室名称UserID: 创建该教室的用户IDDescription: 教室描述信息CreatedAt: 记录创建时间,使用秒级时间戳UpdatedAt: 记录更新时间,使用秒级时间戳
5.4 课表表 (ClassSchedule)
type ClassSchedule struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
ClassID int64 `gorm:"column:class_id;type:bigint;" json:"class_id"` // 班级ID
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"` // 课程ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 章节ID
TeacherID int64 `gorm:"column:teacher_id;type:bigint;" json:"teacher_id"` // 教师ID
TeachingPlanID int64 `gorm:"column:teaching_plan_id;type:bigint;" json:"teaching_plan_id"` // 教学计划ID
StartTime int64 `gorm:"column:start_time;type:bigint;" json:"start_time"` // 开始时间
EndTime int64 `gorm:"column:end_time;type:bigint;" json:"end_time"` // 结束时间
Location string `gorm:"column:location;type:varchar;size:100;" json:"location"` // 地点
Status string `gorm:"column:status;type:varchar;size:20;" json:"status"` // 状态
AssignmentID int64 `gorm:"column:assignment_id;type:bigint;" json:"assignment_id"` // 作业ID
AssignmentType string `gorm:"column:assignment_type;type:varchar;size:50;" json:"assignment_type"` // 作业类型
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
}
6. 资源模块
6.1 资源表 (Resources)
用于管理教学资源,如文档、视频等。
// 资料状态常量定义
const (
ResourceStatusDraft = "draft" // 草稿状态
ResourceStatusReviewing = "reviewing" // 审核中状态
ResourceStatusPublished = "published" // 已发布状态
ResourceStatusArchived = "archived" // 已归档状态
)
type Resources struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 创建人ID
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"` // 资料名称
Path string `gorm:"column:path;type:varchar;size:255;" json:"path"` // 资源路径
Size int64 `gorm:"column:size;type:bigint;" json:"size"` // 资源大小
Ext string `gorm:"column:ext;type:varchar;size:255;" json:"ext"` // 扩展名
CategoryID int64 `gorm:"column:category_id;type:bigint;" json:"category_id"` // 分类ID
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 章节ID
Minutes int `gorm:"column:minutes;type:int;" json:"minutes"` // 阅读时间(分钟)
Status string `gorm:"column:status;type:varchar;size:50;" json:"status"` // 状态(draft, reviewing, published)
Description string `gorm:"column:description;type:text;" json:"description"` // 描述信息
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交审核时间
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
Version string `gorm:"column:version;type:varchar;size:20;default:v1.0;" json:"version"` // 版本号
}
字段说明:
ID: 资源唯一标识符,主键,自增UserID: 创建该资源的用户IDName: 资源名称Path: 资源存储路径Size: 资源大小(字节)Ext: 资源文件扩展名CategoryID: 资源分类ID,关联资源分类表ChapterID: 章节ID,关联章节表Minutes: 预估阅读时间(分钟)Status: 资源状态,包括草稿、审核中、已发布、已归档Description: 资源描述信息CreatedAt: 记录创建时间UpdatedAt: 记录更新时间SubmitAt: 提交审核时间PublishedAt: 发布时间Version: 资源版本号
6.2 资源分类表 (ResourceCategory)
用于对资源进行分类管理。
type ResourceCategory struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 创建人ID
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"` // 分类名称
ParentID int64 `gorm:"column:parent_id;type:bigint;default:0;" json:"parent_id"` // 上级分类ID(默认为0表示顶级分类)
ChapterID int64 `gorm:"column:chapter_id;type:bigint;" json:"chapter_id"` // 章节ID
Description string `gorm:"column:description;type:text;" json:"description"` // 分类描述
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(Unix 时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(Unix 时间戳)
}
字段说明:
ID: 资源分类唯一标识符,主键,自增UserID: 创建该分类的用户IDName: 分类名称ParentID: 上级分类ID,0表示顶级分类,用于构建分类树结构ChapterID: 章节ID,关联章节表Description: 分类描述信息CreatedAt: 记录创建时间UpdatedAt: 记录更新时间
7. 工作流模块
7.1 工作流表 (Workflow)
用于管理工作流定义。
const (
WorkflowStatusEnable = "enable" // 开启
WorkflowStatusDisable = "disable" // 禁用
)
// 定义模块常量
const (
ModuleSyllabus = "syllabus"
ModuleTeachingPlan = "teaching_plan"
ModuleCourses = "courses"
ModuleCourseware = "courseware"
ModuleResources = "resources"
ModuleQuestions = "questions"
ModulePapers = "papers"
ModuleExams = "exams"
ModuleApprove = "workflow_approve"
ModuleScore = "exam_score"
ModuleCertificates = "certificates"
ModuleSchedule = "class_schedule"
ModuleScheduleSummary = "class_schedule_summary"
ModuleDocuments = "teaching_document"
ModuleKnowledgePoints = "knowledge_points"
ModuleAssignment = "assignment"
)
type Workflow struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
Name string `gorm:"column:name;type:varchar;size:100;" json:"name"` // 流程名称(唯一)
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID(创建者)
Description string `gorm:"column:description;type:varchar;size:255;" json:"description"` // 流程描述
NodeLen int64 `gorm:"column:node_len;type:bigint;" json:"node_len"` // 节点数量
ModuleKey string `gorm:"column:module_key;type:varchar;size:50;" json:"module_key"` // 流程类型(课件审核/资源发布)
Status string `gorm:"column:status;varchar;size:50;" json:"status"` // 流程状态(1:启用,0:禁用)
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(秒级时间戳)
}
字段说明:
ID: 工作流唯一标识符,主键,自增Name: 工作流名称UserID: 创建该工作流的用户IDDescription: 工作流描述信息NodeLen: 工作流节点数量ModuleKey: 模块键值,标识该工作流适用于哪个模块Status: 工作流状态,包括启用和禁用CreatedAt: 记录创建时间UpdatedAt: 记录更新时间
7.2 工作流审批表 (WorkflowApprove)
用于管理工作流审批记录。
const (
WorkflowApproveStatusReviewing = "reviewing"
WorkflowApproveStatusPublished = "published"
WorkflowApproveStatusRejected = "rejected"
WorkflowApproveStatusRevision = "revision" //修订记录
WorkflowApproveStatusBackedUp = "backed_up" //上级打回
WorkflowApproveStatusDeleted = "deleted" // 已废弃
)
const (
WorkflowActionTypeApprove = "approve" //审核操作
WorkflowActionTypeDelete = "delete" //删除操作
)
type WorkflowApprove struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
UserID int64 `gorm:"column:userId;type:bigint;" json:"userId"` // 被审核人ID
CheckerID int64 `gorm:"column:checker_id;type:bigint;" json:"checker_id"` // 审核人ID
StepID int `gorm:"column:step_id;type:bigint;" json:"step_id"` // 步骤序号
UserName string `gorm:"column:username;type:varchar;size:255;" json:"username"` // 审核人用户名
OperatorID int64 `gorm:"column:operator_id;type:bigint;" json:"operator_id"` // 操作人ID
ModuleKey string `gorm:"column:module_key;type:varchar;size:50;" json:"module_key"` // 模块键值
ActionType string `gorm:"column:action_type;type:varchar;size:50;" json:"action_type"` // 操作类型(审核/删除)
WorkflowID int64 `gorm:"column:workflow_id;type:bigint;" json:"workflow_id"` // 流程ID(唯一)
DataID int64 `gorm:"column:data_id;type:bigint;" json:"data_id"` // 数据ID(唯一)
DataTitle string `gorm:"column:data_title;type:varchar;size:255;" json:"data_title"` // 数据标题(唯一)
Status string `gorm:"column:status;type:varchar;size:50;" json:"status"` // 审核状态,例如:待审批、已通过、未通过等
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
ApprovedAt int64 `gorm:"column:approved_at;autoCreateTime" json:"approved_at"` // 审核通过时间(秒级时间戳)
RejectAt int64 `gorm:"column:reject_at;autoCreateTime" json:"reject_at"` // 审核拒绝时间(秒级时间戳)
RejectReason string `gorm:"column:reject_reason;type:varchar;size:255;" json:"reject_reason"` // 审核拒绝原因
Remark string `gorm:"column:remark;type:varchar;size:255;" json:"remark"` // 备注
}
字段说明:
ID: 工作流审批记录唯一标识符,主键,自增UserID: 被审核人IDCheckerID: 审核人IDStepID: 审批步骤序号UserName: 审核人用户名OperatorID: 操作人IDModuleKey: 模块键值ActionType: 操作类型,包括审核和删除WorkflowID: 关联的工作流IDDataID: 被审核数据的IDDataTitle: 被审核数据的标题Status: 审批状态,包括审核中、已发布、已拒绝等CreatedAt: 记录创建时间ApprovedAt: 审核通过时间RejectAt: 审核拒绝时间RejectReason: 审核拒绝原因Remark: 备注信息
8. 证书管理模块
8.1 证书表 (Certificates)
用于管理学员证书信息。
const (
CertificatesStatusDraft = "draft" // 未发布
CertificatesStatusReviewing = "reviewing" // 审核中
CertificatesStatusPublished = "published" // 已发布
CertificatesStatusRejected = "rejected" // 审核拒绝
)
type Certificates struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
StudentID int64 `gorm:"column:student_id;type:bigint;" json:"student_id"`
ExamID int64 `gorm:"column:exam_id;type:bigint;" json:"exam_id"`
ScoreID int64 `gorm:"column:score_id;type:bigint;" json:"score_id"`
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"` // 证书名称(冗余字段,用于打印模板)
Score int `gorm:"column:score;type:int;" json:"score"` // 总分数
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 提交人ID
CertNumber string `gorm:"column:cert_number;uniqueIndex;type:varchar;size:50;" json:"cert_number"` // 证书编号
Signature string `gorm:"column:signature;type:text;" json:"signature"` // 数字签名(SM2算法)
QrCode string `gorm:"column:qr_code;type:text;" json:"qr_code"` // 二维码内容
BarCode string `gorm:"column:bar_code;type:text;" json:"bar_code"` // 条形码内容
TemplateID int64 `gorm:"column:template_id;type:bigint;" json:"template_id"` // 印刷模板ID
Address string `gorm:"column:address;type:varchar;size:255;" json:"address"` // 邮寄地址
TrackingNumber string `gorm:"column:tracking_number;type:varchar;size:100;" json:"tracking_number"` // 物流单号
IsPrinted int `gorm:"column:is_printed;type:int;" json:"is_printed"` // 是否已打印(0:未打印,1:已打印)
Status string `gorm:"column:status;type:varchar;size:50;" json:"status"`
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
PrintedAt int64 `gorm:"column:printed_at;" json:"printed_at"` // 打印时间
RevokedAt int64 `gorm:"column:revoked_at;" json:"revoked_at"` // 撤销时间
RevokeReason string `gorm:"column:revoke_reason;type:text;" json:"revoke_reason"` // 撤销原因
}
字段说明:
ID: 证书唯一标识符,主键,自增StudentID: 学生IDExamID: 考试IDScoreID: 成绩IDName: 证书名称(冗余字段,用于打印模板)Score: 考试总分数UserID: 提交人IDCertNumber: 证书编号,唯一Signature: 数字签名(SM2算法)QrCode: 二维码内容BarCode: 条形码内容TemplateID: 印刷模板ID,关联证书模板表Address: 邮寄地址TrackingNumber: 物流单号IsPrinted: 是否已打印(0:未打印,1:已打印)Status: 证书状态,包括草稿、审核中、已发布、审核拒绝CreatedAt: 记录创建时间UpdatedAt: 记录更新时间SubmitAt: 提交审核时间PublishedAt: 发布时间PrintedAt: 打印时间RevokedAt: 撤销时间RevokeReason: 撤销原因
8.2 证书模板表 (IdTpl)
用于管理证书模板信息。
// IdTpl 表示模版模型
type IdTpl struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"` // 模版ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
Name string `gorm:"column:name;type:varchar(100);not null" json:"name"` // 模版名称
Content string `gorm:"column:content;type:text" json:"content"` // 模版内容
HtmlContent string `gorm:"column:html_content;type:text" json:"html_content"` // 模版内容(HTML)
Description string `gorm:"column:description;type:text" json:"description"` // 模版描述
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(秒级时间戳)
}
字段说明:
ID: 证书模板唯一标识符,主键,自增UserID: 创建该模板的用户IDName: 模板名称Content: 模板内容(纯文本格式)HtmlContent: 模板内容(HTML格式)Description: 模板描述信息CreatedAt: 记录创建时间,使用秒级时间戳UpdatedAt: 记录更新时间,使用秒级时间戳
9. 作业管理模块
9.1 作业表 (Assignment)
用于管理下发给学生的作业信息。
const (
AssignmentActionTypeQuestion = "questions" // 做试题 关联Questions表
AssignmentActionTypeCourseware = "courseware" // 看课件 关联Courseware表
AssignmentActionTypeResources = "resources" // 看资料 关联Resources表
)
// 状态定义
const (
AssignmentStatusDraft = "draft" //草稿
AssignmentStatusPublished = "published" //已发布
AssignmentStatusReviewing = "reviewing" //审核中
AssignmentStatusRejected = "rejected" //驳回
)
// 下发作业管理
type Assignment struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
ClassScheduleID int64 `gorm:"column:class_schedule_id;type:bigint;" json:"class_schedule_id"` // 课表ID
CourseID int64 `gorm:"column:course_id;type:bigint;" json:"course_id"` // 课程ID
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"` // 作业名称
ActionType string `gorm:"column:action_type;type:varchar;size:20;" json:"action_type"` // 动作类型
StartAt int64 `gorm:"column:start_at;" json:"start_at"` // 开始时间(开始时间)
EndAt int64 `gorm:"column:end_at;" json:"end_at"` // 结束时间(截止时间)
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 下发教师ID
Description string `gorm:"column:description;type:text;" json:"description"` // 描述
Status string `gorm:"column:status;varchar;size:50;" json:"status"` // 状态
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间(审核通过时间)
}
字段说明:
ID: 作业唯一标识符,主键,自增ClassScheduleID: 课表ID,关联课表表CourseID: 课程ID,关联课程表Name: 作业名称ActionType: 动作类型,包括试题、课件、资料等StartAt: 作业开始时间(时间戳)EndAt: 作业结束时间(时间戳)UserID: 下发教师IDDescription: 作业描述信息Status: 作业状态,包括草稿、已发布、审核中、驳回CreatedAt: 记录创建时间UpdatedAt: 记录更新时间SubmitAt: 提交审核时间PublishedAt: 发布时间
9.2 作业动作表 (AssignmentActions)
用于管理作业中的具体动作信息。
type AssignmentActions struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
AssignmentID int64 `gorm:"column:assignment_id;type:bigint;" json:"assignment_id"` // 关联作业ID
ActionType string `gorm:"column:action_type;type:varchar;size:20;" json:"action_type"` // 动作类型
RefID int64 `gorm:"column:ref_id;type:bigint;" json:"ref_id"` // 关联ID(试题ID、课件ID、资料ID等)
Content string `gorm:"column:content;type:text;" json:"content"` // 内容描述
Required bool `gorm:"column:required;type:boolean;" json:"required"` // 是否必做
Status string `gorm:"column:status;varchar;size:50;" json:"status"` // 状态
OrderNum int `gorm:"column:order_num;type:int;" json:"order_num"` // 排序序号
Minutes int `gorm:"column:minutes;type:int;" json:"minutes"` // 学习时长(分钟)
Score int `gorm:"column:score;type:int;" json:"score"` // 最低分数
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
}
字段说明:
ID: 作业动作唯一标识符,主键,自增AssignmentID: 关联作业IDActionType: 动作类型RefID: 关联ID(试题ID、课件ID、资料ID等)Content: 内容描述Required: 是否必做Status: 状态OrderNum: 排序序号Minutes: 学习时长(分钟)Score: 最低分数要求CreatedAt: 记录创建时间
10. 教学计划与大纲模块
10.1 教学计划表 (TeachingPlan)
用于管理教学计划信息。
const (
TeachingPlanStatusDraft = "draft" // 草稿
TeachingPlanStatusReviewing = "reviewing" // 审核中
TeachingPlanStatusPublished = "published" // 已发布
TeachingPlanStatusRejected = "rejected" // 审核拒绝
)
// 教学计划要关联已发布的大纲,班级(多个)
type TeachingPlan struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
SyllabusID int64 `gorm:"column:syllabus_id;type:bigint;" json:"syllabus_id"` // 大纲ID
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
Name string `gorm:"column:name;type:varchar;size:200;" json:"name"`
Term string `gorm:"column:term;type:varchar;size:100;" json:"term"` // 学期(YYYY-YYYY-N格式)
ClassroomRequirements string `gorm:"column:classroom_requirements;type:text;" json:"classroom_requirements"` // 教室需求描述
Status string `gorm:"column:status;type:varchar;size:20;" json:"status"`
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
StartAt int64 `gorm:"column:start_at;" json:"start_at"` // 开始时间(计划开始时间)
EndAt int64 `gorm:"column:end_at;" json:"end_at"` // 结束时间(计划截止时间)
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at"` // 提交时间(审核提交时间)
PublishedAt int64 `gorm:"column:published_at;" json:"published_at"` // 发布时间
Version string `gorm:"column:version;type:varchar;size:20;default:v1.0;" json:"version"` // 版本号
PreviousID int64 `gorm:"column:previous_id;type:bigint;" json:"previous_id"` // 前序计划ID(用于调整关联)
}
字段说明:
ID: 教学计划唯一标识符,主键,自增SyllabusID: 关联的教学大纲IDUserID: 创建用户IDName: 教学计划名称Term: 学期(YYYY-YYYY-N格式)ClassroomRequirements: 教室需求描述Status: 教学计划状态,包括草稿、审核中、已发布、审核拒绝CreatedAt: 记录创建时间UpdatedAt: 记录更新时间StartAt: 计划开始时间EndAt: 计划结束时间SubmitAt: 提交审核时间PublishedAt: 发布时间Version: 版本号PreviousID: 前序计划ID(用于调整关联)
10.2 教学大纲表 (Syllabus)
用于管理教学大纲信息。
const (
SyllabusStatusDraft = "draft" // 草稿
SyllabusStatusReviewing = "reviewing" // 审查中
SyllabusStatusRejected = "rejected" // 驳回
SyllabusStatusPublished = "published" // 已发布
SyllabusStatusRevision = "revision" // 修订中
SyllabusStatusDeleted = "deleted" // 已废弃
)
type Syllabus struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id" comment:"主键ID"`
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id" comment:"用户ID"`
Name string `gorm:"column:name;type:varchar(100);not null" json:"name" comment:"课程名称"`
Goals string `gorm:"column:goals;type:text;" json:"goals" comment:"教学目标"` // 教学目标
Description string `gorm:"column:description;type:text;" json:"description" comment:"大纲描述"` // 大纲描述
Reference string `gorm:"column:reference;type:text;" json:"reference" comment:"参考文献"` // 参考文献
RevisionNotes string `gorm:"column:revision_notes;type:text;" json:"revision_notes" comment:"修订说明"` // 修订说明
Status string `gorm:"column:status;type:varchar(20);not null" json:"status" comment:"课程状态"` // 课程状态
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at" comment:"创建时间"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" comment:"更新时间"`
SubmitAt int64 `gorm:"column:submit_at;" json:"submit_at" comment:"提交时间"` // 提交时间
PublishedAt int64 `gorm:"column:published_at;" json:"published_at" comment:"发布时间"` // 发布时间
EffectiveDate int64 `gorm:"column:effective_date;" json:"effective_date" comment:"生效时间"` // 生效时间
Version string `gorm:"column:version;type:varchar(30);default:v1.0;" json:"version" comment:"版本号"` // 版本号
}
字段说明:
ID: 教学大纲唯一标识符,主键,自增UserID: 创建用户IDName: 课程名称Goals: 教学目标Description: 大纲描述Reference: 参考文献RevisionNotes: 修订说明Status: 教学大纲状态,包括草稿、审查中、驳回、已发布、修订中、已废弃CreatedAt: 记录创建时间UpdatedAt: 记录更新时间SubmitAt: 提交审核时间PublishedAt: 发布时间EffectiveDate: 生效时间Version: 版本号
10.3 教材表 (Textbook)
用于管理教材信息。
type Textbook struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
Title string `gorm:"column:title;type:varchar;size:255;" json:"title"` // 教材名称
UserID int64 `gorm:"column:user_id;type:bigint;" json:"user_id"` // 用户ID
Author string `gorm:"column:author;type:varchar;size:100;" json:"author"` // 作者
Isbn string `gorm:"column:isbn;type:varchar;size:50;" json:"isbn"` // ISBN编号
Publisher string `gorm:"column:publisher;type:varchar;size:100;" json:"publisher"` // 出版社
Edition string `gorm:"column:edition;type:varchar;size:50;" json:"edition"` // 版本号
FileName string `gorm:"column:file_name;type:varchar;size:255;" json:"file_name"` // 文件名
FileType string `gorm:"column:file_type;type:varchar;size:50;" json:"file_type"` // 文件类型
FilePath string `gorm:"column:file_path;type:varchar;size:255;" json:"file_path"` // 文件路径
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"` // 创建时间(秒级时间戳)
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // 更新时间(秒级时间戳)
}
字段说明:
ID: 教材唯一标识符,主键,自增Title: 教材名称UserID: 创建用户IDAuthor: 作者Isbn: ISBN编号Publisher: 出版社Edition: 版本号FileName: 文件名FileType: 文件类型FilePath: 文件路径CreatedAt: 记录创建时间UpdatedAt: 记录更新时间
11. 评估配置模块
11.1 评估配置表 (EvaluationConfig)
用于管理评估配置信息。
// EvaluationConfig 评估配置表
type EvaluationConfig struct {
ID int64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:bigint;" json:"id"`
CourseID int64 `gorm:"column:course_id;type:bigint;not null" json:"course_id"` // 课程ID
ExamID int64 `gorm:"column:exam_id;type:bigint;not null" json:"exam_id"` // 考试ID
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"` // 用户ID
EvaluationType string `gorm:"column:evaluation_type;type:varchar(50);not null" json:"evaluation_type"` // 评估类型: exam, homework, self_study
Name string `gorm:"column:name;type:varchar(100);not null" json:"name"` // 标准名称
PassScoreRate float64 `gorm:"column:pass_score_rate;type:decimal(5,2);not null" json:"pass_score_rate"` // 及格分数百分比
ExcellentScoreRate float64 `gorm:"column:excellent_score_rate;type:decimal(5,2);not null" json:"excellent_score_rate"` // 优秀分数百分比
PassDurationRate float64 `gorm:"column:pass_duration_rate;type:decimal(5,2);not null" json:"pass_duration_rate"` // 及格时长百分比
ExcellentDurationRate float64 `gorm:"column:excellent_duration_rate;type:decimal(5,2);not null" json:"excellent_duration_rate"` // 优秀时长百分比
CreatedAt int64 `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
}
字段说明:
ID: 评估配置唯一标识符,主键,自增CourseID: 课程IDExamID: 考试IDUserID: 创建用户IDEvaluationType: 评估类型,包括考试、作业、自学等Name: 标准名称PassScoreRate: 及格分数百分比ExcellentScoreRate: 优秀分数百分比PassDurationRate: 及格时长百分比ExcellentDurationRate: 优秀时长百分比CreatedAt: 记录创建时间UpdatedAt: 记录更新时间
12. SCORM学习记录模块
12.1 SCORM会话表 (ScormSessions)
用于存储SCORM学习记录。
// ScormSessions 存储 SCORM 学习记录
type ScormSessions struct {
ID uint `json:"id" gorm:"primary_key"`
Guid string `gorm:"column:guid;type:varchar;unique;not null;" json:"guid"`
CourseID int64 `json:"course_id" gorm:"comment:课程ID"`
ChapterID int64 `json:"chapter_id" gorm:"comment:章节ID"`
CoursewareID int64 `json:"courseware_id" gorm:"index;comment:课件ID"`
LearnerID string `json:"learner_id" gorm:"type:varchar(255);comment:学员ID"`
LearnerName string `json:"learner_name" gorm:"type:varchar(255);comment:学员姓名"`
ScoID string `json:"sco_id" gorm:"index;comment:SCO 唯一标识"` // resource identifier
AttemptNumber int `json:"attempt_number" gorm:"comment:尝试次数"`
CompletionStatus string `json:"completion_status" gorm:"type:varchar(50);comment:完成状态"` // incomplete, completed, not attempted, unknown
SuccessStatus string `json:"success_status" gorm:"type:varchar(50);comment:成功状态"` // passed, failed, unknown
LessonStatus string `json:"lesson_status" gorm:"type:varchar(50);comment:课程状态"` // not attempted, completed, browed, failed, incomplete, passed, pto, aborted, unknown
Entry string `json:"entry" gorm:"type:varchar(50);comment:入口"`
Location string `json:"location" gorm:"type:varchar(255);comment:学习位置"`
ScoreRaw int `json:"score_raw" gorm:"comment:原始分数"`
ScoreMin int `json:"score_min" gorm:"comment:最小分数"`
ScoreMax int `json:"score_max" gorm:"comment:最大分数"`
ScoreScaled float64 `json:"score_scaled" gorm:"comment:缩放分数"` // 缩放得分(通常 0-1)
TotalTime string `json:"total_time" gorm:"type:varchar(50);comment:总学习时长"`
SessionTime string `json:"session_time" gorm:"type:varchar(50);comment:本次会话时长"`
ProgressMeasure string `json:"progress_measure" gorm:"type:varchar(50);comment:进度测量"` // 浮点数(范围 0.0 ~ 1.0)
SuspendData string `json:"suspend_data" gorm:"type:text;comment:挂起数据"`
Exit string `json:"exit" gorm:"type:varchar(50);comment:退出方式"`
Credit string `json:"credit" gorm:"type:varchar(50);comment:学分"`
Mode string `json:"mode" gorm:"type:varchar(50);comment:模式"`
CMI string `json:"cmi" gorm:"type:json;comment:SCORM CMI 数据"` // 存储所有 CMI 数据的 JSON 字符串
InitialAccessTime int64 `json:"initial_access_time" gorm:"comment:初始访问时间戳"`
LastAccessTime int64 `json:"last_access_time" gorm:"comment:最后访问时间戳"`
Source string `gorm:"column:source;type:varchar(50);comment:记录来源(例如:课程学习,作业提交,自测评估等)"`
TotalSCO int `json:"total_sco" gorm:"comment:总 SCO 数量"` // 课程中 SCO 的总数
TotalActivity int `json:"total_activity" gorm:"comment:总活动数"` //
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime"`
}
字段说明:
ID: SCORM会话唯一标识符,主键,自增Guid: 会话唯一标识符CourseID: 课程IDChapterID: 章节IDCoursewareID: 课件IDLearnerID: 学员IDLearnerName: 学员姓名ScoID: SCO唯一标识AttemptNumber: 尝试次数CompletionStatus: 完成状态,包括未完成、已完成、未尝试、未知SuccessStatus: 成功状态,包括通过、未通过、未知LessonStatus: 课程状态Entry: 入口Location: 学习位置ScoreRaw: 原始分数ScoreMin: 最小分数ScoreMax: 最大分数ScoreScaled: 缩放分数TotalTime: 总学习时长SessionTime: 本次会话时长ProgressMeasure: 进度测量SuspendData: 挂起数据Exit: 退出方式Credit: 学分Mode: 模式CMI: SCORM CMI数据InitialAccessTime: 初始访问时间戳LastAccessTime: 最后访问时间戳Source: 记录来源TotalSCO: 总SCO数量TotalActivity: 总活动数CreatedAt: 记录创建时间UpdatedAt: 记录更新时间
13. 用户学习活动模块
13.1 用户学习活动表 (UserLearningActivities)
用于存储所有类型的学习活动记录。
type ActivityType string
const (
ActivityTypeQuestionSubmission ActivityType = "question_submission" // 试题提交
ActivityTypeTheoryCourseware ActivityType = "theory_courseware" // SCORM课件学习
ActivityTypeVirtualCourseware ActivityType = "virtual_courseware" // 虚拟课件学习
ActivityTypeMaterialStudy ActivityType = "material_study" // 资料学习
)
// UserLearningActivities 存储所有类型的学习活动记录
type UserLearningActivities struct {
ID int64 `json:"id" gorm:"primary_key;AUTO_INCREMENT"`
Guid string `gorm:"column:guid;type:varchar(255);unique;not null;comment:学习记录的唯一标识符"`
UserID int64 `json:"user_id" gorm:"column:user_id;type:bigint;not null;index;comment:学员ID"`
Source string `gorm:"column:source;type:varchar(50);comment:记录来源(例如:课程学习,作业提交,自测评估等)"`
ActivityType string `json:"activity_type" gorm:"column:activity_type;type:varchar(50);not null;index;comment:活动类型(e.g., question_submission, scorm_courseware, virtual_courseware, material_study)"`
ActivityID int64 `json:"activity_id" gorm:"column:activity_id;type:bigint;index;comment:对应具体活动记录的ID(例如:Question.ID, ScormSessions.ID, VirtualCoursewareSubmitHistory.ID)"`
CompletionStatus string `json:"completion_status" gorm:"column:completion_status;type:varchar(50);comment:完成状态(e.g., incomplete, completed, passed, failed, browsed, unknown)"`
Score int `json:"score" gorm:"column:score;type:int;comment:得分"`
TotalTimeSpent int64 `json:"total_time_spent" gorm:"column:total_time_spent;type:int;comment:总学习/活动用时(秒)"`
SubmittedAt int64 `json:"submitted_at" gorm:"column:submitted_at;type:bigint;not null;comment:记录提交/更新时间戳"`
SubmitContext string `json:"submit_context" gorm:"column:submit_context;type:text;comment:存储特定活动类型的详细数据(JSON格式)"`
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime"`
}
字段说明:
ID: 用户学习活动唯一标识符,主键,自增Guid: 学习记录的唯一标识符UserID: 学员IDSource: 记录来源ActivityType: 活动类型,包括试题提交、SCORM课件学习、虚拟课件学习、资料学习ActivityID: 对应具体活动记录的IDCompletionStatus: 完成状态Score: 得分TotalTimeSpent: 总学习/活动用时(秒)SubmittedAt: 记录提交/更新时间戳SubmitContext: 存储特定活动类型的详细数据(JSON格式)CreatedAt: 记录创建时间UpdatedAt: 记录更新时间
