edupage-api icon indicating copy to clipboard operation
edupage-api copied to clipboard

Add new methods for getting text grades

Open ivanhrabcak opened this issue 11 months ago • 1 comments

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 avatar Jan 29 '25 18:01 ivanhrabcak

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

mgrfilipmarek avatar Jan 31 '25 13:01 mgrfilipmarek