Skip to content

fix: show missing section warnings on schedule load#1433

Open
ronaldw07 wants to merge 5 commits intoicssc:mainfrom
ronaldw07:fix-missing-section-warnings-on-load
Open

fix: show missing section warnings on schedule load#1433
ronaldw07 wants to merge 5 commits intoicssc:mainfrom
ronaldw07:fix-missing-section-warnings-on-load

Conversation

@ronaldw07
Copy link
Copy Markdown
Contributor

@ronaldw07 ronaldw07 commented Jan 18, 2026

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

  • Added checkForMissingSections() method to AppStore that:
    • Groups courses by course ID (deptCode + courseNumber + term)
    • Compares required section types (from sectionTypes array) with enrolled section types
    • Identifies missing required sections
    • Displays a warning snackbar listing all affected courses
  • Integrated into schedule loading: Call checkForMissingSections() after successful schedule load in loadSchedule()
  • Extracted sectionTypeToName() utility function: Created a reusable utility to convert section type codes to readable names
  • Refactored getMissingSections.ts: Updated to use the shared utility function, eliminating code duplication

How It Works

The getCourseInfo API endpoint (called by fromScheduleSaveState) already returns the full sectionTypes array 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:

1 course is missing required sections:
COMPSCI 161 (2024 Fall): Missing Discussion

For multiple courses:

2 courses are missing required sections:
COMPSCI 161 (2024 Fall): Missing Discussion
PHYSICS 7C (2024 Fall): Missing Lab

Test plan

  • Load a saved schedule with courses missing required sections
  • Verify warning snackbar appears on page load
  • Verify warning message correctly identifies missing sections
  • Verify existing missing section warnings in the AddedCourses pane still work
  • Verify no warnings appear for courses with all required sections

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
Copy link
Copy Markdown
Contributor

@calebwongg calebwongg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
image
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!

Comment thread apps/antalmanac/src/stores/AppStore.ts Outdated
({ courseId, missingSections }) => `${courseId}: Missing ${missingSections.join(', ')}`
);

const message =
Copy link
Copy Markdown
Contributor

@calebwongg calebwongg Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
            )}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

@calebwongg calebwongg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
image
An example is that EECS 31 doesn't require a lab or seminar. The warning should only be displaying for the lab

Comment thread apps/antalmanac/src/stores/Schedules.ts Outdated
const fullCourseRequests = Array.from(uniqueCourses).map(async (courseKey) => {
const [term, deptCode, courseNumber] = courseKey.split('-');
try {
const fullData = await WebSOC.query({ term, deptCode, courseNumber });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@ronaldw07 ronaldw07 Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see. I will try to fix it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good thank you !!!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor

@calebwongg calebwongg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Image

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.
@ronaldw07
Copy link
Copy Markdown
Contributor Author

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.

Comment thread apps/antalmanac/src/stores/Schedules.ts Outdated
Comment thread apps/antalmanac/src/stores/Schedules.ts Outdated
Comment thread apps/antalmanac/src/stores/Schedules.ts Outdated
Comment thread apps/antalmanac/src/stores/Schedules.ts Outdated
Comment thread apps/antalmanac/src/stores/Schedules.ts Outdated
Copy link
Copy Markdown
Contributor

@calebwongg calebwongg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature looks good ! some small changes though, the main one being to change the idea of building our own keys with '|'

@ronaldw07
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@github-actions github-actions Bot added the Stale label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show missing section warnings for saved courses on page load

2 participants