题目增加启用字段
This commit is contained in:
parent
e6bb6da561
commit
3545c29c45
|
|
@ -81,14 +81,13 @@
|
|||
<!-- <span wx:if="{{to_read}}">{{to_read}}条未读</span> -->
|
||||
</view>
|
||||
</navigator>
|
||||
<navigator url="/pages/qtest/form" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<navigator url="/pages/exam/index" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/qtest.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">个人防护用品检测(铅当量)</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red">
|
||||
<!-- <span wx:if="{{to_read}}">{{to_read}}条未读</span> -->
|
||||
<image src="/images/exam.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">Ⅲ类自测入口</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red"></view>
|
||||
</navigator>
|
||||
</view>
|
||||
<view style="margin-top:6px">
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@
|
|||
<view class="weui-cell__bd">平均分</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:if="{{avg_score}}">{{avg_score}}</view>
|
||||
</view>
|
||||
<navigator url="/pages/exam/index" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
|
||||
<navigator url="/pages/qtest/form" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/exam.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
<image src="/images/qtest.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">正式考试入口</view>
|
||||
<view class="weui-cell__bd">个人防护用品检测(铅当量)</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red"></view>
|
||||
</navigator>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class ExamViewSet(ModelViewSet):
|
|||
question_queryset = Question.objects.none()
|
||||
questioncats = workscope.questioncat.order_by('type', 'create_time')
|
||||
if questioncats.count() == 3:
|
||||
queryset = Question.objects.filter(is_delete=0)
|
||||
queryset = Question.objects.filter(is_delete=0, enabled=True)
|
||||
a1_set = queryset.filter(questioncat=questioncats[0], type='单选').order_by('?')[:12]
|
||||
a2_set = queryset.filter(questioncat=questioncats[1], type='单选').order_by('?')[:12]
|
||||
a3_set = queryset.filter(questioncat=questioncats[2], type='单选').order_by('?')[:16]
|
||||
|
|
@ -200,7 +200,7 @@ class WorkScopeViewSet(ModelViewSet):
|
|||
a1 = 2*b2 + 2*b3 - 2
|
||||
a2 = 18 - 2*b2
|
||||
a3 = 24 - 2*b3
|
||||
queryset = Question.objects.filter(is_delete=0)
|
||||
queryset = Question.objects.filter(is_delete=0, enabled=True)
|
||||
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]
|
||||
|
|
@ -210,7 +210,7 @@ class WorkScopeViewSet(ModelViewSet):
|
|||
question_queryset = question_queryset|a1_set|a2_set|a3_set|b1_set|b2_set|b3_set
|
||||
elif workscope.name == '辐射安全管理':
|
||||
# 辐射安全管理出卷规则
|
||||
queryset = Question.objects.filter(is_delete=0)
|
||||
queryset = Question.objects.filter(is_delete=0, enabled=True)
|
||||
a1_set = queryset.filter(questioncat=questioncats[0], type='单选').order_by('?')[:16]
|
||||
a2_set = queryset.filter(questioncat=questioncats[1], type='单选').order_by('?')[:24]
|
||||
b1_set = queryset.filter(questioncat=questioncats[0], type='多选').order_by('?')[:4]
|
||||
|
|
@ -218,14 +218,14 @@ class WorkScopeViewSet(ModelViewSet):
|
|||
question_queryset = question_queryset|a1_set|a2_set|b1_set|b2_set
|
||||
elif workscope.name == '科研、生产及其他':
|
||||
# 科研、生产及其他出卷规则
|
||||
queryset = Question.objects.filter(is_delete=0)
|
||||
queryset = Question.objects.filter(is_delete=0, enabled=True)
|
||||
a1_set = queryset.filter(questioncat=questioncats[0], type='单选').order_by('?')[:24]
|
||||
a2_set = queryset.filter(questioncat=questioncats[1], type='单选').order_by('?')[:16]
|
||||
b1_set = queryset.filter(questioncat=questioncats[0], type='多选').order_by('?')[:6]
|
||||
b2_set = queryset.filter(questioncat=questioncats[1], type='多选').order_by('?')[:4]
|
||||
question_queryset = question_queryset|a1_set|a2_set|b1_set|b2_set
|
||||
else:
|
||||
queryset = Question.objects.filter(is_delete=0,questioncat__in = workscope.questioncat.all())
|
||||
queryset = Question.objects.filter(is_delete=0,questioncat__in = workscope.questioncat.all(), enabled=True)
|
||||
if ret['danxuan_count']:
|
||||
danxuan = queryset.filter(type='单选').order_by('?')[:ret['danxuan_count']]
|
||||
question_queryset = question_queryset | danxuan
|
||||
|
|
@ -265,7 +265,7 @@ class WorkScopeViewSet(ModelViewSet):
|
|||
ret['panduan_count'] = rule.panduan_count
|
||||
ret['panduan_score'] = rule.panduan_score
|
||||
question_queryset = Question.objects.none()
|
||||
queryset = Question.objects.filter(is_delete=0)
|
||||
queryset = Question.objects.filter(is_delete=0, enabled=True)
|
||||
if ret['danxuan_count']:
|
||||
danxuan = queryset.filter(type='单选').order_by('?')[:ret['danxuan_count']]
|
||||
question_queryset = question_queryset | danxuan
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.4 on 2021-03-28 07:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('question', '0012_question_img'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='question',
|
||||
name='enabled',
|
||||
field=models.BooleanField(default=True, verbose_name='是否启用'),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.4 on 2021-03-28 07:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('question', '0013_question_enabled'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='question',
|
||||
name='enabled',
|
||||
field=models.BooleanField(default=False, verbose_name='是否启用'),
|
||||
),
|
||||
]
|
||||
|
|
@ -44,6 +44,7 @@ class Question(SoftCommonModel):
|
|||
options = JSONField(verbose_name='选项')
|
||||
right = JSONField(verbose_name='正确答案')
|
||||
resolution = models.TextField(verbose_name='解析', blank=True)
|
||||
enabled = models.BooleanField('是否启用', default=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = '题目'
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class ExerciseView(APIView):
|
|||
perms_map=[{'post':'exercise'}]
|
||||
def post(self, request):
|
||||
questioncat = request.data['questioncat']
|
||||
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat).order_by('type','pk', 'name')
|
||||
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat,enabled=True).order_by('type','pk', 'name')
|
||||
if 'ydtms' in request.data and request.data['ydtms']:
|
||||
queryset = queryset.exclude(id__in = request.data['ydtms'])
|
||||
if 'ydtms_' in request.data and request.data['ydtms_']:
|
||||
|
|
|
|||
Loading…
Reference in New Issue