This commit is contained in:
wucongxing8150 2024-06-25 14:19:41 +08:00
parent c4278c9f19
commit 06a0593d92
2 changed files with 12 additions and 4 deletions

View File

@ -81,7 +81,7 @@ type PutQuestion struct {
// PutQuestionTest 修改题目
type PutQuestionTest struct {
QuestionName string `json:"question_name" form:"question_name" validate:"required" label:"题目名称"`
QuestionType int `json:"question_type" form:"question_type" validate:"required,oneof=1 2 3 4" label:"题目类型"` // 题目类型(1:单选 2:多选 3:问答 4:判断)
QuestionType string `json:"question_type" form:"question_type" validate:"required,oneof=1 2 3 4" label:"题目类型"` // 题目类型(1:单选 2:多选 3:问答 4:判断)
QuestionStatus string `json:"question_status" form:"question_status" validate:"required,oneof=1 2" label:"状态"` // 状态1:正常 2:禁用)
QuestionAnswer string `json:"question_answer" form:"question_answer" validate:"required" label:"答案"`
QuestionAnalysis string `json:"question_analysis" form:"question_analysis" label:"解析"`

View File

@ -482,8 +482,16 @@ func (r *QuestionService) PutQuestionTest(questionId int64, req requests.PutQues
}
// 题目类型
if req.QuestionType != question.QuestionType {
questionData["question_type"] = req.QuestionType
if req.QuestionType != "" {
questionType, err := strconv.Atoi(req.QuestionType)
if err != nil {
tx.Rollback()
return false, errors.New("题目类型错误")
}
if questionType != question.QuestionType {
questionData["question_type"] = req.QuestionType
}
}
// 状态
@ -614,7 +622,7 @@ func (r *QuestionService) PutQuestionTest(questionId int64, req requests.PutQues
}
}
if req.QuestionType == 1 || req.QuestionType == 2 {
if req.QuestionType == "1" || req.QuestionType == "2" {
// 新增选项
questionOptionDao := dao.QuestionOptionDao{}
if req.Input1 != nil {