From 5a77a3dd12b890acbc35190897970a9dfd0fbe8e Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Mon, 11 Feb 2019 18:02:58 +0100 Subject: [PATCH] Add missing statistics --- server/statistics/templates/statistics.html | 20 ++++++++++++++++++-- server/statistics/views.py | 20 +++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/server/statistics/templates/statistics.html b/server/statistics/templates/statistics.html index 8e60a87e..75fc2994 100644 --- a/server/statistics/templates/statistics.html +++ b/server/statistics/templates/statistics.html @@ -147,7 +147,23 @@ Anzahl erfasste Inhaltsblöcke pro Klasse
- 0 + {{ content_block_by_users_count }} +
+ +
+

+ Anzahl von Lehrern erfasste Inhaltsblöcke +

+
+ {{ content_block_by_teachers_count }} +
+
+
+

+ Anzahl von Schülern erfasste Inhaltsblöcke +

+
+ {{ content_block_by_students_count }}
@@ -155,7 +171,7 @@ Wieviele Personen haben einen oder mehrere Inhaltsblöcke erfasst?
- 0 + {{ users_with_content_blocks_count }}
diff --git a/server/statistics/views.py b/server/statistics/views.py index be16368c..f1c349b3 100644 --- a/server/statistics/views.py +++ b/server/statistics/views.py @@ -4,7 +4,8 @@ from django.views.generic import TemplateView from assignments.models import StudentSubmission from books.models import Module, ContentBlock from rooms.models import Room -from users.models import SchoolClass +from users.managers import RoleManager +from users.models import SchoolClass, User class StatisticsView(TemplateView): @@ -39,6 +40,19 @@ class StatisticsView(TemplateView): content_block_count = ContentBlock.objects.count() + content_block_by_users = ContentBlock.objects.filter( + Q(owner__user_roles__role__key=RoleManager.TEACHER_KEY) | Q( + owner__user_roles__role__key=RoleManager.STUDENT_KEY)).count() + + content_block_by_teachers = ContentBlock.objects.filter( + owner__user_roles__role__key=RoleManager.TEACHER_KEY).count() + content_block_by_students = ContentBlock.objects.filter( + owner__user_roles__role__key=RoleManager.STUDENT_KEY).count() + + users_with_content_blocks = User.objects.filter( + Q(user_roles__role__key=RoleManager.STUDENT_KEY) | Q(user_roles__role__key=RoleManager.TEACHER_KEY)).filter( + owned_pages__gt=0).distinct().count() + context['private_submissions'] = private_submissions context['shared_submissions'] = shared_submissions context['modules'] = modules @@ -47,5 +61,9 @@ class StatisticsView(TemplateView): context['room_entries_classes'] = room_entries_classes context['rooms'] = rooms context['content_block_count'] = content_block_count + context['content_block_by_users_count'] = content_block_by_users + context['content_block_by_teachers_count'] = content_block_by_teachers + context['content_block_by_students_count'] = content_block_by_students + context['users_with_content_blocks_count'] = users_with_content_blocks return context