1
This commit is contained in:
parent
4d87ded852
commit
2fbc7d7e1c
@ -72,6 +72,23 @@ func (r *QuestionService) AddQuestion(req requests.AddQuestion) (bool, error) {
|
||||
if len(req.QuestionOption) == 0 {
|
||||
return false, errors.New("请填入选项")
|
||||
}
|
||||
|
||||
questionOption := "A.B.C.D.E.F.G.H.I.J.K."
|
||||
for _, s := range req.QuestionOption {
|
||||
if s == "" {
|
||||
return false, errors.New("存在为空的选项")
|
||||
}
|
||||
|
||||
// 判断是否为正常选项
|
||||
if !strings.Contains(questionOption, s) {
|
||||
return false, errors.New("选项存在错误标识")
|
||||
}
|
||||
|
||||
// 判断答案是否在选项中
|
||||
if !strings.Contains(questionAnswer, s) {
|
||||
return false, errors.New("答案不在选项中,请重新填写")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 验证重复
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user