diff --git a/data/schedule.py b/data/schedule.py index a1aa5d1..0844bcb 100644 --- a/data/schedule.py +++ b/data/schedule.py @@ -73,7 +73,7 @@ class Timeslot: return f"[{self.online_platform.value.get('name')}]({self.online_link})" def _get_location_str(self, offline_prefix="in", online_prefix="**online** @") -> str: - return f"{offline_prefix} **{self.location}**" if self.location is not None \ + return f"{offline_prefix} {self.location}" if self.location is not None \ else f"{online_prefix} **{self.get_link_str()}**" def get_special_fmt_str(self) -> Optional[str]: @@ -86,7 +86,7 @@ class Timeslot: # Something else is wrong return f"⚠️ {self.course} gaat vandaag door van **{timeFromInt(self.start_time)}** tot " \ - f"**{timeFromInt(self.end_time)}** {self._get_location_str(online_prefix='op')}" + f"**{timeFromInt(self.end_time)}** **{self._get_location_str(online_prefix='op')}**" @staticmethod def from_slot_dict(slot_dict: Dict, course_dict: Dict, current_week: int): @@ -95,15 +95,14 @@ class Timeslot: """ special = False - week = find_week(str(current_week), slot_dict) - if week is not None: + if "weeks" in slot_dict and str(current_week) in slot_dict["weeks"]: # If at least one thing was changed, this slot requires extra attention special = True # Overwrite the normal data with the customized entries - slot_dict.update(week) + slot_dict.update(slot_dict["weeks"][str(current_week)]) # Only happens online, not on-campus - online_only = week.get("online_only", False) + online_only = slot_dict["weeks"][str(current_week)].get("online_only", False) if online_only: slot_dict.pop("location") @@ -407,9 +406,7 @@ class ScheduleEmbed(LesEmbed): if not has_link: return "" - # Store in a set first to remove duplicates - entries = list(set(f"{entry.course}: **{entry.get_link_str()}**" for entry in has_link)) - return "\n".join(list(sorted(entries))) + return "\n".join(list(f"{entry.course}: **{entry.get_link_str()}**" for entry in has_link)) def find_minor(client: commands.Bot, userid: int) -> Tuple[Optional[int]]: @@ -423,20 +420,3 @@ def find_minor(client: commands.Bot, userid: int) -> Tuple[Optional[int]]: return role.id, return None, - - -def find_week(week: str, slot_dict: Dict) -> Optional[Dict]: - """Find a week in a slot_dict""" - if "weeks" not in slot_dict: - return None - - # Split all entries based on commas - # to allow grouping weeks together - for w in slot_dict["weeks"]: - weeks = w.split(",") - - if week in weeks: - return slot_dict["weeks"][w] - - # Week was not in any of the lists - return None diff --git a/files/schedules/31.json b/files/schedules/31.json index 4e3d28c..9dfa778 100644 --- a/files/schedules/31.json +++ b/files/schedules/31.json @@ -15,23 +15,19 @@ { "name": "Beveiliging en parallelle systemen", "role": 891744461405687808, + "online_links": { + "zoom": "https://ufora.ugent.be/d2l/ext/rp/439235/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" + }, "schedule": [ { "course": "Modelleren en Simuleren", - "online_links": { - "zoom": "https://ufora.ugent.be/d2l/ext/rp/439235/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" - }, "slots": [ { "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -54,12 +50,8 @@ }, "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -75,12 +67,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -97,8 +85,7 @@ { "course": "Parallelle Computersystemen", "online_links": { - "zoom": "https://ufora.ugent.be/d2l/ext/rp/449671/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826", - "opencast": "https://elosp.ugent.be/opencastplanner/live/GCMobile-ocrec79" + "zoom": "https://ufora.ugent.be/d2l/ext/rp/449671/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" }, "slots": [ { @@ -107,7 +94,6 @@ "canceled": true } }, - "online": "opencast", "location": { "campus": "Ardoyen", "building": "iGent 126", @@ -120,7 +106,6 @@ } }, { - "online": "opencast", "location": { "campus": "Ardoyen", "building": "iGent 126", @@ -167,12 +152,8 @@ }, "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Ardoyen", "building": "iGent 125", @@ -188,20 +169,13 @@ }, { "course": "Wiskundige Modellering", - "online_links": { - "zoom": "https://ufora.ugent.be/d2l/ext/rp/446530/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" - }, "slots": [ { "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -217,12 +191,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S8", @@ -238,12 +208,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S8", @@ -276,12 +242,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -297,12 +259,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -318,12 +276,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -347,12 +301,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S8", @@ -368,12 +318,8 @@ "weeks": { "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -392,12 +338,8 @@ }, "6": { "canceled": true - }, - "10,11,12": { - "online_only": true } }, - "online": "zoom", "location": { "campus": "Sterre", "building": "S9", @@ -414,8 +356,7 @@ { "course": "Besturingssystemen", "online_links": { - "zoom": "https://ufora.ugent.be/d2l/ext/rp/442814/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826", - "opencast": "https://elosp.ugent.be/opencastplanner/live/GCMobile-ocrec79" + "zoom": "https://ufora.ugent.be/d2l/ext/rp/442814/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" }, "slots": [ { @@ -428,7 +369,6 @@ } } }, - "online": "opencast", "location": { "campus": "Ardoyen", "building": "iGent 126", @@ -441,7 +381,6 @@ } }, { - "online": "opencast", "location": { "campus": "Ardoyen", "building": "iGent 126",