From f37a2afb27b4a387b8f389307ff4e938ad088dc6 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 6 Nov 2020 23:32:58 +0800 Subject: [PATCH] =?UTF-8?q?start=20end=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- groups/templates/groups/exam.html | 3 ++- groups/views.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/groups/templates/groups/exam.html b/groups/templates/groups/exam.html index a7106952..f9a315d3 100644 --- a/groups/templates/groups/exam.html +++ b/groups/templates/groups/exam.html @@ -1,4 +1,5 @@ {% extends "groups/base.html" %} +{% load static %} {% block title %}在线考试统计{% endblock %} {% block pagehead %} @@ -9,7 +10,7 @@ {% endblock %} {% block content %} -{% load static %} +

在线考试统计

diff --git a/groups/views.py b/groups/views.py index 19b031bb..28d5549c 100644 --- a/groups/views.py +++ b/groups/views.py @@ -470,8 +470,8 @@ def examChart(request):#在线考试 def exam_rate(request): # 考试通过率 - start = request.GET.get('start') - end = request.GET.get('end') + start = request.GET.get('start', None) + end = request.GET.get('end', None) companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all() ret = {'x':{'name':'所属公司', 'data':[]}, 's':[{'name':'参考率', 'data':[]},{'name':'满分率', 'data':[]}, {'name':'优秀率', 'data':[]}], 't':'各公司考试比例统计', 'l':['参考率', '满分率', '优秀率']} for i in companys: @@ -479,6 +479,10 @@ def exam_rate(request): user_count = s_models.User.objects.filter(usecomp=i, deletemark=1).count() # 参加考试员工数 base = s_models.ExamTestDetail.objects.filter(user__usecomp=i, user__deletemark=1, ison=1).exclude(examtest__nousecomps__contains=','+str(i.partid)+',') + if start: + base = base.filter(examtest__starttime__gte=start) + if end: + base = base.filter(examtest__starttime__lte=end) testuser_count = base.values('user').distinct().count() # 参考率 rate1 = testuser_count/user_count