|
5 | 5 |
|
6 | 6 | ## 1. Editing `my_config` |
7 | 7 |
|
| 8 | +### 1.1 Setting the language |
| 9 | + |
| 10 | +Set the language using: |
| 11 | + |
| 12 | +- `untis.my_config.set_lang('en')` |
| 13 | +- `untis.my_config.set_lang('de')` |
| 14 | + |
| 15 | +Note: Currently only german (`'de'`) and english (`en`) is supported. |
| 16 | + |
| 17 | +### 1.2 Understanding the objects |
| 18 | + |
| 19 | +`units.my_config` is split into 3 subclasses: |
| 20 | +- `timetable_mapping_config (TimeTableMappingConfig)` |
| 21 | +- `self.language_config (LanguageConfig)` |
| 22 | +- `self.html_style_config (HTMLStyleConfig)` |
| 23 | + |
| 24 | +### 1.3 Modifying specific values |
| 25 | + |
8 | 26 | Modify the Configuration using `untis.my_config.* = ...` |
9 | 27 |
|
10 | 28 | For example: |
11 | | -- `untis.my_config.timetable_html_footer = ...` |
12 | | -- `untis.my_config.two_week_abbreviation = ...` |
13 | | -- `untis.my_config.teacher_mapping = ...` |
| 29 | +- `untis.my_config.html_style_config.timetable_html_footer = ...` |
| 30 | +- `untis.my_config.language_config.two_week_abbreviation = ...` |
| 31 | +- `untis.my_config.timetable_mapping_config.teacher_mapping = ...` |
14 | 32 | - ... |
15 | 33 |
|
| 34 | + |
16 | 35 | ## 2. Timetable mappings |
17 | 36 |
|
18 | | -See [config.py](../untis/config.py) for more info. |
| 37 | +Example `personal_timetable_entries` |
| 38 | +```python |
| 39 | +untis.my_config.timetable_mapping_config.personal_timetable_entries: dict[str, tuple[set[str], set[str]]] = { |
| 40 | + 'child1': ( |
| 41 | + # Set of teacher abbreviations |
| 42 | + {'T1', 'T2', 'T3', ...}, |
| 43 | + # Set of subject abbreviations |
| 44 | + {'M', 'G', 'E', ...}), |
| 45 | + 'child2': ( |
| 46 | + {'T1', 'T2', 'T3', ...}, |
| 47 | + {'M', 'G', 'E', ...}), |
| 48 | +} |
| 49 | +``` |
| 50 | +This allows using `TimeTable.filter_hours_by_personal('child1')` on an existing TimeTable, which only returns the |
| 51 | +lessons with certain teachers or subjects connected to it. Useful if your child is in a class, where some pupils attend |
| 52 | +lessons that your child doesn't. |
| 53 | + |
| 54 | +Example `teacher_mapping` |
| 55 | +```python |
| 56 | +untis.my_config.timetable_mapping_config.teacher_mapping: dict[int, tuple[str, str, tuple[str, ...]]] = { |
| 57 | + 0: ('Unknown', 'N/A', ('/',)), # Always means no teacher, never assign a real name here |
| 58 | + # Teacher ID: (full name, abbreviated Name, (Subject abbreviation 1, ...) |
| 59 | + 3: ('Tom Mister', 'AB', ('M', 'G', 'E')), |
| 60 | + 8: ('Benjamin Bob', 'CD', ('PS', 'PE', 'FR')), |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +This allows the TimeTable to format the name of the teachers correctly. The API technically does have a |
| 65 | +`Session.teachers()` function which uses the webuntis `getTeachers` endpoint. However, most student accounts don't have |
| 66 | +access to that endpoint. I'm working on a way integrate with the getTeachers endpoint directly for the accounts that |
| 67 | +support it. |
| 68 | + |
| 69 | +> [!CAUTION] |
| 70 | +> More documentation will follow soon. |
| 71 | +
|
| 72 | +Generating this mapping is rather tedious, but the first step is getting the IDs. |
| 73 | +See [2.1 Generating element IDs](#21-generating-element-ids) for help. |
| 74 | + |
| 75 | +Example `subject_to_color` |
| 76 | +```python |
| 77 | +untis.my_config.timetable_mapping_config.subject_to_color: dict[tuple[str, str, int], tuple[int, int, int]] = { |
| 78 | + # Subjet abbreviation, full subject name, subject id: RGB Value |
| 79 | + ('M', 'Math', 107): (83, 103, 220), |
| 80 | + ('E', 'English', 193): (45, 26, 136), |
| 81 | + ('FR', 'French', 981): (122, 112, 212) |
| 82 | +} |
| 83 | +``` |
| 84 | +This allows the TimeTable to display corresponding colours along with the subject names. |
| 85 | +The API technically delivers this, but I'm still uncertain whether this is safe to use. |
| 86 | + |
| 87 | +Generating this mapping is rather tedious, but the first step is getting the IDs. |
| 88 | +See [2.1 Generating element IDs](#21-generating-element-ids) for help. |
| 89 | + |
| 90 | +Also see [config.py](../untis/config.py) for more info on `TimeTableMappingConfig`. |
19 | 91 |
|
20 | 92 | ### 2.1 Generating element IDs |
21 | 93 |
|
| 94 | +In the following you will see the code I used to generate teacher & subject IDs. |
| 95 | + |
22 | 96 | ```python |
23 | 97 | import typing |
24 | 98 | import uuid |
@@ -60,7 +134,9 @@ def _return_data_whole_school_year( |
60 | 134 | return result_table |
61 | 135 |
|
62 | 136 |
|
63 | | -def return_all_subjects(session: untis.Session) -> tuple[list[untis.objects.Subject], dict[untis.objects.Subject, list[str]]]: |
| 137 | +def return_all_subjects( |
| 138 | + session: untis.Session |
| 139 | +) -> tuple[list[untis.objects.Subject], dict[untis.objects.Subject, list[str]]]: |
64 | 140 | subjects: list[untis.objects.Subject] = [] |
65 | 141 | subject_info: dict[untis.objects.Subject, list[str]] = {} |
66 | 142 |
|
@@ -89,7 +165,9 @@ def return_all_subjects(session: untis.Session) -> tuple[list[untis.objects.Subj |
89 | 165 | return subjects, subject_info |
90 | 166 |
|
91 | 167 |
|
92 | | -def return_all_teacher_ids(session: untis.Session) -> tuple[list[untis.objects.Teacher], dict[untis.objects.Teacher, list[str]]]: |
| 168 | +def return_all_teacher_ids( |
| 169 | + session: untis.Session |
| 170 | +) -> tuple[list[untis.objects.Teacher], dict[untis.objects.Teacher, list[str]]]: |
93 | 171 | teachers: list[untis.objects.Teacher] = [] |
94 | 172 | teacher_info: dict[untis.objects.Teacher, list[str]] = {} |
95 | 173 |
|
@@ -118,10 +196,40 @@ def return_all_teacher_ids(session: untis.Session) -> tuple[list[untis.objects.T |
118 | 196 | return teachers, teacher_info |
119 | 197 | ``` |
120 | 198 |
|
| 199 | +In this section, `Teacher` and `Subject` is interchangeable. Use `return_all_subjects` for receiving `Subject`s, |
| 200 | +and `return_all_teacher_ids` for `Teacher`s. The concept is the same for both. |
| 201 | + |
| 202 | +These functions will return a `tuple[list[untis.objects.Teacher], dict[untis.objects.Teacher, list[str]]]`: |
| 203 | +- First element: `teachers: list[Teacher]`, the `name` and `long_name` fields will be set to `unknown` initially. |
| 204 | + |
| 205 | +- Second element: `teacher_info: dict[untis.objects.Teacher, list[str]]`, this will help you fill up the teacher |
| 206 | +mapping. Each teacher will have a few lessons associated with it, so you can create the mapping `ID -> name`. |
| 207 | +In the Untis app the names of the teachers will be displayed, so open the Untis app and manually find the lessons |
| 208 | +and transfer the names of the teachers. I am aware that this is very tedious to do, especially if your school has |
| 209 | +hundreds of teachers. |
| 210 | + |
| 211 | +> [!CAUTION] |
| 212 | +> More documentation will follow soon. |
| 213 | +
|
121 | 214 | ## 3. Language specific configuration |
122 | 215 |
|
123 | | -See [config.py](../untis/config.py) for more info. |
| 216 | +Also see [Setting the language](#11-setting-the-language) for more info on setting the language. |
| 217 | + |
| 218 | +You can also manipulate values manually, for example: |
| 219 | +- `untis.my_config.language_config.two_week_abbreviation = ...` |
| 220 | +- `untis.my_config.language_config.two_week_abbreviation = ...` |
| 221 | +- ... |
| 222 | + |
| 223 | +Also see [config.py](../untis/config.py) for more info on `LanguageConfig`. |
124 | 224 |
|
125 | 225 | ## 4. HTML style configuration |
126 | 226 |
|
127 | | -See [config.py](../untis/config.py) for more info. |
| 227 | +Also see [Setting the language](#11-setting-the-language) for more info on setting the language. |
| 228 | + |
| 229 | +You can also manipulate values manually, for example: |
| 230 | +- `my_config.html_style_config.timetable_html_footer = ...` |
| 231 | +- `my_config.html_style_config.html_style_config.lesson_time_ranges = ...` |
| 232 | +- `my_config.html_style_config.html_style_config.table_header_base_rgb = ...` |
| 233 | +- ... |
| 234 | + |
| 235 | +Also see [config.py](../untis/config.py) for more info on `HTMLStyleConfig`. |
0 commit comments