fix: show missing section warnings on schedule load#1433
fix: show missing section warnings on schedule load#1433ronaldw07 wants to merge 5 commits intoicssc:mainfrom
Conversation
When courses are restored from saved state on page load, missing section warnings now appear for courses that require additional sections (e.g., lab, discussion) that weren't saved. Changes: - Add checkForMissingSections() method to AppStore that detects and displays warnings for courses missing required sections - Call checkForMissingSections() after successful schedule load - Extract sectionTypeToName() utility function to eliminate code duplication - Refactor getMissingSections.ts to use shared utility function Fixes icssc#1399
c280960 to
66ce27c
Compare
calebwongg
left a comment
There was a problem hiding this comment.
Haven't looked too deep into the code yet, but upon just checking to see if the feature works, we still aren't displaying the missing sections warning when the user loads in their schedule

This is the what my added courses pane looks like right when I load in my classes, and if the user saved an incomplete schedule, we have no missing sections warning. We want to have the warning display right when the schedule loads in. Feel free to text me on discord (calbe__) if you have any further questions!
| ({ courseId, missingSections }) => `${courseId}: Missing ${missingSections.join(', ')}` | ||
| ); | ||
|
|
||
| const message = |
There was a problem hiding this comment.
We want to keep the warning consistent, so instead of the snackbar we want to use the mui alert. You shouldn't need to code in the alert because we already have it in SectionTable.tsx:
{missingSections?.length > 0 && (
<Alert
severity="warning"
sx={{
mb: 1,
'& .MuiAlert-message': {
display: 'flex',
alignItems: 'center',
},
}}
>
Missing required sections: {missingSections.join(', ')}
</Alert>
)}
There was a problem hiding this comment.
Look into how the missing sections attributes flow through the code. We store the missing sections as a property on CourseWithTerm objects and check that value when the section table mounts. Feel free to reach out if you have questions
When loading a saved schedule, getCourseInfo was called with specific sectionCodes, causing WebSOC to return only those sections. This resulted in incomplete sectionTypes arrays, which prevented missing section warnings from appearing correctly. Now fetches full course data for each unique course to get complete sectionTypes, ensuring the MUI Alert warnings appear when sections are missing. Fixes icssc#1399
There was a problem hiding this comment.
issue: Again haven't looked into the code, but now we are staying consistent with the mui alert and there is some sort of missing sections comparison going on upon schedule load (which is good).
However, the comparison doesn't work as it thinks that some classes require sections that don't exist for that class.

An example is that EECS 31 doesn't require a lab or seminar. The warning should only be displaying for the lab
| const fullCourseRequests = Array.from(uniqueCourses).map(async (courseKey) => { | ||
| const [term, deptCode, courseNumber] = courseKey.split('-'); | ||
| try { | ||
| const fullData = await WebSOC.query({ term, deptCode, courseNumber }); |
There was a problem hiding this comment.
nit: websoc lets you query with an array of section codes. Its redundant here to have an individual query for each section code. We would rather only need one query using an array of section codes as the query parameter.
There was a problem hiding this comment.
oh I see. I will try to fix it
There was a problem hiding this comment.
sounds good thank you !!!
There was a problem hiding this comment.
let me know if this works!
Instead of making individual WebSOC queries for each course, group courses by (term, deptCode) and query all courses in a department at once. This reduces the number of API calls significantly.
calebwongg
left a comment
There was a problem hiding this comment.
issue: Still didn't get into the bulk of the code, but some functionality is still a little buggy! You can see here that I'm getting an alert for a missing lab when MATH 3A has no lab section:
Another thing worth looking into also is that auth is substantially slower when loading in the app. It also seems a bit slower switching between the 'SEARCH' pane and the 'ADDED' pane (this could just be placebo). I'm suspecting it might still be because of redundant API queries, so try and look into it and see what you can do. If you run into any problems, or if you have any questions on how to implement this fix feel free to reach out! Please test before marking ready for review!
… warnings When fetching complete sectionTypes on schedule load, the previous approach queried all courses in a department which caused cross-department contamination (e.g. PHYSICS 3A and SOC SCI 3A polluting MATH 3A sectionTypes with Lab). Now queries each unique (term, deptCode, courseNumber) individually and filters results to only match the correct department and course number.
|
Fixed the false positive warnings. The previous dept-wide query was returning courses from other departments with the same course number (e.g. PHYSICS 3A and SOC SCI 3A contaminating MATH 3A's sectionTypes with Lab). Now queries each course individually by (term, deptCode, courseNumber) and filters results to only the matching department and course number. Tested locally - MATH 3A with only lecture correctly shows 'Missing: Discussion' and no false Lab warning. |
calebwongg
left a comment
There was a problem hiding this comment.
feature looks good ! some small changes though, the main one being to change the idea of building our own keys with '|'
…or sectionTypes lookup
|
addressed all the nits from Feb 25 (hopefully) — switched to a nested Map<Term, Map<Dept, Map<CourseNum, SectionTypes>>> instead of building synthetic string keys, used WebsocSectionType directly for the set type, and removed the redundant dept/courseNumber filter checks inside the loop. |
Summary
Fixes #1399 - Show missing section warnings for saved courses on page load
When AntAlmanac loads and restores courses from
fromScheduleSaveState, the app now detects and displays warnings for courses that are missing required sections (e.g., lab, discussion).Changes
checkForMissingSections()method to AppStore that:sectionTypesarray) with enrolled section typescheckForMissingSections()after successful schedule load inloadSchedule()sectionTypeToName()utility function: Created a reusable utility to convert section type codes to readable namesgetMissingSections.ts: Updated to use the shared utility function, eliminating code duplicationHow It Works
The
getCourseInfoAPI endpoint (called byfromScheduleSaveState) already returns the fullsectionTypesarray containing all available section types for a course. After a schedule loads successfully,checkForMissingSections()compares the required section types with the sections the user has enrolled in and displays warnings for any missing required sections.Example Output
If a user has saved a schedule with only Lecture + Lab sections of a course that requires Lecture + Lab + Discussion, they'll see:
For multiple courses:
Test plan