diff --git a/test_client/src/api/question.js b/test_client/src/api/question.js index 63d51f0..b526fe3 100644 --- a/test_client/src/api/question.js +++ b/test_client/src/api/question.js @@ -108,6 +108,13 @@ export function deleteQuestion(id) { method: 'delete', }) } +export function deleteQuestions(data) { + return request({ + url: `/question/question/deletes/`, + method: 'post', + data + }) +} export function importQuestion(data) { return request({ url: `/question/question/import/`, diff --git a/test_client/src/router/index.js b/test_client/src/router/index.js index bf26603..ddfd745 100644 --- a/test_client/src/router/index.js +++ b/test_client/src/router/index.js @@ -279,7 +279,13 @@ export const asyncRoutes = [ path: 'examtest', name: 'ExamTest', component: () => import('@/views/analyse/examtest.vue'), - meta: { title: '答卷列表', icon: '', perms: ['examtest_view'] } + meta: { title: '模考答卷', icon: '', perms: ['examtest_view'] } + }, + { + path: 'examtest2', + name: 'ExamTest2', + component: () => import('@/views/analyse/examtest2.vue'), + meta: { title: '正式考试答卷', icon: '', perms: ['examtest_view'] } }, { path: 'chart', diff --git a/test_client/src/settings.js b/test_client/src/settings.js index c158b71..cd73c99 100644 --- a/test_client/src/settings.js +++ b/test_client/src/settings.js @@ -1,6 +1,6 @@ module.exports = { - title: '安建环培训考试平台', + title: '中科辐射', /** * @type {boolean} true | false diff --git a/test_client/src/views/analyse/examtest.vue b/test_client/src/views/analyse/examtest.vue index deef5da..1feede1 100644 --- a/test_client/src/views/analyse/examtest.vue +++ b/test_client/src/views/analyse/examtest.vue @@ -138,6 +138,7 @@ import Pagination from "@/components/Pagination"; const listQuery = { page: 1, limit: 20, + type:'自助模考', search:'' }; export default { @@ -152,8 +153,7 @@ export default { listLoading: true, typeOptions: [ { key: "自助模考", label: "自助模考", value: "自助模考" }, - { key: "押卷模考", label: "押卷模考", value: "押卷模考"}, - { key: "正式考试", label: "正式考试", value: "正式考试"}, + { key: "押卷模考", label: "押卷模考", value: "押卷模考"} ], passOptions: [ { key: true, label: "通过", value: true }, @@ -230,6 +230,7 @@ export default { this.listQuery = { page: 1, limit: 20, + type:'自助模考', search:'', }; this.value = [] diff --git a/test_client/src/views/analyse/examtest2.vue b/test_client/src/views/analyse/examtest2.vue new file mode 100644 index 0000000..075ca1b --- /dev/null +++ b/test_client/src/views/analyse/examtest2.vue @@ -0,0 +1,279 @@ + + + diff --git a/test_client/src/views/exam/index.vue b/test_client/src/views/exam/index.vue index 6a1129f..fcfb7f9 100644 --- a/test_client/src/views/exam/index.vue +++ b/test_client/src/views/exam/index.vue @@ -250,7 +250,7 @@ export default { }); }, handleView(scope){ - this.$router.push({name:'ExamTest', params:{exam:scope.row.id}}) + this.$router.push({name:'ExamTest2', params:{exam:scope.row.id}}) }, async confirmexam(form) { diff --git a/test_client/src/views/question/question.vue b/test_client/src/views/question/question.vue index 6d6049e..1c5c27f 100644 --- a/test_client/src/views/question/question.vue +++ b/test_client/src/views/question/question.vue @@ -70,6 +70,12 @@ Excel导入 导出Excel +批量删除 { + this.$message.success("成功"); + this.getList(); + }) + } else { + this.$message.warning("请先选择题目"); + } + }, exportQuestion() { const loading = this.$loading({ text:'正在准备..' diff --git a/test_server/examtest/exports.py b/test_server/examtest/exports.py index d6f5f0a..20b0eb7 100644 --- a/test_server/examtest/exports.py +++ b/test_server/examtest/exports.py @@ -34,7 +34,7 @@ def exportw_test(obj, bool): """ 导出个人考试记录word版本 """ - filename = obj.exam.name + '-' + str(obj.exam.id) + '-' + obj.consumer.name + '-' + obj.consumer.id + '.docx' + filename = obj.exam.name + '-' + str(obj.exam.id) + '-' + obj.consumer_detail['name'] + '-' + str(obj.score) + '.docx' path = '/media/export/' + filename fullpath = BASE_DIR + path if bool or (not os.path.exists(fullpath)): diff --git a/test_server/examtest/models.py b/test_server/examtest/models.py index 8d92e04..6de9b8a 100644 --- a/test_server/examtest/models.py +++ b/test_server/examtest/models.py @@ -23,6 +23,7 @@ class Exam(CommonModel): qdimgs = JSONField('签到图片', default=list) xcimgs = JSONField('现场图片', default=list) + def __str__(self): return self.name @@ -55,6 +56,9 @@ class ExamTest(CommonModel): class Meta: verbose_name = '模拟考试' verbose_name_plural = verbose_name + + def __str__(self): + return self.name diff --git a/test_server/examtest/serializers.py b/test_server/examtest/serializers.py index acd7597..4e9c34d 100644 --- a/test_server/examtest/serializers.py +++ b/test_server/examtest/serializers.py @@ -235,6 +235,7 @@ class ExamTestExamListSerializer(serializers.ModelSerializer): workscope_name = serializers.StringRelatedField(source='workscope', read_only=True) took_format = serializers.SerializerMethodField() candidate_ = serializers.SerializerMethodField() + exam_name = serializers.StringRelatedField(source='exam', read_only=True) class Meta: model = ExamTest diff --git a/test_server/question/views.py b/test_server/question/views.py index 738eb80..31a0314 100644 --- a/test_server/question/views.py +++ b/test_server/question/views.py @@ -6,13 +6,13 @@ from rest_framework import status from rest_framework.decorators import action, permission_classes from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.generics import GenericAPIView -from rest_framework.permissions import IsAuthenticated +from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet from rest_framework_jwt.authentication import JSONWebTokenAuthentication -from crm.models import PaySubject +from crm.models import Consumer, PaySubject from examtest.models import WorkScope from server import settings from utils.custom import CommonPagination @@ -116,6 +116,13 @@ class QuestionViewSet(ModelViewSet): ret['panduan'] = queryset.filter(type='判断').count() return Response(ret) + def get_queryset(self): + user = self.request.user + if isinstance(user, Consumer): + questioncats = user.workscope.questioncat.all() + self.queryset = self.queryset.filter(questioncat__in = questioncats) + return super().get_queryset() + @action(methods=['get'], detail=False, url_path='export', url_name='export_question', perms_map=[{'*':'export_question'}]) def export(self, request): @@ -143,6 +150,17 @@ class QuestionViewSet(ModelViewSet): i.save() return Response() + @action(methods=['post'], detail=False, perms_map=[{'*':'question_delete'}]) + def deletes(self, request): + """ + 批量删除 + """ + ids = request.data.get('ids', []) + if request.user.is_superuser: + Question.objects.filter(id__in=ids).update(is_delete=True) + return Response() + return Response({'error':'权限不足'}) + @action(methods=['post'], detail=False, url_name='enable_question', permission_classes=[IsAuthenticated]) def enable(self, request): ids = request.data.get('ids',None)