Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new methods for getting text grades #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ivanhrabcak
Copy link
Collaborator

Fixes #71
I've added a new class:

@dataclass
class EduTextGrade:
    grade_id: int
    comment: Optional[str]
    grade_type: int
    date: datetime
    subject_id: int
    subject_name: Optional[str]

And 2 new methods:

from edupage_api import Edupage, Term

edupage = Edupage()
edupage.login("Username", "Password", "Your school's subdomain")

# the new methods are equivalent to `edupage.get_grades` and `edupage.get_grades_for_term`
text_grades: list[EduTextGrade] = edupage.get_text_grades()
text_grades_t1: list[EduTextGrade] = edupage.get_text_grades_for_term(2024, Term.FIRST)

@mgrfilipmarek Can you please test? Feel free to suggest any more fields that should be added.

You can install the test version with this command:

pip install -U git+https://github.com/EdupageAPI/edupage-api@feature/text-grades

And to revert back:

pip uninstall edupage-api
pip install edupage-api

@ivanhrabcak ivanhrabcak requested a review from BelKed January 29, 2025 18:08
Copy link
Collaborator

@BelKed BelKed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, LGTM! :)

I can't test in on live data since I don't have any text grades :(

list[EduGrade]: List of `EduTextGrade`s
"""

return Grades(self).get_grades(year=None, term=None)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe return Grades(self).get_text_grades(year=None, term=None)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@mgrfilipmarek
Copy link

I found something strange.
Calling get_grades returns empty list. I guess, that its somehow connected to the fact, that they already started second term in our school/edupage.
image

But when I try to use get_grades_for_term(2024, Term.FIRST) I recieve exception:
"Caught blocking call to putrequest with args (<urllib3.connection.HTTPSConnection object at 0x7f64f389be60>, 'POST', '/znamky/?what=studentviewer&znamky_yearid=2024&nadobdobie=P1') inside the event loop by custom integration 'homeassistantedupage' at custom_components/homeassistantedupage/homeassistant_edupage.py, line 60: grades = await self.hass.async_add_executor_job(self.api.get_grades_for_term(2024, Term.FIRST)). (offender: /home/vscode/.local/ha-venv/lib/python3.12/site-packages/urllib3/connection.py, line 219: return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)), please create a bug report at https://github.com/rine77/homeassistantedupage/issues\nFor developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#putrequest"

Maybe request_url is not correct? But Im quite new in python so I could be wrong.
My suggestions:

  • It could be a typo (in slovak 😄 ) nadobdobie=P1
  • In real edupage in network, I can see POST to: https://*.edupage.org/znamky/?what=studentviewer&akcia=studentData&eqav=1&maxEqav=7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Text grades are unsupported
3 participants