-- ----------------------------
-- Table structure for sys_log_longtext
-- ----------------------------
DROP TABLE IF EXISTS `sys_log_longtext`;
CREATE TABLE `sys_log_longtext`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sys_id` bigint NULL DEFAULT NULL,
  `params` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '请求参数',
  `result` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '结果',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_log_mediumtext
-- ----------------------------
DROP TABLE IF EXISTS `sys_log_mediumtext`;
CREATE TABLE `sys_log_mediumtext`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sys_id` bigint NULL DEFAULT NULL,
  `params` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '请求参数',
  `result` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '结果',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sys_id`(`sys_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_log_text
-- ----------------------------
DROP TABLE IF EXISTS `sys_log_text`;
CREATE TABLE `sys_log_text`  (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `sys_id` bigint NULL DEFAULT NULL,
  `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '请求参数',
  `result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '结果',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `sys_id`(`sys_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;



drop table if exists resources_question_snapshot;

/*==============================================================*/
/* Table: resources_question_snapshot                           */
/*==============================================================*/
CREATE TABLE `resources_question_snapshot` (
     `resources_question_snapshot_id` bigint(20) NOT NULL COMMENT '题目快照ID',
     `teacher_open_course_question_setting_id` bigint(20) NOT NULL COMMENT '开课题目配置ID',
     `teacher_open_course_merge_course_info_id` bigint(20) DEFAULT NULL COMMENT '开课课程ID',
     `question_type` int(2) DEFAULT NULL COMMENT '题型(1单选 2多选 3判断 4填空 5分析)',
     `question_score` decimal(3,1) DEFAULT NULL COMMENT '分值',
     `question_stem` varchar(3000) DEFAULT NULL COMMENT '题干',
     `question_option_a` varchar(1000) DEFAULT NULL COMMENT '选项A',
     `question_option_b` varchar(1000) DEFAULT NULL COMMENT '选项B',
     `question_option_c` varchar(1000) DEFAULT NULL COMMENT '选项C',
     `question_option_d` varchar(1000) DEFAULT NULL COMMENT '选项D',
     `question_option_e` varchar(1000) DEFAULT NULL COMMENT '选项E',
     `question_answer` varchar(255) DEFAULT NULL COMMENT '答案（单选是一个 多选是多个 判断是对错）',
     `question_analysis` varchar(3000) DEFAULT NULL COMMENT '解析',
     `question_status` int(2) DEFAULT NULL COMMENT '题目状态 （1上架， 2下架）',
     `user_id` bigint(20) DEFAULT NULL COMMENT '后台用户ID',
     `org_id` bigint(20) DEFAULT NULL COMMENT '组织机构ID',
     PRIMARY KEY (`resources_question_snapshot_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='资源管理 - 题库管理-快照-关联来源';



ALTER TABLE hands_on ADD  COLUMN add_time datetime COMMENT '添加时间';
ALTER TABLE hands_on ADD  COLUMN org_id bigint(20) COMMENT '组织机构ID';
ALTER TABLE hands_on ADD  COLUMN user_id bigint(20) COMMENT '后台用户ID';
ALTER TABLE hands_on ADD  COLUMN training_data VARCHAR(1000) COMMENT '数据集（多个地址，逗号隔开）';

drop table if exists hands_on_achievement;
CREATE TABLE `hands_on_achievement` (
    `hand_on_achievement_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `hand_on_id` bigint(20) DEFAULT NULL COMMENT '实操项目ID',
    `class_id` bigint(20) DEFAULT NULL COMMENT '班级ID',
    `student_id` bigint(20) DEFAULT NULL COMMENT '学生ID',
    `video_score`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '观看视频得分',
    `ppt_score` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '观看PTT得分',
    `theory_score` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '理论测评得分',
    `practical_training_score` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '实训操作步骤得分',
    `report_writing_score` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '报告撰写得分',
    `total_score` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '合计得分',
    `hand_on_achievement_status` int(11) DEFAULT NULL COMMENT '状态(1正常 2删除)',
    `add_time` datetime(3) DEFAULT NULL COMMENT '添加时间',
    `org_id` bigint(20) DEFAULT NULL COMMENT '组织机构ID',
    `user_id` bigint(20) DEFAULT NULL COMMENT '后台用户ID',
    PRIMARY KEY (`hand_on_achievement_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=244 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='课程实操-实操成绩';
drop table if exists teacher_open_course_score_weight;
create table teacher_open_course_score_weight
(
    teacher_open_course_id bigint not null comment '课程id',
    teacher_id           bigint comment '老师id',
    sign_in_result       varchar(255) comment '签到成绩(权重)',
    chapter_contact_result varchar(255) comment '章节联系成绩(权重)',
    course_practice_result varchar(255) comment '课程实操成绩(权重)',
    homework_result      varchar(255) comment '作业成绩(权重)',
    examination_result   varchar(255) comment '考试成绩(权重)',
    interaction_result   varchar(255) comment '互动成绩(权重)',
    sign_in_result_setting varchar(255) comment '签到成绩设置1签到次数2到课到率',
    sign_in_score        varchar(255) comment '签到次数_每签到一次分数',
    chapter_contact_result_setting varchar(255) comment '章节联系设置1正确率积分2平均完成度计分',
    course_practice_result_setting varchar(255) comment '课程实操成绩设置1平均分2平均完成进度',
    homework_result_setting varchar(255) comment '作业成绩设置1平均分(默认1)',
    examination_result_setting varchar(255) comment '考试成绩设置1平均分(默认1)',
    interaction_result_setting varchar(255) comment '互动成绩设置1留言2提问3回答',
    interaction_result_message_score varchar(255) comment '互动成绩留言得分',
    interaction_result_question_score varchar(255) comment '互动成绩提问得分',
    interaction_result_answer_score varchar(255) comment '互动成绩回答得分',
    result_status_setting varchar(255) comment '成绩状态设置1二分法2等级法3字母法',
    dichotomy_score      varchar(255) comment '二分法分数',
    excellent_score      varchar(255) comment '等级法优秀分数',
    good_score           varchar(255) comment '等级法良好分数',
    secondary_score      varchar(255) comment '等级法中等分数',
    pass_score           varchar(255) comment '等级法及格分数',
    lettera_score        varchar(255) comment '字母法A分数',
    letterb_score        varchar(255) comment '字母法B分数',
    letterc_score        varchar(255) comment '字母法C分数',
    letterd_score        varchar(255) comment '字母法D分数',
    org_id               bigint comment '组织ID',
    user_id              bigint comment '用户ID',
    create_time          bigint comment '创建时间',
    primary key (teacher_open_course_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table teacher_open_course_score_weight comment '教师-我的课程-成绩权重';

ALTER TABLE teacher_open_course_score_dashboard ADD  COLUMN teacher_open_course_id bigint(20) COMMENT '课程开课ID';

ALTER TABLE resources_application ADD  COLUMN link_secret_key varchar(255) COMMENT '链接秘钥';

drop table if exists teacher_open_course_knowledge_point_relation;
CREATE TABLE `teacher_open_course_knowledge_point_relation` (
    `teacher_open_course_knowledge_relation_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '关联ID',
    `teacher_open_course_knowledge_point_id` bigint(20) NOT NULL COMMENT '课程开课-知识点ID',
    `bussiness_id` bigint(20) NOT NULL COMMENT '业务ID',
    `bussiness_type` bigint(20) NOT NULL COMMENT '业务类型1章节练习2课程实操, 业务id是主键自增存在重复',
    `create_time` datetime DEFAULT NULL COMMENT '创建时间',
    `org_id` bigint(20) DEFAULT NULL COMMENT '组织ID',
    `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
    `del_flag` int(11) NOT NULL DEFAULT '0' COMMENT '是否删除 1删除，0未删除',
    PRIMARY KEY (`teacher_open_course_knowledge_relation_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='教师-课程开课-知识点-关联表';


# 院校增加默认管理员
ALTER TABLE universities_colleges ADD COLUMN universities_colleges_default_admin_user_id bigint(20) COMMENT '院校默认管理员用户ID';

drop table if exists hands_on_simulation_tasks_file;

create table hands_on_simulation_tasks_file
(
    task_file_id         bigint not null comment '实操任务文件ID',
    hands_on_id          bigint comment '实操ID',
    task_id              bigint comment '任务ID',
    file_url             varchar(255) comment '文件地址',
    file_type            varchar(32) comment '文件类型',
    file_time            varchar(32) comment '视频时长',
    file_name            varchar(64) comment '文件名称',
    add_time             datetime comment '添加时间',
    user_id              bigint comment '用户ID',
    org_id               bigint comment '部门ID',
    primary key (task_file_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table hands_on_simulation_tasks_file comment '课程实操-实训任务附件表';


drop table if exists teacher_open_course_merge_resources_question;

/*==============================================================*/
/* Table: teacher_open_course_merge_resources_question          */
/*==============================================================*/
create table teacher_open_course_merge_resources_question
(
    teacher_open_course_merge_resources_question_id bigint unsigned not null comment 'ID',
    teacher_open_course_id bigint comment '开课ID',
    teacher_open_course_merge_course_info_id       bigint comment '开课课程ID',
    question_type        int(2) comment '题型(1单选 2多选 3判断 4填空 5分析)',
    question_score       decimal(3,1) comment '分值',
    question_stem        varchar(3000) comment '题干',
    question_option_a    varchar(1000) comment '选项A',
    question_option_b    varchar(1000) comment '选项B',
    question_option_c    varchar(1000) comment '选项C',
    question_option_d    varchar(1000) comment '选项D',
    question_option_e    varchar(1000) comment '选项E',
    question_answer      varchar(255) comment '答案（单选是一个 多选是多个 判断是对错）',
    question_analysis    varchar(3000) comment '解析',
    question_status      int(2) comment '题目状态 （1上架， 2下架）',
    user_id              bigint comment '后台用户ID',
    org_id               bigint comment '组织机构ID',
    primary key (teacher_open_course_merge_resources_question_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table teacher_open_course_merge_resources_question comment '开课-题库管理-离线';


drop table if exists teacher_open_course_merge_course_info;

/*==============================================================*/
/* Table: teacher_open_course_merge_course_info                 */
/*==============================================================*/
create table teacher_open_course_merge_course_info
(
    teacher_open_course_merge_course_info_id bigint unsigned not null auto_increment comment 'ID',
    teacher_open_course_id bigint comment '开课ID',
    course_info_name     varchar(255) comment '名称（课程名 或 章名 或 节名）',
    course_info_thumbnail varchar(255) comment '课程缩略图',
    course_label_id      bigint comment '课程标签ID',
    course_info_basics_count integer comment '课程学习人数基数',
    course_info_content  varchar(3000) comment '课程简介',
    course_info_status   int(2) comment '状态(1启用 2禁用 3删除)',
    course_info_type     int(2) comment '类型(1课程 2章 3节)',
    course_info_parent_id bigint comment '父节点ID',
    course_video_id      bigint comment '视频ID(resources_info_id，和节对应)',
    course_courseware_id bigint comment '课件ID(resources_info_id，和节对应)',
    course_enclosure_ids varchar(3000) comment '附件IDs(resources_info_id，和节对应)',
    resources_question_ids varchar(3000) comment '客观题IDs（和章对应）',
    resources_competition_ids varchar(3000) comment '竞赛题IDs（和章对应）',
    resources_training_ids varchar(3000) comment '实训题IDs（和章对应）',
    org_id               bigint comment '组织机构ID',
    user_id              bigint comment '后台用户ID',
    primary key (teacher_open_course_merge_course_info_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table teacher_open_course_merge_course_info comment '开课- 课程配置-离线';

drop table if exists teacher_open_course_hands_on;
CREATE TABLE `teacher_open_course_hands_on` (
`hands_on_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '实操主键',
`teacher_open_course_id` bigint(20) DEFAULT NULL COMMENT '开课ID',
`course_info_id` bigint(20) DEFAULT NULL COMMENT '归属课程',
`course_child_node` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '归属章节',
`hands_on_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '实操名称',
`hands_on_recommend` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '实操介绍',
`add_time` datetime DEFAULT NULL COMMENT '添加时间',
`org_id` bigint(20) DEFAULT NULL COMMENT '组织机构ID',
`user_id` bigint(20) DEFAULT NULL COMMENT '后台用户ID',
`training_data` varchar(1000) DEFAULT NULL COMMENT '数据集（多个地址，逗号隔开）',
PRIMARY KEY (`hands_on_id`) USING BTREE,
KEY `PK_teacher_open_course_id` (`teacher_open_course_id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='教师开课-课程实操';

drop table if exists teacher_open_course_hands_on_simulation_tasks;
CREATE TABLE `teacher_open_course_hands_on_simulation_tasks` (
 `task_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '实训任务id',
 `hands_on_id` bigint(20) DEFAULT NULL COMMENT '实操id(关联主表)',
 `teacher_open_course_id` bigint(20) DEFAULT NULL COMMENT '开课ID',
 `task_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '任务类型',
 `task_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '任务标题',
 `task_score` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '任务分值',
 `task_order` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '任务顺序',
 `task_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '任务状态',
 `assessment_requirements` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '考核要求(A,B,',
 `assessment_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '考核时间分钟(考核要求AC必填)',
 `assessment_content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '考核内容',
 `file_url` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '附件地址',
 `task_list` longtext COMMENT '题目id',
 `org_id` bigint(20) DEFAULT NULL COMMENT '组织机构ID',
 `user_id` bigint(20) DEFAULT NULL COMMENT '后台用户ID',
 `add_time` datetime DEFAULT NULL COMMENT '添加时间',
 PRIMARY KEY (`task_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='教师开课-课程实操-实训任务';

drop table if exists teacher_open_course_hands_on_simulation_tasks_file;
CREATE TABLE `teacher_open_course_hands_on_simulation_tasks_file` (
  `task_file_id` bigint(20) NOT NULL COMMENT '实操任务文件ID',
  `teacher_open_course_id` bigint(20) DEFAULT NULL COMMENT '开课ID',
  `hands_on_id` bigint(20) DEFAULT NULL COMMENT '实操ID',
  `task_id` bigint(20) DEFAULT NULL COMMENT '任务ID',
  `file_url` varchar(255) DEFAULT NULL COMMENT '文件地址',
  `file_type` varchar(32) DEFAULT NULL COMMENT '文件类型',
  `file_time` varchar(32) DEFAULT NULL COMMENT '视频时长',
  `file_name` varchar(64) DEFAULT NULL COMMENT '文件名称',
  `add_time` datetime DEFAULT NULL COMMENT '添加时间',
  `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
  `org_id` bigint(20) DEFAULT NULL COMMENT '部门ID',
  PRIMARY KEY (`task_file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='教师开课-课程实操-实训任务附件表';


ALTER TABLE teacher_open_course_schedule_session ADD  COLUMN teacher_open_course_schedule_session_status_week_detail varchar(100) COMMENT '开课星期 多个逗号隔开 枚举WeekDetailType';

drop table if exists teacher_open_course_merge_schedule_session;

/*==============================================================*/
/* Table: teacher_open_course_merge_schedule_session            */
/*==============================================================*/
create table teacher_open_course_merge_schedule_session
(
    teacher_open_course_merge_schedule_session_id bigint not null comment '课程开课-班级-排课配置-关联ID',
    teacher_open_course_id bigint comment '开课ID',
    teacher_open_course_schedule_session_id bigint comment '课程排课配置ID',
    teacher_open_course_merge_schedule_session_add_time datetime comment '添加时间',
    teacher_open_course_merge_schedule_session_status int(2) comment '状态',
    org_id               bigint comment '组织ID',
    user_id              bigint comment '用户ID',
    primary key (teacher_open_course_merge_schedule_session_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table teacher_open_course_merge_schedule_session comment '课程开课-关联-排课配置';


ALTER TABLE teacher_open_course_chat_log ADD COLUMN chat_log_send_type varchar(50) COMMENT '发送类型 枚举(ChatLogSendTypeEnum)';

ALTER TABLE teacher_open_course_schedule_session_snap ADD COLUMN teacher_open_course_schedule_session_snap_current_week_number int(10) COMMENT '所在时间列表的第几周';

drop table if exists teacher_open_course_merge_resources_info;

/*==============================================================*/
/* Table: teacher_open_course_merge_resources_info              */
/*==============================================================*/
create table teacher_open_course_merge_resources_info
(
    teacher_open_course_merge_resources_info_id bigint unsigned not null auto_increment comment 'ID',
    teacher_open_course_merge_course_info_id       bigint comment '开课课程ID',
    teacher_open_course_id bigint comment '教师开课ID',
    resources_info_name  varchar(255) comment '资源名称',
    resources_info_type  int(2) comment '资源类型 数据字典（resources_info_type）',
    resources_info_content varchar(255) comment '资源内容',
    org_id               bigint comment '组织机构ID',
    user_id              bigint comment '后台用户ID',
    primary key (teacher_open_course_merge_resources_info_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table teacher_open_course_merge_resources_info comment '开课关联- 资源管理-离线';

ALTER TABLE resources_info ADD COLUMN resources_info_files varchar(4000) COMMENT '文件集合';
ALTER TABLE teacher_open_course_merge_resources_info ADD COLUMN resources_info_files varchar(4000) COMMENT '文件集合';


ALTER TABLE teacher_open_course_merge_schedule_session ADD COLUMN teacher_open_course_schedule_session_open_on_holidays tinyint(1) COMMENT '节假日是否排课';
ALTER TABLE teacher_open_course_merge_schedule_session ADD COLUMN teacher_open_course_schedule_session_class_list varchar(4000) COMMENT '开课节次和教室的组合，JSON格式';

-- 回显用
ALTER TABLE resources_question_snapshot ADD COLUMN teacher_open_course_merge_resources_question_id bigint COMMENT '开课题目ID';
ALTER TABLE teacher_open_course_question_log ADD COLUMN question_analysis varchar(1000) COMMENT '解析';
ALTER TABLE teacher_open_course_question_log ADD COLUMN is_tuck int(2) default 0 COMMENT '是否收藏夹';
ALTER TABLE teacher_open_course_question_log ADD COLUMN is_error_favorite int(2) default 0 COMMENT '是否错题库';
ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_update_time datetime COMMENT '修改时间';
ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_finish_time bigint(15) default 1 COMMENT '总用时（秒）';
ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_reply varchar(300) COMMENT '评语';
ALTER TABLE teacher_open_course_question_log ADD COLUMN question_log_add_type varchar(50) COMMENT '题目添加类型（枚举 QuestionLogAddTypeEnum）';

-- 通用的题目配置
drop table if exists general_question_setting;
CREATE TABLE `general_question_setting` (
      `general_question_setting_id` bigint(20) NOT NULL COMMENT '通用题目设置ID',
      `business_id` bigint(20) NOT NULL COMMENT '业务ID',
      `business_type` varchar(50) NOT NULL COMMENT '业务类型（枚举 QuestionBussinessTypeEnum）',
      `general_question_setting_school_class_ids` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '班级ID集合（逗号隔开）',
      `general_question_setting_do_count` int(11) DEFAULT NULL COMMENT '作答次数',
      `general_question_setting_question_no_order` int(11) DEFAULT NULL COMMENT '题目乱序（同一大题内）',
      `general_question_setting_option_no_order` int(11) DEFAULT NULL COMMENT '选项乱序（限单选、多选）',
      `general_question_setting_end_show_qa` int(11) DEFAULT NULL COMMENT '答卷后显示答案解析',
      `general_question_setting_end_show_true_false` int(11) DEFAULT NULL COMMENT '答卷后显示答案对错',
      `general_question_setting_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题目-名称',
      `general_question_start_time` datetime DEFAULT NULL COMMENT '题目开始时间',
      `general_question_end_time` datetime DEFAULT NULL COMMENT '题目结束时间',
      `general_question_setting_type` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '类型 枚举（ResourcesQuestionSnapshotFromTypeEnum）',
      `general_question_setting_require` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题目要求',
      `general_question_setting_file` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '附件，老师上传附件（单文件）',
      `general_question_setting_push_status` int(11) DEFAULT NULL COMMENT '发布状态。 1发布，2未发布',
      `general_question_setting_status` int(11) DEFAULT NULL COMMENT '状态 （1正常 2删除）',
      `general_question_setting_add_time` datetime DEFAULT NULL COMMENT '创建时间',
      `org_id` bigint(20) DEFAULT NULL COMMENT '组织ID',
      `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
      PRIMARY KEY (`general_question_setting_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='系统通用-题目-设置';

drop table if exists general_resources_question_snapshot;
CREATE TABLE `general_resources_question_snapshot` (
     `general_resources_question_snapshot_id` bigint(20) NOT NULL COMMENT '通用题目快照ID',
     `general_question_setting_id` bigint(20) NOT NULL COMMENT '通用题目配置ID',
     `business_course_info_id` bigint(20) DEFAULT NULL COMMENT '业务课程ID',
     `business_course_info_type` varchar(30) DEFAULT NULL COMMENT '业务课程类型（枚举 QuestionBusinessTypeEnum）',
     `question_type` int(2) DEFAULT NULL COMMENT '题型(1单选 2多选 3判断 4填空 5分析)',
     `question_score` decimal(3,1) DEFAULT NULL COMMENT '分值',
     `question_stem` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题干',
     `question_option_a` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项A',
     `question_option_b` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项B',
     `question_option_c` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项C',
     `question_option_d` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项D',
     `question_option_e` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项E',
     `question_answer` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '答案（单选是一个 多选是多个 判断是对错）',
     `question_analysis` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '解析',
     `question_status` int(2) DEFAULT NULL COMMENT '题目状态 （1上架， 2下架）',
     `user_id` bigint(20) DEFAULT NULL COMMENT '后台用户ID',
     `org_id` bigint(20) DEFAULT NULL COMMENT '组织机构ID',
     PRIMARY KEY (`general_resources_question_snapshot_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='资源管理-题库管理-通用快照';

drop table if exists general_question_log;
CREATE TABLE `general_question_log` (
    `general_question_log_id` bigint(20) NOT NULL COMMENT '学生做题日志ID',
    `general_question_setting_id` bigint(20) DEFAULT NULL COMMENT '通用题目配置ID',
    `general_resources_question_snapshot_id` bigint(20) DEFAULT NULL COMMENT '题目快照ID',
    `general_resources_question_log_type` varchar(50) DEFAULT NULL COMMENT '题目日志类型（枚举 GeneralResourcesQuestionLogTypeEnum）',
    `general_question_log_answer` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '学生提交的答案',
    `general_question_log_upload_file` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '附件，学生端上传附件（单文件）',
    `general_question_log_add_time` datetime DEFAULT NULL COMMENT '创建时间',
    `general_question_log_status` int(11) DEFAULT NULL COMMENT '状态（1正常 2删除）',
    `student_id` bigint(20) DEFAULT NULL COMMENT '学生ID',
    `student_score` decimal(3,1) DEFAULT NULL COMMENT '学生得分',
    `question_type` int(2) DEFAULT NULL COMMENT '题型(1单选 2多选 3判断 4填空 5分析)',
    `question_score` decimal(3,1) DEFAULT NULL COMMENT '分值（学生得分）',
    `question_stem` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题干',
    `question_option_a` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项A',
    `question_option_b` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项B',
    `question_option_c` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项C',
    `question_option_d` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项D',
    `question_option_e` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '选项E',
    `question_answer` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '答案（单选是一个 多选是多个 判断是对错）',
    `question_analysis` varchar(1000) DEFAULT NULL COMMENT '解析',
    `is_tuck` int(2) DEFAULT NULL COMMENT '是否收藏夹',
    `is_error_favorite` int(2) DEFAULT NULL COMMENT '是否错题库',
    `general_question_log_update_time` datetime COMMENT '修改时间',
    `general_question_log_finish_time` bigint(10) default 1 COMMENT '总用时（秒）',
    `general_question_log_reply` varchar(300) default 1 COMMENT '评语',
    `question_log_add_type` varchar(50) COMMENT '题目添加类型（枚举 QuestionLogAddTypeEnum）',
    `org_id` bigint(20) DEFAULT NULL COMMENT '组织ID',
    `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
    PRIMARY KEY (`general_question_log_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='题库-通用做题日志';


ALTER TABLE student_client_link ADD COLUMN student_client_link_desc varchar(600) COMMENT '描述说明';

drop table if exists question_log_summary;

/*==============================================================*/
/* Table: question_log_summary                                  */
/*==============================================================*/
create table question_log_summary
(
    question_log_summary_id bigint not null comment '学生做题日志汇总ID',
    question_setting_id  bigint comment '题目配置ID',
    question_setting_name varchar(100) comment '题目配置名称',
    question_setting_type varchar(50) comment '类型 枚举（ResourcesQuestionSnapshotFromTypeEnum）',
    question_log_summary_from_type varchar(50) comment '来源类型 枚举',
    question_setting_total_score float comment '配置的题目总分数',
    question_log_summary_student_total_score float comment '学生总得分',
    person_id            bigint comment '人员ID（学生ID等等）',
    question_log_ids     varchar(2000) comment '关联的做题日志IDs',
    question_log_summary_question_total_count int comment '配置的题目总数',
    question_log_summary_student_do_count int comment '学生做题总数',
    question_log_summary_success_count int comment '正确数量',
    question_log_summary_error_count int comment '错误数量',
    question_log_summary_success_rate float comment '正确率,最大100',
    question_log_summary_current_pass_rate float comment '当前配置的及格比率',
    question_log_summary_is_pass int(2) comment '是否及格',
    finish_second_time   int comment '完成用时(秒)',
    finish_time          varchar(50) comment '完成用时，时间格式',
    question_log_summary_status int(2) comment '状态（1正常 2删除）',
    question_log_summary_add_time datetime comment '添加时间',
    org_id               bigint comment '组织ID',
    user_id              bigint comment '用户ID',
    primary key (question_log_summary_id)
)
    auto_increment = 1
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;

alter table question_log_summary comment '学生-题目日志-分析汇总';

ALTER TABLE teacher_open_course_question_setting ADD COLUMN teacher_open_course_merge_course_info_id bigint(20) COMMENT '关联的章节ID（仅章节练习有值）';
ALTER TABLE teacher_open_course_merge_resources_info ADD COLUMN resources_info_status int(2) COMMENT '资源状态 0 删除 1上架 2下架';
ALTER TABLE teacher_open_course_merge_resources_info ADD COLUMN order_index decimal(10, 6) COMMENT '排序（越小越靠前）';
ALTER TABLE student ADD COLUMN student_gender int(2) COMMENT '性别 -1 未知 1男 2女';

ALTER TABLE teacher ADD COLUMN teacher_gender int(2) COMMENT '性别 -1 未知 1男 2女';

ALTER TABLE hands_on ADD COLUMN hands_on_status int(2) COMMENT '状态 （1上架， 2下架）';
ALTER TABLE resources_competition ADD COLUMN resources_competition_status int(2) COMMENT '状态 （1上架， 2下架）';
ALTER TABLE resources_training ADD COLUMN resources_training_status int(2) COMMENT '状态 （1上架， 2下架）';


ALTER TABLE course_label ADD COLUMN add_type varchar(20) COMMENT '添加类型枚举（AddTypeEnum）';
ALTER TABLE resources_question ADD COLUMN add_type varchar(20) COMMENT '添加类型枚举（AddTypeEnum）';
ALTER TABLE resources_info ADD COLUMN add_type varchar(20) COMMENT '添加类型枚举（AddTypeEnum）';


drop table if exists teaching_management;

/*==============================================================*/
/* Table: teaching_management                                   */
/*==============================================================*/
create table teaching_management
(
    teacher_merge_class_third_id bigint unsigned not null auto_increment comment 'ID',
    university_faculty_info varchar(100) comment '院系信息',
    university_system_info varchar(100) comment '专业信息',
    teacher_info         varchar(100) comment '教师信息',
    school_class_info    varchar(500) comment '班级信息，多个逗号隔开',
    teacher_merge_class_third_add_time datetime comment '创建时间',
    teacher_merge_class_third_status int(2) comment '状态 1正常 2删除',
    user_id              bigint comment '后台用户ID',
    org_id               bigint comment '组织机构ID',
    primary key (teacher_merge_class_third_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table teaching_management comment '授课管理-需要对接外部系统';

ALTER TABLE course_info ADD COLUMN order_index decimal(10, 6) COMMENT '排序（越小越靠前）';

drop table if exists notice_read;

/*==============================================================*/
/* Table: notice_read                                           */
/*==============================================================*/
create table notice_read
(
    notice_read_id       bigint not null comment 'ID',
    person_id            varchar(100) comment '人员ID',
    notice_read_type     varchar(50) comment '类型 (枚举类 NoticeTypeEnum)',
    notice_read_time     datetime comment '已读时间',
    org_id               bigint comment '组织ID',
    user_id              bigint comment '用户ID',
    primary key (notice_read_id)
)
    auto_increment = 1
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_general_ci;

alter table notice_read comment '通知公告等-已读时间记录';

ALTER TABLE teacher_open_course_chat_log ADD COLUMN chat_log_full_id varchar(2000) COMMENT '互动日志全路径ID';
ALTER TABLE school_class ADD COLUMN university_faculty_id bigint(20) COMMENT '院系ID';

ALTER TABLE teacher_open_course_schedule_session ADD COLUMN schedule_session_title varchar(60) COMMENT '排课标题';


ALTER TABLE core_user ADD COLUMN login_count bigint(20) COMMENT '登录次数';
ALTER TABLE core_user ADD COLUMN last_login_time datetime COMMENT '最后登录时间';
