Skip to content

Commit

Permalink
fix: a patch fix on teacher client's updating exam, also removed json…
Browse files Browse the repository at this point in the history
… tag of `created_at` and `last_updated_at` on server's models so that it won't affect the API
  • Loading branch information
gonearewe committed Jun 27, 2022
1 parent c67f7db commit 4550116
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions server/models/bfq.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type Bfq struct {
Answer3 string `gorm:"column:answer_3;type:tinytext" json:"answer_3"` // 填空的答案
OverallCorrectScore int `gorm:"column:overall_correct_score;type:int(11);not null;default:0" json:"overall_correct_score"` // 此题在所有出现中的总得分数*10,即保存到小数点后一位
OverallScore int `gorm:"column:overall_score;type:int(11);not null;default:0" json:"overall_score"` // 此题在所有出现中的总分数*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/bfq_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type BfqAnswer struct {
StudentAnswer1 string `gorm:"column:student_answer_1;type:tinytext" json:"student_answer_1"` // 学生的答案
StudentAnswer2 string `gorm:"column:student_answer_2;type:tinytext" json:"student_answer_2"` // 学生的答案
StudentAnswer3 string `gorm:"column:student_answer_3;type:tinytext" json:"student_answer_3"` // 学生的答案
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/cq.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Cq struct {
Template string `gorm:"column:template;type:text;not null" json:"template"` // 题目的初始模板
OverallCorrectScore int `gorm:"column:overall_correct_score;type:int(11);not null;default:0" json:"overall_correct_score"` // 此题在所有出现中的总得分数*10,即保存到小数点后一位
OverallScore int `gorm:"column:overall_score;type:int(11);not null;default:0" json:"overall_score"` // 此题在所有出现中的总分数*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/cq_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type CqAnswer struct {
RightOutput string `gorm:"column:right_output;type:text;not null" json:"right_output"` // 程序的正确输出,与 cq 中 output 字段保持一致
StudentOutput string `gorm:"column:student_output;type:text" json:"student_output"` // 学生代码的实际输出
IsAnswerRight bool `gorm:"column:is_answer_right;type:tinyint(1);default:0" json:"is_answer_right"` // 学生的代码是否正确,即 right_output 是否等于 student_output,由触发器计算
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/crq.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type Crq struct {
Answer6 string `gorm:"column:answer_6;type:tinytext" json:"answer_6"` // 填空的答案
OverallCorrectScore int `gorm:"column:overall_correct_score;type:int(11);not null;default:0" json:"overall_correct_score"` // 此题在所有出现中的总得分数*10,即保存到小数点后一位
OverallScore int `gorm:"column:overall_score;type:int(11);not null;default:0" json:"overall_score"` // 此题在所有出现中的总分数*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/crq_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type CrqAnswer struct {
StudentAnswer4 string `gorm:"column:student_answer_4;type:tinytext" json:"student_answer_4"` // 学生的答案
StudentAnswer5 string `gorm:"column:student_answer_5;type:tinytext" json:"student_answer_5"` // 学生的答案
StudentAnswer6 string `gorm:"column:student_answer_6;type:tinytext" json:"student_answer_6"` // 学生的答案
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/exam.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type Exam struct {
CrqNum uint8 `gorm:"column:crq_num;type:tinyint(2) unsigned;not null" json:"crq_num"` // 代码阅读题题数
CqScore uint8 `gorm:"column:cq_score;type:tinyint(2) unsigned;not null" json:"cq_score"` // 写代码题每题分数
CqNum uint8 `gorm:"column:cq_num;type:tinyint(2) unsigned;not null" json:"cq_num"` // 写代码题题数
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/exam_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type ExamSession struct {
TimeAllowed int8 `gorm:"column:time_allowed;type:tinyint(3);not null" json:"time_allowed"` // 考生答题时间,单位:分钟
EndTime time.Time `gorm:"column:end_time;type:datetime" json:"end_time"` // 交卷时刻
Score int16 `gorm:"column:score;type:smallint(6);not null" json:"score"` // 最终成绩*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/maq.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type Maq struct {
RightAnswer string `gorm:"column:right_answer;type:char(7);not null" json:"right_answer"` // 答案,按升序包含所有正确选项的索引,如 "5"、"124"、"67"
OverallCorrectScore int `gorm:"column:overall_correct_score;type:int(11);not null;default:0" json:"overall_correct_score"` // 此题在所有出现中的总得分数*10,即保存到小数点后一位
OverallScore int `gorm:"column:overall_score;type:int(11);not null;default:0" json:"overall_score"` // 此题在所有出现中的总分数*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/maq_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type MaqAnswer struct {
ExamSessionID int `gorm:"uniqueIndex:maq_id;index:exam_session_id;column:exam_session_id;type:int(10);not null" json:"exam_session_id"` // 连接 exam_session
RightAnswer string `gorm:"column:right_answer;type:char(7);not null" json:"right_answer"` // 正确答案,与 maq 中同名字段保持一致
StudentAnswer string `gorm:"column:student_answer;type:char(7)" json:"student_answer"` // 学生的答案
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/mcq.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Mcq struct {
RightAnswer string `gorm:"column:right_answer;type:char(1);not null" json:"right_answer"` // 答案,正确选项的索引,如 "4"、"1"
OverallCorrectScore int `gorm:"column:overall_correct_score;type:int(11);not null;default:0" json:"overall_correct_score"` // 此题在所有出现中的总得分数*10,即保存到小数点后一位
OverallScore int `gorm:"column:overall_score;type:int(11);not null;default:0" json:"overall_score"` // 此题在所有出现中的总分数*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/mcq_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type McqAnswer struct {
ExamSessionID int `gorm:"uniqueIndex:mcq_id;index:exam_session_id;column:exam_session_id;type:int(10);not null" json:"exam_session_id"` // 连接 exam_session
RightAnswer string `gorm:"column:right_answer;type:char(1);not null" json:"right_answer"` // 正确答案,与 mcq 中同名字段保持一致
StudentAnswer string `gorm:"column:student_answer;type:char(1)" json:"student_answer"` // 学生的答案
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/student.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type Student struct {
StudentID string `gorm:"unique;index:student_id_2;column:student_id;type:varchar(10);not null" json:"student_id"` // 学号
Name string `gorm:"index:student_id_2;index:class_id;index:name;column:name;type:varchar(50);not null" json:"name"` // 姓名
ClassID string `gorm:"index:student_id_2;index:class_id;column:class_id;type:varchar(10);not null" json:"class_id"` // 班号
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/teacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type Teacher struct {
Password string `gorm:"column:password;type:varchar(100);not null" json:"password"` // 加盐后的密码
Salt string `gorm:"column:salt;type:varchar(50);not null" json:"-"` // 盐
IsAdmin bool `gorm:"column:is_admin;type:tinyint(1);not null;default:0" json:"is_admin"` // 是否为超级管理员
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/tfq.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type Tfq struct {
Answer bool `gorm:"column:answer;type:tinyint(1);not null" json:"answer"` // 正确答案
OverallCorrectScore int `gorm:"column:overall_correct_score;type:int(11);not null;default:0" json:"overall_correct_score"` // 此题在所有出现中的总得分数*10,即保存到小数点后一位
OverallScore int `gorm:"column:overall_score;type:int(11);not null;default:0" json:"overall_score"` // 此题在所有出现中的总分数*10,即保存到小数点后一位
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
4 changes: 2 additions & 2 deletions server/models/tfq_answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type TfqAnswer struct {
ExamSessionID int `gorm:"uniqueIndex:tfq_id;index:exam_session_id;column:exam_session_id;type:int(10);not null" json:"exam_session_id"` // 连接 exam_session
RightAnswer bool `gorm:"column:right_answer;type:tinyint(1);not null" json:"right_answer"` // 正确答案,与 tfq 中同名字段保持一致
StudentAnswer bool `gorm:"column:student_answer;type:tinyint(1)" json:"student_answer"` // 学生的答案
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"created_at"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"last_updated_at"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;default:CURRENT_TIMESTAMP" json:"-"`
LastUpdatedAt time.Time `gorm:"column:last_updated_at;type:datetime" json:"-"`
}

// TableName get sql table name.获取数据库表名
Expand Down
2 changes: 1 addition & 1 deletion teacher_client/src/views/exam/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export default {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
const tempData = Object.assign({}, this.temp)
updateExam('exam', tempData).then(() => {
updateExam([tempData]).then(() => {
const index = this.list.findIndex(v => v.id === this.temp.id)
this.list.splice(index, 1, this.temp)
this.dialogFormVisible = false
Expand Down

0 comments on commit 4550116

Please sign in to comment.