Release - Upload
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#from django.contrib import admin
|
||||
#from .models import Lecturer
|
||||
|
||||
#admin.site.register(Lecturer)
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PruefplanViewerConfig(AppConfig):
|
||||
name = 'pruefplan_viewer'
|
||||
@@ -0,0 +1,94 @@
|
||||
# Generated by Django 3.2 on 2021-04-30 12:03
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Exam',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('identification', models.CharField(max_length=200, null=True)),
|
||||
('date', models.DateField(blank=True, null=True)),
|
||||
('time', models.TimeField(blank=True, null=True)),
|
||||
('weekday', models.CharField(max_length=200, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ExamExecution',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('supervisorType', models.CharField(max_length=200, null=True)),
|
||||
('location', models.CharField(max_length=200, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Lecturer',
|
||||
fields=[
|
||||
('identification', models.CharField(max_length=200, primary_key=True, serialize=False)),
|
||||
('firstName', models.CharField(max_length=200, null=True)),
|
||||
('lastName', models.CharField(max_length=200, null=True)),
|
||||
('title', models.CharField(max_length=200, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Subject',
|
||||
fields=[
|
||||
('identification', models.CharField(max_length=200, primary_key=True, serialize=False)),
|
||||
('initials', models.CharField(max_length=200, null=True)),
|
||||
('name', models.CharField(max_length=200, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StudentExam',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('examIdentification', models.CharField(max_length=200, null=True)),
|
||||
('date', models.DateField(blank=True, null=True)),
|
||||
('time', models.TimeField(blank=True, null=True)),
|
||||
('weekday', models.CharField(max_length=200, null=True)),
|
||||
('location', models.CharField(max_length=200, null=True)),
|
||||
('examExecution', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pruefplan_viewer.examexecution')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Student',
|
||||
fields=[
|
||||
('matrikel', models.CharField(max_length=200, primary_key=True, serialize=False)),
|
||||
('exams', models.ManyToManyField(to='pruefplan_viewer.StudentExam')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='PartialExam',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('identification', models.CharField(max_length=200, null=True)),
|
||||
('regStudCount', models.CharField(max_length=200, null=True)),
|
||||
('exam', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pruefplan_viewer.exam')),
|
||||
('subjectIds', models.ManyToManyField(to='pruefplan_viewer.Subject')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='examexecution',
|
||||
name='lecturer',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pruefplan_viewer.lecturer'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='examexecution',
|
||||
name='partialExam',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pruefplan_viewer.partialexam'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='examexecution',
|
||||
name='subjectIds',
|
||||
field=models.ManyToManyField(to='pruefplan_viewer.Subject'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-02-26 17:04
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("pruefplan_viewer", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="examexecution",
|
||||
options={
|
||||
"ordering": ("partialExam__exam__date", "partialExam__exam__time")
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0.2 on 2024-04-11 13:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pruefplan_viewer', '0002_alter_examexecution_options'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Presences',
|
||||
fields=[
|
||||
('identification', models.CharField(max_length=200, primary_key=True, serialize=False)),
|
||||
],
|
||||
),
|
||||
]
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.0.2 on 2024-04-11 16:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pruefplan_viewer', '0003_presences'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='presences',
|
||||
name='date',
|
||||
field=models.DateField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='presences',
|
||||
name='dateTimeText',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='presences',
|
||||
name='time',
|
||||
field=models.TimeField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='presences',
|
||||
name='weekday',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0.3 on 2024-04-24 09:13
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pruefplan_viewer', '0004_presences_date_presences_datetimetext_presences_time_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='presences',
|
||||
name='lecturer',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pruefplan_viewer.lecturer'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.0.3 on 2024-05-17 10:43
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pruefplan_viewer', '0005_presences_lecturer'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Presences',
|
||||
new_name='Attendance',
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.4 on 2025-01-30 14:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pruefplan_viewer', '0006_rename_presences_attendance'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='API_ExamDataSet_ForStudent',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,63 @@
|
||||
# Generated by Django 5.1.4 on 2025-01-30 14:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pruefplan_viewer', '0007_api_examdataset_forstudent'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='date',
|
||||
field=models.DateField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='examIdent',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='examStudCount',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='location',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='room',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='studMartNr',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='subjectIdent',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='supervisor',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='time',
|
||||
field=models.TimeField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='api_examdataset_forstudent',
|
||||
name='weekday',
|
||||
field=models.CharField(max_length=200, null=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,148 @@
|
||||
from __future__ import annotations # Python 3.10 (Production still on 3.9)
|
||||
|
||||
from dataclasses import asdict, dataclass, field
|
||||
import datetime as dt
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Subject(models.Model):
|
||||
identification = models.CharField(max_length=200, primary_key=True)
|
||||
initials = models.CharField(max_length=200, null=True)
|
||||
name = models.CharField(max_length=200, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Exam(models.Model):
|
||||
identification = models.CharField(max_length=200, null=True)
|
||||
date = models.DateField(blank=True, null=True)
|
||||
time = models.TimeField(blank=True, null=True)
|
||||
weekday = models.CharField(max_length=200, null=True)
|
||||
|
||||
|
||||
class PartialExam(models.Model):
|
||||
identification = models.CharField(max_length=200, null=True)
|
||||
regStudCount = models.CharField(max_length=200, null=True)
|
||||
subjectIds = models.ManyToManyField(Subject)
|
||||
exam = models.ForeignKey("Exam", blank=True, null=True, on_delete=models.SET_NULL)
|
||||
|
||||
|
||||
class Lecturer(models.Model):
|
||||
identification = models.CharField(max_length=200, primary_key=True)
|
||||
firstName = models.CharField(max_length=200, null=True)
|
||||
lastName = models.CharField(max_length=200, null=True)
|
||||
title = models.CharField(max_length=200, null=True)
|
||||
|
||||
|
||||
class Attendance(models.Model):
|
||||
identification = models.CharField(max_length=200, primary_key=True)
|
||||
date = models.DateField(blank=True, null=True)
|
||||
time = models.TimeField(blank=True, null=True)
|
||||
dateTimeText = models.CharField(max_length=200, null=True)
|
||||
weekday = models.CharField(max_length=200, null=True)
|
||||
lecturer = models.ForeignKey(
|
||||
"Lecturer", blank=True, null=True, on_delete=models.SET_NULL
|
||||
)
|
||||
|
||||
|
||||
class StudentExam(models.Model):
|
||||
examIdentification = models.CharField(max_length=200, null=True)
|
||||
date = models.DateField(blank=True, null=True)
|
||||
time = models.TimeField(blank=True, null=True)
|
||||
weekday = models.CharField(max_length=200, null=True)
|
||||
location = models.CharField(max_length=200, null=True)
|
||||
examExecution = models.ForeignKey(
|
||||
"ExamExecution", blank=True, null=True, on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
|
||||
class Student(models.Model):
|
||||
matrikel = models.CharField(max_length=200, primary_key=True)
|
||||
exams = models.ManyToManyField(StudentExam)
|
||||
|
||||
|
||||
class ExamExecution(models.Model):
|
||||
lecturer = models.ForeignKey(
|
||||
"Lecturer", blank=True, null=True, on_delete=models.CASCADE
|
||||
)
|
||||
supervisorType = models.CharField(max_length=200, null=True)
|
||||
location = models.CharField(max_length=200, null=True)
|
||||
subjectIds = models.ManyToManyField(Subject)
|
||||
partialExam = models.ForeignKey(
|
||||
"PartialExam", blank=True, null=True, on_delete=models.SET_NULL
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ("partialExam__exam__date", "partialExam__exam__time")
|
||||
|
||||
|
||||
|
||||
|
||||
# @dataclass()
|
||||
# class API_ExamDataSet_ForStudent(models.Model):
|
||||
# date: dt.date
|
||||
# time: dt.time
|
||||
# weekday: str
|
||||
# room: str | None
|
||||
# location: str | None
|
||||
# subjectIdent: str | None
|
||||
# examIdent: str | None
|
||||
# examStudCount: int | None
|
||||
# supervisor: str
|
||||
# studMartNr: str | None
|
||||
|
||||
# def to_dict(self):
|
||||
# return asdict(self)
|
||||
|
||||
|
||||
class API_ExamDataSet_ForStudent(models.Model):
|
||||
date = models.DateField(blank=True, null=True)
|
||||
time = models.TimeField(blank=True, null=True)
|
||||
weekday = models.CharField(max_length=200, null=True)
|
||||
room = models.CharField(max_length=200, null=True)
|
||||
location = models.CharField(max_length=200, null=True)
|
||||
subjectIdent = models.CharField(max_length=200, null=True)
|
||||
examIdent = models.CharField(max_length=200, null=True)
|
||||
examStudCount = models.CharField(max_length=200, null=True)
|
||||
supervisor = models.CharField(max_length=200, null=True)
|
||||
studMartNr = models.CharField(max_length=200, null=True)
|
||||
|
||||
def to_dict(self):
|
||||
return asdict(self)
|
||||
|
||||
|
||||
|
||||
@dataclass(order=True)
|
||||
class ExamLines:
|
||||
sort_index: dt.datetime = field(init=False)
|
||||
date: dt.date
|
||||
time: dt.time
|
||||
weekday: str
|
||||
location: str | None
|
||||
subjectIds: list[Subject] | None
|
||||
examIdent: str | None
|
||||
examStudCound: int | None
|
||||
supervisorType: str
|
||||
executionSet: list | None
|
||||
partialExamIdent: str | None
|
||||
|
||||
def __post_init__(self):
|
||||
self.sort_index = dt.datetime.combine(self.date, self.time)
|
||||
|
||||
|
||||
def sort_and_group_datetime(examLines: list):
|
||||
|
||||
examLine_Datetime_Groups = {}
|
||||
for examLine in examLines:
|
||||
if examLine.sort_index not in examLine_Datetime_Groups:
|
||||
examLine_Datetime_Groups[examLine.sort_index] = []
|
||||
examLine_Datetime_Groups[examLine.sort_index].append(examLine)
|
||||
|
||||
sorted_groups = sorted(examLine_Datetime_Groups.items(), key=lambda x: x[0])
|
||||
|
||||
sorted_result = []
|
||||
for _, group in sorted_groups:
|
||||
sorted_result.extend(group)
|
||||
|
||||
return sorted_result
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,13 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
app_name = 'pp_viewer'
|
||||
|
||||
urlpatterns = [
|
||||
path('lecturer', views.lecturer, name='lecturer'),
|
||||
path('subject', views.subject, name='subject'),
|
||||
path('exam', views.exam, name='exam'),
|
||||
path('student', views.student, name='student'),
|
||||
path('studentExam/<int:student_id>/', views.examsForStudent, name='examForStudent'),
|
||||
path('lecturerExam/<str:lecturer_id>/', views.examsForLecturer, name='examForLecturer'),
|
||||
]
|
||||
@@ -0,0 +1,115 @@
|
||||
from django.shortcuts import render
|
||||
from django.template.defaulttags import register
|
||||
from django.http import Http404
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from .models import ExamLines, Lecturer, Subject, Exam, Student, sort_and_group_datetime
|
||||
import datetime as dt
|
||||
|
||||
|
||||
@login_required
|
||||
def lecturer(request):
|
||||
lecturers = Lecturer.objects.all()
|
||||
context = {"lecturers": lecturers}
|
||||
return render(request, "pruefplan/lecturer.html", context)
|
||||
|
||||
|
||||
@login_required
|
||||
def subject(request):
|
||||
subjects = Subject.objects.all()
|
||||
context = {"subjects": subjects}
|
||||
return render(request, "pruefplan/subject.html", context)
|
||||
|
||||
|
||||
@login_required
|
||||
def student(request):
|
||||
students = Student.objects.all()
|
||||
context = {"students": students}
|
||||
return render(request, "pruefplan/student.html", context)
|
||||
|
||||
|
||||
@login_required
|
||||
def exam(request):
|
||||
exams = Exam.objects.all()
|
||||
supervisorSetDict = {}
|
||||
for ex in exams:
|
||||
examSupervisors = []
|
||||
for partialExam in ex.partialexam_set.all():
|
||||
for examExe in partialExam.examexecution_set.all():
|
||||
supervisor = (
|
||||
examExe.lecturer.firstName + " " + examExe.lecturer.lastName
|
||||
)
|
||||
if supervisor not in examSupervisors:
|
||||
examSupervisors.append(supervisor)
|
||||
supervisorSetDict[ex.identification] = examSupervisors
|
||||
|
||||
context = {"exams": exams, "supervisorSetDict": supervisorSetDict}
|
||||
return render(request, "pruefplan/exam.html", context)
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_item(dictionary, key):
|
||||
return dictionary.get(key)
|
||||
|
||||
|
||||
def examsForLecturer(request, lecturer_id):
|
||||
lecturer = Lecturer.objects.filter(pk=lecturer_id).first()
|
||||
if lecturer is not None:
|
||||
lecExamExes = lecturer.examexecution_set.all()
|
||||
lecAttendance = lecturer.attendance_set.all()
|
||||
lecExamLines = mergeModels(lecExamExes, lecAttendance)
|
||||
context = {
|
||||
"lecturer": lecturer,
|
||||
"lecExamLines": lecExamLines,
|
||||
"lecExamExes": lecExamExes,
|
||||
}
|
||||
return render(request, "pruefplan/lecturerExam.html", context)
|
||||
else:
|
||||
raise Http404("Dozentenkennung ungültig.")
|
||||
|
||||
|
||||
def examsForStudent(request, student_id):
|
||||
student = Student.objects.all().filter(matrikel=student_id).first()
|
||||
if student is not None:
|
||||
exams = student.exams.all()
|
||||
context = {"student": student, "exams": exams}
|
||||
return render(request, "pruefplan/studentExam.html", context)
|
||||
else:
|
||||
raise Http404("Matrikelnummer ungültig.")
|
||||
|
||||
|
||||
def mergeModels(lecExamExes, lecAttendance):
|
||||
result = [
|
||||
ExamLines(
|
||||
date=examExes.partialExam.exam.date,
|
||||
time=examExes.partialExam.exam.time,
|
||||
weekday=examExes.partialExam.exam.weekday,
|
||||
location=examExes.location,
|
||||
subjectIds=examExes.subjectIds,
|
||||
examIdent=examExes.partialExam.identification,
|
||||
examStudCound=examExes.partialExam.regStudCount,
|
||||
supervisorType=examExes.supervisorType,
|
||||
executionSet=list(examExes.partialExam.examexecution_set.all()),
|
||||
partialExamIdent=examExes.partialExam.exam.identification,
|
||||
)
|
||||
for examExes in lecExamExes
|
||||
]
|
||||
|
||||
result += [
|
||||
ExamLines(
|
||||
date=attendance.date,
|
||||
time=attendance.time,
|
||||
weekday=attendance.weekday,
|
||||
location=None,
|
||||
subjectIds=None,
|
||||
examIdent=None,
|
||||
examStudCound=None,
|
||||
supervisorType="PRÄSENZ",
|
||||
executionSet=None,
|
||||
partialExamIdent=None,
|
||||
)
|
||||
for attendance in lecAttendance
|
||||
]
|
||||
|
||||
result = sort_and_group_datetime(result)
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user