考试抽题
This commit is contained in:
parent
9c77679f92
commit
49eb0acc0e
|
@ -14,6 +14,7 @@
|
||||||
<view class="weui-article__h2">{{tm_index+1}}.
|
<view class="weui-article__h2">{{tm_index+1}}.
|
||||||
<span class="txlabel">{{tm_current.type}}</span>
|
<span class="txlabel">{{tm_current.type}}</span>
|
||||||
<span>({{tm_current.total_score}}分)</span>
|
<span>({{tm_current.total_score}}分)</span>
|
||||||
|
<span style="color:gray">({{tm_current.questioncat_name}})</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-article__title">{{tm_current.name}}</view>
|
<view class="weui-article__title">{{tm_current.name}}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
@ -84,16 +84,34 @@ class WorkScopeViewSet(ModelViewSet):
|
||||||
ret['panduan_count'] = workscope.rule.panduan_count
|
ret['panduan_count'] = workscope.rule.panduan_count
|
||||||
ret['panduan_score'] = workscope.rule.panduan_score
|
ret['panduan_score'] = workscope.rule.panduan_score
|
||||||
question_queryset = Question.objects.none()
|
question_queryset = Question.objects.none()
|
||||||
queryset = Question.objects.filter(is_delete=0,questioncat__in = workscope.questioncat.all())
|
questioncats = workscope.questioncat.exclude(name='辐射小知识更新中').order_by('type')
|
||||||
if ret['danxuan_count']:
|
if questioncats.count() == 3:
|
||||||
danxuan = queryset.filter(type='单选').order_by('?')[:ret['danxuan_count']]
|
import random
|
||||||
question_queryset = question_queryset | danxuan
|
b2 = random.randint(1,9)
|
||||||
if ret['duoxuan_count']:
|
b3 = random.randint(1,b2+1)
|
||||||
duoxuan = queryset.filter(type='多选').order_by('?')[:ret['duoxuan_count']]
|
b1 = 10 - b2 -b3
|
||||||
question_queryset = question_queryset | duoxuan
|
a1 = 2*b2 + 2*b3 - 2
|
||||||
if ret['panduan_count']:
|
a2 = 18 - 2*b2
|
||||||
panduan = queryset.filter(type='判断').order_by('?')[:ret['panduan_count']]
|
a3 = 24 - 2*b3
|
||||||
question_queryset = question_queryset | panduan
|
queryset = Question.objects.filter(is_delete=0)
|
||||||
|
a1_set = queryset.filter(questioncat=questioncats[0], type='单选').order_by('?')[:a1]
|
||||||
|
a2_set = queryset.filter(questioncat=questioncats[1], type='单选').order_by('?')[:a2]
|
||||||
|
a3_set = queryset.filter(questioncat=questioncats[2], type='单选').order_by('?')[:a3]
|
||||||
|
b1_set = queryset.filter(questioncat=questioncats[0], type='多选').order_by('?')[:b1]
|
||||||
|
b2_set = queryset.filter(questioncat=questioncats[1], type='多选').order_by('?')[:b2]
|
||||||
|
b3_set = queryset.filter(questioncat=questioncats[2], type='多选').order_by('?')[:b3]
|
||||||
|
question_queryset = question_queryset|a1_set|a2_set|a3_set|b1_set|b2_set|b3_set
|
||||||
|
else:
|
||||||
|
queryset = Question.objects.filter(is_delete=0,questioncat__in = workscope.questioncat.all())
|
||||||
|
if ret['danxuan_count']:
|
||||||
|
danxuan = queryset.filter(type='单选').order_by('?')[:ret['danxuan_count']]
|
||||||
|
question_queryset = question_queryset | danxuan
|
||||||
|
if ret['duoxuan_count']:
|
||||||
|
duoxuan = queryset.filter(type='多选').order_by('?')[:ret['duoxuan_count']]
|
||||||
|
question_queryset = question_queryset | duoxuan
|
||||||
|
if ret['panduan_count']:
|
||||||
|
panduan = queryset.filter(type='判断').order_by('?')[:ret['panduan_count']]
|
||||||
|
question_queryset = question_queryset | panduan
|
||||||
questions = QuestionSerializer(instance=question_queryset.order_by('type'),many=True).data
|
questions = QuestionSerializer(instance=question_queryset.order_by('type'),many=True).data
|
||||||
for i in questions:
|
for i in questions:
|
||||||
if i['type'] == '单选':
|
if i['type'] == '单选':
|
||||||
|
|
Loading…
Reference in New Issue