testrule add
This commit is contained in:
parent
01be8f6c30
commit
abc1687ea2
|
@ -28,10 +28,11 @@ export function deleteSubject(id) {
|
|||
})
|
||||
}
|
||||
|
||||
export function getQuestioncatAll() {
|
||||
export function getQuestioncatAll(query) {
|
||||
return request({
|
||||
url: '/question/questioncat/all/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,7 @@ export function getQuestioncatList(query) {
|
|||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createQuestioncat(data) {
|
||||
return request({
|
||||
url: '/question/questioncat/',
|
||||
|
@ -70,6 +72,15 @@ export function getQuestionList(query) {
|
|||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getQuestionCount(query) {
|
||||
return request({
|
||||
url: '/question/question/count/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createQuestion(data) {
|
||||
return request({
|
||||
url: '/question/question/',
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
<el-table-column align="center" label="名称">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="简述">
|
||||
<template slot-scope="scope">{{ scope.row.desc }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.create_time }}</span>
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
<el-form-item label="规则名称" prop="name">
|
||||
<el-input v-model="ruleForm.name" style="width:400px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="规则简述" prop="desc">
|
||||
<el-input v-model="ruleForm.desc" style="width:400px" type="textarea"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属学科" prop="subject">
|
||||
<el-select v-model="ruleForm.subject" placeholder="请选择所属学科" style="width:400px">
|
||||
<el-select v-model="ruleForm.subject" placeholder="请选择所属学科" style="width:400px" @change="getQuestioncatAll()">
|
||||
<el-option
|
||||
v-for="item in subjectData"
|
||||
:key="item.value"
|
||||
|
@ -21,24 +24,30 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="题库范围" prop="questioncat">
|
||||
<el-select v-model="ruleForm.questioncat" multiple placeholder="请选择题库范围" style="width:400px">
|
||||
<el-option label="区域一" value="shanghai"></el-option>
|
||||
<el-option label="区域二" value="beijing"></el-option>
|
||||
<el-select
|
||||
v-model="ruleForm.questioncat" multiple placeholder="请选择题库范围" style="width:400px"
|
||||
@blur="getQuestionCount()">
|
||||
<el-option
|
||||
v-for="item in questioncatData"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单选题">
|
||||
共有<span style="color:orange;font-weight:bold">0</span>道,选取
|
||||
<el-input v-model="ruleForm.detail.danxuan.num" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||
共有<span style="color:orange;font-weight:bold">{{typecount.danxuan}}</span>道,选取
|
||||
<el-input v-model="ruleForm.detail.danxuan.count" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||
<el-input v-model="ruleForm.detail.danxuan.score" style="width:60px" @input="calScore()"></el-input>分
|
||||
</el-form-item>
|
||||
<el-form-item label="多选题">
|
||||
共有<span style="color:orange;font-weight:bold">0</span>道,选取
|
||||
<el-input v-model="ruleForm.detail.duoxuan.num" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||
共有<span style="color:orange;font-weight:bold">{{typecount.duoxuan}}</span>道,选取
|
||||
<el-input v-model="ruleForm.detail.duoxuan.count" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||
<el-input v-model="ruleForm.detail.duoxuan.score" style="width:60px" @input="calScore()"></el-input>分
|
||||
</el-form-item>
|
||||
<el-form-item label="判断题">
|
||||
共有<span style="color:orange;font-weight:bold">0</span>道,选取
|
||||
<el-input v-model="ruleForm.detail.panduan.num" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||
共有<span style="color:orange;font-weight:bold">{{typecount.panduan}}</span>道,选取
|
||||
<el-input v-model="ruleForm.detail.panduan.count" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||
<el-input v-model="ruleForm.detail.panduan.score" style="width:60px" @input="calScore()"></el-input>分
|
||||
</el-form-item>
|
||||
<el-form-item label="时间限制" prop="duration">
|
||||
|
@ -59,7 +68,7 @@
|
|||
</template>
|
||||
<script>
|
||||
import { createTestRule } from "@/api/examtest";
|
||||
import { getSubjectAll, getQuestioncatList } from "@/api/question";
|
||||
import { getSubjectAll, getQuestioncatAll, getQuestionCount } from "@/api/question";
|
||||
import { genTree } from "@/utils";
|
||||
export default {
|
||||
data() {
|
||||
|
@ -70,15 +79,15 @@ export default {
|
|||
questioncat: [],
|
||||
detail: {
|
||||
danxuan: {
|
||||
num: 0,
|
||||
count: 0,
|
||||
score: 0
|
||||
},
|
||||
duoxuan: {
|
||||
num: 0,
|
||||
count: 0,
|
||||
score: 0
|
||||
},
|
||||
panduan: {
|
||||
num: 0,
|
||||
count: 0,
|
||||
score: 0
|
||||
},
|
||||
duration: 0,
|
||||
|
@ -86,6 +95,11 @@ export default {
|
|||
passscore: 0
|
||||
}
|
||||
},
|
||||
typecount:{
|
||||
danxuan:0,
|
||||
duoxuan:0,
|
||||
panduan:0
|
||||
},
|
||||
subjectData:[],
|
||||
questioncatData:[],
|
||||
rules: {
|
||||
|
@ -125,9 +139,20 @@ export default {
|
|||
this.subjectData = genTree(response.data) ;
|
||||
});
|
||||
},
|
||||
getQuestioncatAll() {
|
||||
getQuestioncatAll({pid:this.ruleForm.subject}).then(response => {
|
||||
this.questioncatData = genTree(response.data) ;
|
||||
});
|
||||
},
|
||||
getQuestionCount() {
|
||||
console.log(this.ruleForm.questioncat)
|
||||
// getQuestionCount({ids:this.ruleForm.questioncat}).then(response => {
|
||||
// this.typecount = response.data
|
||||
// });
|
||||
},
|
||||
calScore() {
|
||||
let detail = this.ruleForm.detail
|
||||
let score = detail.danxuan.num * detail.danxuan.score + detail.duoxuan.num * detail.duoxuan.score + detail.panduan.num * detail.panduan.score
|
||||
let score = detail.danxuan.count * detail.danxuan.score + detail.duoxuan.count * detail.duoxuan.score + detail.panduan.count * detail.panduan.score
|
||||
this.ruleForm.detail.score = score
|
||||
},
|
||||
resetForm(formName) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
|
||||
from rest_framework_jwt.serializers import jwt_decode_handler
|
||||
from rest_framework import exceptions
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from crm.models import Consumer
|
||||
|
||||
|
@ -17,7 +18,7 @@ class ConsumerTokenAuthentication(JSONWebTokenAuthentication):
|
|||
|
||||
try:
|
||||
consumer = Consumer.objects.get(username=username)
|
||||
except consumer.DoesNotExist:
|
||||
except Consumer.DoesNotExist:
|
||||
msg = _('消费者不存在')
|
||||
raise exceptions.AuthenticationFailed(msg)
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.4 on 2020-03-17 13:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('examtest', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='testrule',
|
||||
name='desc',
|
||||
field=models.TextField(default='', verbose_name='描述'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.4 on 2020-03-17 13:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('examtest', '0002_testrule_desc'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='testrule',
|
||||
name='desc',
|
||||
field=models.TextField(default='', verbose_name='描述'),
|
||||
),
|
||||
]
|
|
@ -5,7 +5,8 @@ from question.models import Questioncat
|
|||
|
||||
# Create your models here.
|
||||
class TestRule(CommonModel):
|
||||
name = models.CharField(max_length=200, unique=True, verbose_name="名称")
|
||||
subject = models.ForeignKey(Questioncat, blank=True, null=True, on_delete=models.CASCADE, verbose_name="所属学科", related_name="subject")
|
||||
questioncat = models.ManyToManyField(Questioncat, verbose_name="所选题库")
|
||||
detail = JSONField(verbose_name="试卷结构")
|
||||
name = models.CharField(max_length=200, unique=True, verbose_name='名称')
|
||||
desc = models.TextField(verbose_name='描述', default='')
|
||||
subject = models.ForeignKey(Questioncat, blank=True, null=True, on_delete=models.CASCADE, verbose_name='所属学科', related_name='subject')
|
||||
questioncat = models.ManyToManyField(Questioncat, verbose_name='所选题库')
|
||||
detail = JSONField(verbose_name='试卷结构')
|
|
@ -85,6 +85,8 @@ class QuestioncatViewSet(ModelViewSet):
|
|||
题库分类全,不分页
|
||||
"""
|
||||
queryset = Questioncat.objects.filter(is_delete=0).all()
|
||||
if request.query_params.get('pid',None):
|
||||
queryset = queryset.filter(pid = request.query_params.get('pid'))
|
||||
serializer = QuestioncatSerializer(instance=queryset,many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
|
@ -123,6 +125,19 @@ class QuestionViewSet(ModelViewSet):
|
|||
instance.save()
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated],
|
||||
url_path='count', url_name='question_count')
|
||||
def count(self, request):
|
||||
ret = {'danxuan':0,'duoxuan':0,'panduan':0}
|
||||
queryset = self.queryset
|
||||
if request.query_params.get('ids',None):
|
||||
queryset = queryset.filter(questioncat__in = request.query_params.get('ids'))
|
||||
ret['danxuan'] = queryset.filter(type=1).count()
|
||||
ret['duoxuan'] = queryset.filter(type=1).count()
|
||||
ret['panduan'] = queryset.filter(type=1).count()
|
||||
return Response(ret)
|
||||
|
||||
|
||||
@action(methods=['post'], detail=False, permission_classes=[IsAuthenticated],
|
||||
url_path='import', url_name='import_question')
|
||||
def import_question(self, request):
|
||||
|
|
Loading…
Reference in New Issue