Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
non-permanent average of grades
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Dec 7, 2023
1 parent 0705186 commit 2a4e271
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion gimsisapi/formtagparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"):
Expand Down
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2a4e271

Please sign in to comment.