Feature Views¶
These views implement specific user interactions and workflows. They often combine multiple UI components like Buttons, Select Menus, and Modals.
sequenceDiagram
User->>Discord: /module Mathematic
Discord->>Oscar: Interaction Event
Oscar->>ModulSearch: search_module()
ModulSearch->>Module: from_name("Mathematic M1")
Module->>Database: Query or API fetch
Database-->>Module: Module Object
Module-->>ModulSearch: Return
ModulSearch->>ModuleView: Initialize with module
ModuleView-->>User: Interactive Card
1. Onboarding (StartView)¶
The initial onboarding screen (/start) where users select their language, semester, and course of study.
Key Logic:
* Multi-Step Process: The view dynamically rebuilds itself (_build_view) depending on whether language, semester, or major is already set in the state.
* Semester Groups: Uses SelectButton instances grouped by "Semester". Clicking one updates the user's preference in the database immediately.
* Persistence: Directly interacts with the preferences table via db.set_preferences to store the user's major and language.
src.oscar.ui.start_view.StartView ¶
Bases: OwnerOnly, LayoutView
Class for the initial start view for the discord bot
Source code in src/oscar/ui/start_view.py
_build_view ¶
Source code in src/oscar/ui/start_view.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
2. Module Interactions¶
Module Summary (ModuleView)¶
Displays a summary card of a specific module. It serves as the hub for further actions.
- Add to Plan: Adds the module to the user's semester plan via
db.add_to_semesterplan. - Detailed Info: Swaps the current message content with an
AllInfoView. - LSF: A link button into the public LSF course search, built by
util.lsf. - Handbook: A link button into the faculty module handbook, built by
util.bookstack. It points into the reader's own programme when we know it.
src.oscar.ui.module_view.ModuleView ¶
Bases: LayoutView
Class for displaying module related information
Source code in src/oscar/ui/module_view.py
Comparison (CompareView)¶
The UI for /compare. It puts two or three modules next to each other so a student can
pick one elective out of several without opening three cards.
- Layout: One inline embed field per module. Discord renders three of them in a
row on a wide screen and stacks them on a phone, which is why
MAX_MODULESis 3 rather than a round number. - Rows:
ROW_KEYSdrives both the values and the headings, so a row cannot be added without a translated heading for it. - Footer:
differing_rowsnames the rows the modules disagree on. That is the reason for the comparison, so it is said out loud instead of being left to the eye. - Limits: Titles and values are cut to discord's 256 and 1024 characters. Going over makes the whole message fail rather than look untidy.
src.oscar.ui.compare_view.CompareView ¶
Bases: OwnerOnly, View
Two or three modules side by side, with a handbook link under each.
Source code in src/oscar/ui/compare_view.py
create_embed ¶
Builds the comparison itself.
Returns:
| Type | Description |
|---|---|
Embed
|
An embed with one inline field per module and a closing line naming |
Embed
|
what differs. |
Source code in src/oscar/ui/compare_view.py
src.oscar.ui.compare_view.module_rows ¶
The values this module contributes to the comparison, keyed by ROW_KEYS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The module to read. |
required |
language
|
LanguageCode
|
The language the student picked. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
One cleaned, single line value per row key. |
Source code in src/oscar/ui/compare_view.py
src.oscar.ui.compare_view.differing_rows ¶
The row keys on which the modules do not agree.
That is the whole reason for putting them side by side, so it is worth saying out loud rather than leaving the reader to spot it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
list[dict[str, str]]
|
One |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The differing keys, in |
Source code in src/oscar/ui/compare_view.py
Detailed Information (AllInfoView)¶
Displays the full data of a module (Credits, Lecturer, Content, Learning Goals).
It uses the Module class methods (e.g., get_content(language)) to fetch localized strings, potentially triggering on-the-fly translation if the requested language is missing in the database.
src.oscar.ui.all_info_view.AllInfoView ¶
Bases: LayoutView
Class representing a detailed view of module information in a Discord UI.
Source code in src/oscar/ui/all_info_view.py
build_view ¶
Builds the detailed module information view.
Source code in src/oscar/ui/all_info_view.py
3. Semester Plan (SemesterplanView)¶
Shows the user's personal semester plan.
Technical Specifics:
* Inheritance: Inherits from CustomView to support external rebuild triggers.
* Dynamic Rebuild: The build_view() method fetches the fresh module list from the database every time it runs.
* Interaction: Uses DeleteButton, which calls self.view_ref.build_view() on this view to refresh the UI immediately after a module is removed.
src.oscar.ui.semesterplan_view.SemesterplanView ¶
Bases: CustomView
Custom class to hold a semester plan (view)
Source code in src/oscar/ui/semesterplan_view.py
build_view ¶
Source code in src/oscar/ui/semesterplan_view.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
4. Search & Filter¶
Filter Selection (SelectView)¶
The UI for the /filter command. It allows users to combine criteria like CP, SWS, and exam type.
- Logic: It maps button labels (e.g., "<5CP") to
CpFilterandSwsFilterEnums. - Execution: Upon clicking "Search", it instantiates
ModulesFilterto process the criteria and transitions to thePaginatedModuleViewwith the results.
src.oscar.ui.select_view.SelectView ¶
Bases: OwnerOnly, LayoutView
Class for filtering a list of modules
Source code in src/oscar/ui/select_view.py
_build_view ¶
Draws the whole mask.
Source code in src/oscar/ui/select_view.py
Filter Results (PaginatedModuleView)¶
Displays the search/filter results with navigation buttons (<<, <, >, >>).
It manages pagination logic (index, per_page) locally and updates the Embed content dynamically.
src.oscar.ui.select_view.PaginatedModuleView ¶
Bases: OwnerOnly, LayoutView
Class for showing a filtered module list page by page, in a chosen order.
Source code in src/oscar/ui/select_view.py
_build_page ¶
Source code in src/oscar/ui/select_view.py
_next
async
¶
5. User Feedback (FeedbackView)¶
A complex form allowing users to submit ratings and text feedback.
Components:
* Select Menus: Three dropdowns for scoring (Intuitiveness, Discoverability, Usefulness). The code maps values (1-4) inversely to the database storage (where 4 might represent the best or worst score depending on the specific scale logic).
* Modals: Buttons trigger the ImproveModal to collect text input (Improvements, Wishes, Bugs).
src.oscar.ui.feedback_view.FeedbackView ¶
Bases: OwnerOnly, LayoutView
Class for giving feedback
Source code in src/oscar/ui/feedback_view.py
_build_view ¶
Source code in src/oscar/ui/feedback_view.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
Feedback Modal¶
Helper class (discord.ui.Modal) used by FeedbackView to capture multi-line text input.
src.oscar.ui.feedback_view.ImproveModal ¶
Bases: Modal
Source code in src/oscar/ui/feedback_view.py
6. Standard Study Plan (SPlanView)¶
The UI for /standard_plan. Unlike the others it uses the classic embed API rather than
Components V2, because it carries an image attachment.
- Picture: Two programmes have a hand drawn image. Every other plan is rendered
from its json by
util.plan_image. - Handbook: A link button into the programme's own book in the faculty BookStack.
src.oscar.ui.splan_view.SPlanView ¶
Bases: OwnerOnly, View
View for the standard study plan (NO Components V2).
Source code in src/oscar/ui/splan_view.py
create_embed ¶
Builds the embed for the standard study plan.
Source code in src/oscar/ui/splan_view.py
get_image_file ¶
The picture that belongs to this plan.
A hand drawn image wins while there is nothing to mark. It is a flat png, so a tick cannot be drawn into it. As soon as the student has saved modules the plan is rendered instead, because a marked text next to an unmarked picture reads as two different plans.
Returns:
| Type | Description |
|---|---|
File | None
|
A |