Skip to content

Commit

Permalink
Tri des notes par date de saisie
Browse files Browse the repository at this point in the history
Ajout de l'affichage maximum des notes dans la configuration
  • Loading branch information
Giga77 committed Nov 30, 2024
1 parent d8fb04b commit 7632eba
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions custom_components/ecole_directe/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DOMAIN,
DEFAULT_REFRESH_INTERVAL,
FILENAME_QCM,
GRADES_TO_DISPLAY,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -145,6 +146,10 @@ async def async_step_init(
"decode_html",
default=self.config_entry.options.get("decode_html", False),
): bool,
vol.Optional(
"notes_affichees",
default=self.config_entry.options.get("notes_affichees", GRADES_TO_DISPLAY),
): int,
}
),
)
2 changes: 2 additions & 0 deletions custom_components/ecole_directe/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DEFAULT_LUNCH_BREAK_TIME,
DEFAULT_REFRESH_INTERVAL,
EVENT_TYPE,
GRADES_TO_DISPLAY,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -204,6 +205,7 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
eleve,
year_data,
self.hass.config.config_dir,
self.config_entry.options.get("notes_affichees", GRADES_TO_DISPLAY)
)
disciplines = grades_evaluations["disciplines"]
self.data[f"{eleve.get_fullname_lower()}_disciplines"] = disciplines
Expand Down
8 changes: 4 additions & 4 deletions custom_components/ecole_directe/ecole_directe_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def clean_html(raw_html):
return cleantext


def get_grades_evaluations(token, eleve, annee_scolaire, config_path):
def get_grades_evaluations(token, eleve, annee_scolaire, config_path, grades_dispaly = GRADES_TO_DISPLAY):
"""get grades"""

if DEBUG_ON:
Expand Down Expand Up @@ -524,18 +524,18 @@ def get_grades_evaluations(token, eleve, annee_scolaire, config_path):
break

if "notes" in data:
data["notes"].sort(key=operator.itemgetter("date"))
data["notes"].sort(key=operator.itemgetter("dateSaisie"))
data["notes"].reverse()
for grade_json in data["notes"]:
if grade_json["noteSur"] == "0":
index1 += 1
if index1 > GRADES_TO_DISPLAY:
if index1 > grades_dispaly:
continue
evaluation = get_evaluation(grade_json)
response["evaluations"].append(evaluation)
else:
index2 += 1
if index2 > GRADES_TO_DISPLAY:
if index2 > grades_dispaly:
continue
grade = get_grade(grade_json)
response["grades"].append(grade)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ecole_directe/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"documentation": "https://github.com/hacf-fr/hass-ecoledirecte",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/hacf-fr/hass-ecoledirecte/issues",
"version": "0.3.18"
"version": "0.3.19"
}
2 changes: 1 addition & 1 deletion custom_components/ecole_directe/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def __init__(
self, coordinator: EDDataUpdateCoordinator, eleve: EDEleve, suffix: str
) -> None:
"""Initialize the ED sensor."""
super().__init__(coordinator, "timetable_" + suffix, eleve, "len")
super().__init__(coordinator, name="timetable_" + suffix, eleve=eleve, state="len")
self._suffix = suffix
self._start_at = None
self._end_at = None
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ecole_directe/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"data": {
"refresh_interval": "Data refresh interval (in minutes)",
"lunch_break_time": "Lunch break time",
"decode_html": "Decode HTML for homeworks - Warning it will delete all HTML (style, links, iFrame, etc.)"
"decode_html": "Decode HTML for homeworks - Warning it will delete all HTML (style, links, iFrame, etc.)",
"notes_affichees": "Maximum grades to display"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ecole_directe/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"data": {
"refresh_interval": "Data refresh interval (in minutes)",
"lunch_break_time": "Lunch break time",
"decode_html": "Decode HTML for homeworks - Warning it will delete all HTML (style, links, iFrame, etc.)"
"decode_html": "Decode HTML for homeworks - Warning it will delete all HTML (style, links, iFrame, etc.)",
"notes_affichees": "Maximum grades to display"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ecole_directe/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"data": {
"refresh_interval": "Intervale de mise à jour des données (en minutes)",
"lunch_break_time": "Heure de la pause déjeuner",
"decode_html": "Decode HTML pour les devoirs - Attention cela va supprimer tout le HTML (style, liens, iFrame, etc.)"
"decode_html": "Decode HTML pour les devoirs - Attention cela va supprimer tout le HTML (style, liens, iFrame, etc.)",
"notes_affichees": "Notes maximum affichées"
}
}
}
Expand Down

0 comments on commit 7632eba

Please sign in to comment.