Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/constants/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SearchByStringExampleMap = new Map([
["course-code", "MAS3114"],
["course-title", "Linear Algebra"],
["instructor", "Huang"],
["class-num", "14240"]
]);

export function getSearchByStringExample(searchByStr: string): string {
Expand Down
3 changes: 3 additions & 0 deletions app/src/constants/soc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ export enum SearchBy {
COURSE_CODE = "Course Code",
COURSE_TITLE = "Course Title",
INSTRUCTOR = "Instructor",
SECTION_ID = "Section ID",
}

export const SearchBys = [
SearchBy.COURSE_CODE,
SearchBy.COURSE_TITLE,
SearchBy.INSTRUCTOR,
SearchBy.SECTION_ID,
];

const SearchByStringMap = new Map([
["course-code", SearchBy.COURSE_CODE],
["course-title", SearchBy.COURSE_TITLE],
["instructor", SearchBy.INSTRUCTOR],
["class-num", SearchBy.SECTION_ID],
]);

export function getSearchBy(searchByStr: string): SearchBy {
Expand Down
6 changes: 6 additions & 0 deletions app/src/scripts/soc/soc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export abstract class SOC_Generic {
),
),
);
} else if (searchBy === SearchBy.SECTION_ID) {
return this.courses.filter((c) =>
c.sections.some((s) =>
s.number.toString().includes(phrase),
),
);
}
throw new Error("Unhandled SearchBy.");
}
Expand Down