Skip to content

Commit

Permalink
fix campus export
Browse files Browse the repository at this point in the history
  • Loading branch information
urvdp committed Jul 25, 2024
1 parent 2baeb6b commit 21c4d28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/spz/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion src/spz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -294,6 +294,7 @@ def tag_is_digit(self):
except ValueError:
return False

"""
@property
def sanitized_grade(self):
if self.grade is None:
Expand Down
2 changes: 1 addition & 1 deletion src/spz/templates/internal/administration/grade.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h2>Notenübersicht</h2>
<tbody>
{% for applicant in course.course_list %}
{% set attendance = course.get_course_attendance(course.id, applicant.id) %}
<tr class="{{ 'error' if applicant.full_grade == 'nicht bestanden' else '' }}">
<tr class="{{ 'error' if attendance.full_grade == 'nicht bestanden' else '' }}">
<td>{% if applicant.tag %} {{ applicant.tag }} {% endif %}</td>
<td>{{ applicant.first_name }}</td>
<td>{{ applicant.last_name }}</td>
Expand Down
9 changes: 5 additions & 4 deletions src/spz/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 21c4d28

Please sign in to comment.