Skip to content

Don't fail get_grades() on unknown or numeric grade types - #128

Merged
ivanhrabcak merged 3 commits into
EdupageAPI:masterfrom
MilanPala:fix-grade-types
Oct 11, 2026
Merged

ivanhrabcak merged 3 commits into
EdupageAPI:masterfrom
MilanPala:fix-grade-types

Conversation

@MilanPala

Copy link
Copy Markdown
Contributor

Problem

get_grades() fails for some schools with:

UnboundLocalError: cannot access local variable 'max_points' where it is not associated with a value

The max_points/importance branch only handles p_typ_udalosti values "1", "2" and "3" as strings. Real data from a Czech primary school has two other shapes:

  • "4": symbolic grades, e.g. Ú (p_vaha is set, p_vaha_body is null)
  • 1 as a number instead of "1"

Neither matches, so both variables are never assigned.

Fix

  • Compare str(p_typ_udalosti), so a numeric type is handled like its string form.
  • Default max_points and importance to None.
  • For any other type, read importance from p_vaha if present. There are no max points, and percent stays None because the grade isn't numeric.

Tests

New tests/test_grades.py: normal, numeric-type, percentage, symbolic ("4", Ú) and unknown types without p_vaha. The new symbolic, numeric and unknown cases fail on master, and the suite passes. Also checked against a real parent account: 12 grades load, 4 of them symbolic.

Co-Authored-By: Claude Code

Milan Pála and others added 3 commits October 11, 2026 13:32
EduPage can send p_typ_udalosti as a number, and it also uses grade
types other than 1-3 (e.g. "4" for symbolic grades like "Ú"). Neither
matched the if chain, so max_points was never assigned and get_grades()
raised UnboundLocalError.

Co-Authored-By: Claude Code
@ivanhrabcak
ivanhrabcak merged commit 97bdd7d into EdupageAPI:master Oct 11, 2026
2 checks passed
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.

2 participants