EdupageAPI / edupage-api

A python library for accessing your Edupage account
https://edupageapi.github.io/edupage-api/
GNU General Public License v3.0
66 stars 13 forks source link

[Feature request] Getting info about grades #38

Closed FilipZboril closed 2 years ago

FilipZboril commented 2 years ago

Hey so can you make it so I can get all of the grades from a subject into a list? Something like:

from edupage_api import Edupage, BadCredentialsException, LoginDataParsingException

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")

try:
    edupage.login()
except BadCredentialsException:
    print("Wrong username or password!")
except LoginDataParsingException:
    print("Try again or open an issue!")

grades = EduGrades("English")
print(grades)

Output: ['1','2','3','1','1,5'etc]

ivanhrabcak commented 2 years ago

Yes:)

I can look into it today.

FilipZboril commented 2 years ago

Thank you! :)

ivanhrabcak commented 2 years ago

Hello, I've created a new release so now Grade has a subject_id property for better distinction of subjects. To get all grades from a subject you can do this:

from edupage_api import Edupage, BadCredentialsException, LoginDataParsingException

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")

try:
    edupage.login()
except BadCredentialsException:
    print("Wrong username or password!")
except LoginDataParsingException:
    print("Try again or open an issue!")

all_grades = edupage.get_grades() # this is a list of all grades for the current period (half-year??)

# see https://www.w3schools.com/python/ref_func_filter.asp
history_grades = list(filter(lambda x: x.subject == "History", all_grades)) # after (including) version 0.9.7

# filter by subject id
history_subject_id = 10
history_grades = list(filter(lambda x: x.subject_id == 10, all_grades)) # only after (including) version 0.9.88

EduGrade:

class EduGrade:
    def __init__(self, event_id, title, grade, importance, datetime_added, subject, teacher, percent, verbal,
                 max_points, subject_id):
        self.id = event_id
        self.title = title
        self.grade = grade
        self.importance = importance
        self.datetime_added = EduExactDateTime.from_formatted_string(datetime_added)
        self.subject = subject
        self.teacher = teacher
        self.percent = percent
        self.verbal = verbal
        self.max_points = max_points
        self.subject_id = subject_id

I hope this is enough for you. If not, please describe what do you want me to change. If this is what you need, please close this issue.

FilipZboril commented 2 years ago

Wow you made that extremely fast, and It is all I need. Thank you very much!

ivanhrabcak commented 2 years ago

Everything was already implemeted (Grade and get_grades was already there) I just added subject_id. I am happy that I've helped you:)