Add missing statistics

This commit is contained in:
Ramon Wenger 2019-02-11 18:02:58 +01:00
parent 89961dc301
commit 5a77a3dd12
2 changed files with 37 additions and 3 deletions

View File

@ -147,7 +147,23 @@
Anzahl erfasste Inhaltsblöcke pro Klasse
</h3>
<div class="statistic__value">
0
{{ content_block_by_users_count }}
</div>
</div>
<div class="statistic">
<h3 class="statistic__description">
Anzahl von Lehrern erfasste Inhaltsblöcke
</h3>
<div class="statistic__value">
{{ content_block_by_teachers_count }}
</div>
</div>
<div class="statistic">
<h3 class="statistic__description">
Anzahl von Schülern erfasste Inhaltsblöcke
</h3>
<div class="statistic__value">
{{ content_block_by_students_count }}
</div>
</div>
<div class="statistic">
@ -155,7 +171,7 @@
Wieviele Personen haben einen oder mehrere Inhaltsblöcke erfasst?
</h3>
<div class="statistic__value">
0
{{ users_with_content_blocks_count }}
</div>
</div>

View File

@ -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