From 21c4d28d26102a1e99e72e0aa86890c4116fce8a Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 25 Jul 2024 23:10:18 +0200 Subject: [PATCH] fix campus export --- src/spz/export/__init__.py | 3 ++- src/spz/models.py | 3 ++- src/spz/templates/internal/administration/grade.html | 2 +- src/spz/views.py | 9 +++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/spz/export/__init__.py b/src/spz/export/__init__.py index 4ad65a6..83857e7 100644 --- a/src/spz/export/__init__.py +++ b/src/spz/export/__init__.py @@ -72,7 +72,8 @@ def export_course_list(courses, format, filename='Kursliste'): for course in courses: formatter.begin_section(course.full_name) for applicant in course.course_list: - formatter.write_element(dict(course=course, applicant=applicant)) + attendance = course.get_course_attendance(course.id, applicant.id) + formatter.write_element(dict(course=course, applicant=applicant, attendance=attendance)) formatter.set_course_information(course) formatter.end_section(course.full_name) diff --git a/src/spz/models.py b/src/spz/models.py index 4a8959b..59c203f 100644 --- a/src/spz/models.py +++ b/src/spz/models.py @@ -284,7 +284,7 @@ def __lt__(self, other): def full_name(self): return '{} {}'.format(self.first_name, self.last_name) - """@property + @property def tag_is_digit(self): if self.tag is None: return False @@ -294,6 +294,7 @@ def tag_is_digit(self): except ValueError: return False + """ @property def sanitized_grade(self): if self.grade is None: diff --git a/src/spz/templates/internal/administration/grade.html b/src/spz/templates/internal/administration/grade.html index 68f0e01..947363c 100644 --- a/src/spz/templates/internal/administration/grade.html +++ b/src/spz/templates/internal/administration/grade.html @@ -41,7 +41,7 @@

Notenübersicht

{% for applicant in course.course_list %} {% set attendance = course.get_course_attendance(course.id, applicant.id) %} - + {% if applicant.tag %} {{ applicant.tag }} {% endif %} {{ applicant.first_name }} {{ applicant.last_name }} diff --git a/src/spz/views.py b/src/spz/views.py index 4b19e62..17336bd 100644 --- a/src/spz/views.py +++ b/src/spz/views.py @@ -1367,19 +1367,20 @@ def campus_portal_grades(export_token): grade_objects = [] for course in courses: for student in course.course_list: + attendance = course.get_course_attendance(course.id, student.id) # check for valid matriculation id -> tag and if the grade was set and course is passed - if student.tag_is_digit and student.full_grade not in ["-", "nicht bestanden"]: - if student.hide_grade: + if student.tag_is_digit and attendance.full_grade not in ["-", "nicht bestanden"]: + if attendance.hide_grade: grade = "bestanden" else: - grade = student.full_grade + grade = attendance.full_grade grade_objects.append( { "matriculationId": int(student.tag), # required # "title": course.name, # name without alternatives a, b, c, ... # "titleEn": course.name_english, "examDate": exam_date_iso, - "ects": student.ects_points, # required + "ects": attendance.ects_points, # required "grade": grade, # required "sqUnit": "SPZ" }