题目导入时如果题干,题型,分类若在数据库中同时查到一致的,则跳过

This commit is contained in:
caoqianming 2021-05-08 14:57:42 +08:00
parent 38e58451db
commit 489ab609f4
2 changed files with 5 additions and 3 deletions

View File

@ -0,0 +1,2 @@
2021-05:增加正式考试参考机会默认为3次
2021-05:题目导入时如果题干,题型,分类若在数据库中同时查到一致的,则跳过

View File

@ -202,7 +202,7 @@ class QuestionViewSet(ModelViewSet):
else:
cateobj = Questioncat.objects.get(id=questioncatdict[questioncat])
if type == '单选':
if Question.objects.filter(type='单选',name=name, is_delete=0).exists():
if Question.objects.filter(type='单选',name=name, is_delete=0, questioncat=cateobj).exists():
notinlist.append(i)
else:
if right in ['A','B','C','D','E','F']:
@ -220,7 +220,7 @@ class QuestionViewSet(ModelViewSet):
obj.save()
elif type == '多选':
right = list(right)
if Question.objects.filter(type='多选', name=name, is_delete=0).exists():
if Question.objects.filter(type='多选', name=name, is_delete=0, questioncat=cateobj).exists():
notinlist.append(i)
else:
if [False for c in right if c not in qlist]:
@ -243,7 +243,7 @@ class QuestionViewSet(ModelViewSet):
right = 'A'
else:
right = 'B'
if Question.objects.filter(type='判断',name=name, is_delete=0).exists():
if Question.objects.filter(type='判断',name=name, is_delete=0, questioncat=cateobj).exists():
notinlist.append(i)
else:
obj = Question()