|
|
@@ -156,6 +156,10 @@ func (s LearningQuestionService) Update(ctx context.Context, req *learning.Learn
|
|
|
return validErr.Current()
|
|
|
}
|
|
|
if len(req.Content) != 0 {
|
|
|
+ if req.Type == nil {
|
|
|
+ return myerrors.NewMsgError(nil, "请输入题型")
|
|
|
+ }
|
|
|
+ questionType := *req.Type
|
|
|
if len(req.Content) < 2 {
|
|
|
return myerrors.NewMsgError(nil, "至少需要两个选项")
|
|
|
}
|
|
|
@@ -168,7 +172,7 @@ func (s LearningQuestionService) Update(ctx context.Context, req *learning.Learn
|
|
|
if correctCount < 1 {
|
|
|
return myerrors.NewMsgError(nil, "正确答案未设置")
|
|
|
}
|
|
|
- if (req.Type == 1 || req.Type == 3) && correctCount != 1 {
|
|
|
+ if (questionType == 1 || questionType == 3) && correctCount != 1 {
|
|
|
return myerrors.NewMsgError(nil, "正确答案只能设置一个")
|
|
|
}
|
|
|
}
|
|
|
@@ -199,7 +203,7 @@ func (s LearningQuestionService) Update(ctx context.Context, req *learning.Learn
|
|
|
if req.Name != "" {
|
|
|
toupdate["Name"] = req.Name
|
|
|
}
|
|
|
- if req.Type != 0 {
|
|
|
+ if req.Type != nil {
|
|
|
toupdate["Type"] = req.Type
|
|
|
}
|
|
|
if req.Enable != nil {
|