From 2a4e2719cb67e97cf7a4fa73776392279a06b09c Mon Sep 17 00:00:00 2001 From: mytja Date: Thu, 7 Dec 2023 17:37:24 +0100 Subject: [PATCH] non-permanent average of grades --- gimsisapi/formtagparser.py | 10 +++++++++- main.py | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gimsisapi/formtagparser.py b/gimsisapi/formtagparser.py index 77c9255..715784d 100644 --- a/gimsisapi/formtagparser.py +++ b/gimsisapi/formtagparser.py @@ -282,6 +282,8 @@ def get_grades(text): return {} all_grades = 0.0 all_grades_count = 0 + all_nc_grades = 0.0 + all_nc_grades_count = 0 for i in table.find("tbody").find_all("tr"): subject = i.find("th") f = i.find_all("td") @@ -390,13 +392,19 @@ def get_grades(text): if subject_grades["final"] is None and total_all_perm_count != 0: all_grades += subject_grades["perm_average"] all_grades_count += 1 + all_nc_grades += subject_grades["average"] + all_nc_grades_count += 1 elif subject_grades["final"] is not None: all_grades += int(subject_grades["final"]) all_grades_count += 1 + all_nc_grades += int(subject_grades["final"]) + all_nc_grades_count += 1 gradings["subjects"].append(subject_grades) if all_grades_count != 0: - gradings["average"] = all_grades / all_grades_count + gradings["average_perm"] = all_grades / all_grades_count + if all_nc_grades_count != 0: + gradings["average"] = all_nc_grades / all_nc_grades_count school_years = [] for i in soup.find("select", id="ctl00_ContentPlaceHolder1_ddlIdSolskoleto").find_all("option"): diff --git a/main.py b/main.py index 41a178a..3c53474 100644 --- a/main.py +++ b/main.py @@ -12,12 +12,12 @@ async def main(): # classes, days = await gimsis.fetch_timetable() # print(classes, days) # await gimsis.fetch_timetable("12 09 2022") - absences = await gimsis.fetch_absences("01.09.2022", type=AbsenceType.by_days) - print(absences) + #absences = await gimsis.fetch_absences("01.09.2022", type=AbsenceType.by_days) + #print(absences) # gradings = await gimsis.fetch_gradings() # print(gradings) - #grades = await gimsis.fetch_grades(year=2022) - #print(grades) + grades = await gimsis.fetch_grades(year="2023") + print(grades) #profile = await gimsis.my_profile() #print(profile) #teachers = await gimsis.fetch_teachers()