Add statistics basics
This commit is contained in:
parent
e9bee08c1d
commit
89961dc301
|
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 2.0.6 on 2019-02-10 21:13
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('assignments', '0003_auto_20181018_0800'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='studentsubmission',
|
||||
name='student',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='submissions', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
||||
|
|
@ -30,7 +30,7 @@ class StudentSubmission(TimeStampedModel):
|
|||
text = models.TextField(blank=True)
|
||||
document = models.URLField(blank=True, default='', max_length=255)
|
||||
assignment = models.ForeignKey(Assignment, on_delete=models.CASCADE, related_name='submissions')
|
||||
student = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
||||
student = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, related_name='submissions')
|
||||
final = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 2.0.6 on 2019-02-10 21:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rooms', '0003_remove_roomentry_subtitle'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='room',
|
||||
name='school_class',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rooms', to='users.SchoolClass'),
|
||||
),
|
||||
]
|
||||
|
|
@ -13,7 +13,7 @@ class Room(TitleSlugDescriptionModel):
|
|||
verbose_name = 'Raum'
|
||||
verbose_name_plural = 'Räume'
|
||||
|
||||
school_class = models.ForeignKey(SchoolClass, blank=False, null=False, on_delete=models.CASCADE)
|
||||
school_class = models.ForeignKey(SchoolClass, blank=False, null=False, on_delete=models.CASCADE, related_name='rooms')
|
||||
appearance = models.CharField(blank=True, null=False, max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -1,84 +1,133 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Statistics</h1>
|
||||
<h1>Statistiken</h1>
|
||||
|
||||
<h2>Ergebnisse</h2>
|
||||
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Total Anzahl erfasste Ergebnisse (nur für Schüler gespeichert)
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{{ private_submissions }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Total Anzahl erfasste Ergebnisse (mit Lehrperson geteilt)
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{{ shared_submissions }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Ergebnisse pro Modul (nur für Schüler gespeichert)
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for module in modules %}
|
||||
<h4>
|
||||
{{ module.title }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ module.private_submissions }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Ergebnisse pro Modul (mit Lehrperson geteilt)
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for module in modules %}
|
||||
<h4>
|
||||
{{ module.title }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ module.shared_submissions }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Ergebnisse pro Klasse (nur für Schüler gespeichert)
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for school_class in classes %}
|
||||
<h4>
|
||||
{{ school_class.name }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ school_class.private_submissions }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Ergebnisse pro Klasse (mit Lehrperson geteilt)
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for school_class in classes %}
|
||||
<h4>
|
||||
{{ school_class.name }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ school_class.shared_submissions }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Räume</h2>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Räume pro Klasse
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for school_class in room_classes %}
|
||||
<h4>
|
||||
{{ school_class.name }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ school_class.room_count }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Raumeinträge pro Klasse
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for school_class in room_entries_classes %}
|
||||
<h4>
|
||||
{{ school_class.name }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ school_class.room_entry_count }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Raumeinträge pro Raum
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{% for room in rooms %}
|
||||
<h4>
|
||||
{{ room.title }}
|
||||
</h4>
|
||||
<p>
|
||||
{{ room.room_entry_count }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -86,25 +135,25 @@
|
|||
<h2>Inhaltsblöcke</h2>
|
||||
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Total Anzahl erfasste Inhaltsblöcke
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
{{ content_block_count }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Anzahl erfasste Inhaltsblöcke pro Klasse
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="statistic__description">
|
||||
<h3 class="statistic__description">
|
||||
Wieviele Personen haben einen oder mehrere Inhaltsblöcke erfasst?
|
||||
</div>
|
||||
</h3>
|
||||
<div class="statistic__value">
|
||||
0
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,51 @@
|
|||
from django.http import HttpResponse
|
||||
import datetime
|
||||
|
||||
from django.db.models import Count, Q
|
||||
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
|
||||
|
||||
|
||||
class StatisticsView(TemplateView):
|
||||
template_name = "statistics.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['test'] = 'hello'
|
||||
|
||||
private_submissions = StudentSubmission.objects.filter(final=False).count()
|
||||
shared_submissions = StudentSubmission.objects.filter(final=True).count()
|
||||
|
||||
private_submissions_by_module = Count('assignments__submissions',
|
||||
filter=Q(assignments__submissions__final=False))
|
||||
shared_submissions_by_module = Count('assignments__submissions', filter=Q(assignments__submissions__final=True))
|
||||
|
||||
modules = Module.objects.values('title').annotate(private_submissions=private_submissions_by_module).annotate(
|
||||
shared_submissions=shared_submissions_by_module)
|
||||
|
||||
private_submissions_by_class = Count('users__submissions', filter=Q(users__submissions__final=False))
|
||||
shared_submissions_by_class = Count('users__submissions', filter=Q(users__submissions__final=True))
|
||||
rooms_by_class = Count('rooms')
|
||||
room_entries_by_class = Count('rooms__room_entries')
|
||||
room_entries_by_room = Count('room_entries')
|
||||
|
||||
classes = SchoolClass.objects.values('name').annotate(
|
||||
private_submissions=private_submissions_by_class).annotate(shared_submissions=shared_submissions_by_class)
|
||||
|
||||
room_classes = SchoolClass.objects.values('name').annotate(room_count=rooms_by_class)
|
||||
room_entries_classes = SchoolClass.objects.values('name').annotate(room_entry_count=room_entries_by_class)
|
||||
|
||||
rooms = Room.objects.values('title').annotate(room_entry_count=room_entries_by_room)
|
||||
|
||||
content_block_count = ContentBlock.objects.count()
|
||||
|
||||
context['private_submissions'] = private_submissions
|
||||
context['shared_submissions'] = shared_submissions
|
||||
context['modules'] = modules
|
||||
context['classes'] = classes
|
||||
context['room_classes'] = room_classes
|
||||
context['room_entries_classes'] = room_entries_classes
|
||||
context['rooms'] = rooms
|
||||
context['content_block_count'] = content_block_count
|
||||
|
||||
return context
|
||||
|
|
|
|||
Loading…
Reference in New Issue