考试比例分析图开始
This commit is contained in:
parent
dc204a95f3
commit
4bde63c25e
|
@ -31,6 +31,7 @@ urlpatterns = [
|
|||
path('api/riskChart',views.riskChart),
|
||||
path('api/trainChart',views.trainChart),
|
||||
path('api/examChart',views.examChart),
|
||||
path('api/examrate',views.exam_rate),
|
||||
path('api/admininfo/<int:id>/', views.admininfo),
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from safesite.models import ExamTestDetail
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.shortcuts import render,reverse
|
||||
from django.shortcuts import redirect
|
||||
|
@ -468,3 +469,32 @@ def examChart(request):#在线考试
|
|||
|
||||
|
||||
|
||||
def exam_rate(request):
|
||||
# 考试通过率
|
||||
start = request.GET.get('start')
|
||||
end = request.GET.get('end')
|
||||
companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all()
|
||||
for i in companys:
|
||||
# 员工数
|
||||
user_count = s_models.User.objects.filter(usecomp=i, deletemark=1).count()
|
||||
# 参加考试员工数
|
||||
base = s_models.ExamTestDetail.objects.filter(user__usecomp=i, user__deletemark=1)
|
||||
testuser_count = base.values('user').distinct().count()
|
||||
# 参考率
|
||||
rate1 = testuser_count/user_count
|
||||
# 考试总数
|
||||
test_count = base.count()
|
||||
# 满分数
|
||||
full_count = base.filter(score = F('examtest__totalscore')).count()
|
||||
# 满分率
|
||||
rate2 = full_count/test_count if test_count else 0
|
||||
# 90分数
|
||||
ninety_count = base.filter(score__gte = F('examtest__totalscore')*0.9).count()
|
||||
# 90以上得分率
|
||||
rate3 = ninety_count/test_count if test_count else 0
|
||||
print(user_count, testuser_count)
|
||||
# print(i.partname, rate1, rate2, rate3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue