Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fixed issues with prerequisites inaccuracies #588

Merged
merged 11 commits into from
Apr 11, 2024
2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
npm install
npm install -g eslint
- name: Run ESLint
run: eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0
run: eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0
4 changes: 2 additions & 2 deletions lib/components/popups/course-search/prereqs/PrereqDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ const PrereqDisplay: FC = () => {
setHasPreReqs(false);

// First get all valid preReqs (isNegative = true)
let preReqs = filterNNegatives(version);
let preReqs = filterNNegatives(courseToShow);
setNNegativePreReqs(preReqs);
// If there exists preReqs, we need to process and display them.
if (version !== 'None' && preReqs.length > 0) {
setHasPreReqs(true);
display(preReqs);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [version, courseCache]);
}, [courseToShow]);

/**
* Processes then displays prereqs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const PrereqDropdown: FC<{
const getChildPrereqs = () => {
// eslint-disable-next-line array-callback-return
return element.map((el: any, index: number): JSX.Element => {
if (typeof el === 'number') {
return processPrereqs(el, index);
} else return <></>;
return processPrereqs(el, index);
});
};

Expand Down
6 changes: 5 additions & 1 deletion lib/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

body {
margin: 0;
font-family: Futura, Trebuchet MS, Arial, sans-serif;
font-family:
Futura,
Trebuchet MS,
Arial,
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Expand Down
27 changes: 24 additions & 3 deletions lib/resources/assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ export const course_tags = [
* @param inspected - the course
* @returns array with valid prereqs
*/
export const filterNNegatives = (inspected: Course | 'None'): any[] => {
export const filterNNegatives = (
inspected: UserCourse | Course | 'None' | null,
): any[] => {
let preReqs: any[] = [];
if (inspected !== 'None' && inspected !== undefined) {
if (inspected !== 'None' && inspected) {
preReqs = inspected.preReq.filter((section: any) => {
return section.IsNegative === 'N';
});
Expand Down Expand Up @@ -1031,7 +1033,8 @@ export const checkAllPrereqs = (
return new Promise((resolve) => {
getCourse(number, courseCache, currCourses, -1).then((course) => {
if (course.resp !== null) {
let filtered = filterNNegatives(course.resp);
const version = getVersion(course.resp, semester + ' ' + year.year);
let filtered = filterNNegatives(version);
if (filtered.length === 0) {
return resolve(true);
} else {
Expand Down Expand Up @@ -1061,6 +1064,24 @@ export const checkAllPrereqs = (
});
};

/**
* @param course - course object
* @param term - term of the course
* @returns the version of course with matching term
*/
export const getVersion = (course: any, term: string) => {
for (let v of course.versions) {
if (v.term === term) {
return v;
}
}
if (course.versions.length > 0) {
return course.versions[0];
} else {
return course;
}
};

/**
* @param major - major name
* @returns the major object from the name
Expand Down
4 changes: 3 additions & 1 deletion lib/resources/redux_sample/Counter.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
left: 0;
top: 0;
opacity: 0;
transition: width 1s linear, opacity 0.5s ease 1s;
transition:
width 1s linear,
opacity 0.5s ease 1s;
}

.asyncButton:active:after {
Expand Down
Loading