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

GPA and Grade Distribution in Search Results #671

Merged
merged 94 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
fc9e52c
Add instructor to queryGrades
MinhxNguyen7 Aug 22, 2023
c9ccbbd
GPA cell in section table
MinhxNguyen7 Aug 23, 2023
800514b
Reasonable desktop styling
MinhxNguyen7 Aug 23, 2023
e4b021c
Button to hide GPA column
MinhxNguyen7 Aug 23, 2023
efd2f90
Basic grades popup functionality
MinhxNguyen7 Aug 23, 2023
f91d405
Close distribution on clickaway
MinhxNguyen7 Aug 23, 2023
4a8014d
Styling for GPA text
MinhxNguyen7 Aug 23, 2023
9cd4fc9
Hide Zotistics link in GPA popup
MinhxNguyen7 Aug 23, 2023
e673331
Close GPA distribution on re-click
MinhxNguyen7 Aug 23, 2023
ef39739
Add instructor to grade cache key
MinhxNguyen7 Aug 23, 2023
f3a5bf3
Section GPA graph for particular instructor
MinhxNguyen7 Aug 23, 2023
469b8d3
Restore labels to GPA graph
MinhxNguyen7 Aug 23, 2023
b28cd8a
Did todo
MinhxNguyen7 Aug 23, 2023
ead9dad
Replace Zotistics link with anchor on graph
MinhxNguyen7 Aug 26, 2023
7aadb4a
Clear gradesCache when clearing websocCache
MinhxNguyen7 Aug 26, 2023
a556c05
Lock for gradesCache
MinhxNguyen7 Aug 26, 2023
6f245d6
Helpful graphQL request failure
MinhxNguyen7 Aug 26, 2023
66b07a4
Remove debug print
MinhxNguyen7 Aug 26, 2023
829502f
Add classname to graph anchor
MinhxNguyen7 Aug 26, 2023
c427213
Disable scroll when popover
MinhxNguyen7 Aug 26, 2023
da49e25
Styled table for good spacing and side scrolling
MinhxNguyen7 Aug 26, 2023
249c13b
Remove Todo
MinhxNguyen7 Aug 26, 2023
b313fa6
Add Tabs for Sat/Sun on Map (#632)
KevinWu098 Aug 22, 2023
c1e2c37
Add support for new API time formats (#669)
KevinWu098 Aug 27, 2023
93f43bb
Revert "Add support for new API time formats (#669)" (#678)
KevinWu098 Aug 27, 2023
b43d6f0
Change "Copy Section Code" to Chip (#668)
KevinWu098 Aug 27, 2023
55057e8
Change 'boolean' visit value to string (#657)
KevinWu098 Aug 27, 2023
0309898
Add Course Level Filtering, Restyle Advanced Search (#677)
KevinWu098 Aug 30, 2023
53b2336
Schedule Select element closes with [esc] (#638)
KevinWu098 Aug 31, 2023
deec07d
Rename tabs for descriptiveness and concision (#675)
MinhxNguyen7 Aug 31, 2023
2855765
Add support for new API time formats (#669) (#679)
KevinWu098 Sep 4, 2023
3306538
Swap staging 68 to prod endpoint (#683)
KevinWu098 Sep 4, 2023
1703319
Overhaul Schedule Select | Edit | Delete (#659)
KevinWu098 Sep 4, 2023
91b5a86
Fix Light Mode Coloring (#684)
KevinWu098 Sep 4, 2023
5e5f346
Refactor .ics exports for new time formats (#685)
KevinWu098 Sep 4, 2023
52162b5
Add Vitest to GitHub Actions (#682)
EricPedley Sep 5, 2023
c50fc9f
Fix helper function: removeDuplicateMeetings (#688)
KevinWu098 Sep 6, 2023
7565b61
Switch to staging-88 PP GraphQL endpoint
MinhxNguyen7 Sep 7, 2023
e13cbd5
Generalize graphQL query function
MinhxNguyen7 Sep 7, 2023
c35262a
Merge branch 'main' into gpa
MinhxNguyen7 Sep 7, 2023
06f5940
Rename variables loadCourses for descriptiveness
MinhxNguyen7 Sep 7, 2023
9cdf18a
Implement aggregateGroupedGrades endpoint
MinhxNguyen7 Sep 7, 2023
71863c6
Move grades to separate module and class
MinhxNguyen7 Sep 7, 2023
8bc5e05
cacheOnly for section table grades
MinhxNguyen7 Sep 7, 2023
625682c
Fix typo in import statement
MinhxNguyen7 Sep 7, 2023
09f1a3a
Remove extraneous information from grades cache
MinhxNguyen7 Sep 7, 2023
736e505
Move Zotistics link to grades popup title
MinhxNguyen7 Sep 7, 2023
72e7f43
Refactor and set section table styling
MinhxNguyen7 Sep 7, 2023
77c1e4e
Fix bulk cache population cache hit
MinhxNguyen7 Sep 7, 2023
97e6fea
Refactor gpa (#689)
ap0nia Sep 7, 2023
1424923
fix: styling issues
ap0nia Sep 7, 2023
01c8b02
Tweak column widths for better mobile UX
MinhxNguyen7 Sep 7, 2023
6dd7e40
Fix GPA font size on mobile
MinhxNguyen7 Sep 7, 2023
be54eed
Fix average grade popup
MinhxNguyen7 Sep 7, 2023
7c3a53f
Update queryGrades documentation
MinhxNguyen7 Sep 7, 2023
d9143c0
Fix grades query with GEs
MinhxNguyen7 Sep 7, 2023
2ab1f9a
Bugfix for reversion to old MUI
MinhxNguyen7 Sep 7, 2023
d64bc2c
Merge branch 'main' into gpa
MinhxNguyen7 Sep 7, 2023
3617dff
Fix grades in added courses
MinhxNguyen7 Sep 7, 2023
fc77616
Correct documentation in grades popup
MinhxNguyen7 Sep 8, 2023
ccfb6e9
Filter out "ANY" GE
MinhxNguyen7 Sep 8, 2023
65c3238
Change grades endpoint name
MinhxNguyen7 Sep 8, 2023
c41cdce
TabStore default export
MinhxNguyen7 Sep 9, 2023
a683be5
Remove remnants of tab store from RightPaneStore
MinhxNguyen7 Sep 9, 2023
78d393d
Migrate columns to separate store
MinhxNguyen7 Sep 9, 2023
d0a59a7
Remove remnant of old column store
MinhxNguyen7 Sep 9, 2023
190fe46
Enable/disable columns independantly from selected
MinhxNguyen7 Sep 9, 2023
6627b6e
Disable GPA column in Added pane
MinhxNguyen7 Sep 10, 2023
073a449
Remove redundant import
MinhxNguyen7 Sep 16, 2023
2bd297b
Apply suggestions from review
MinhxNguyen7 Sep 16, 2023
06427cd
Merge branch 'main' into gpa
MinhxNguyen7 Sep 16, 2023
d772d23
Add missing parenthesis
MinhxNguyen7 Sep 16, 2023
0f70d1e
Add course and instructor to graph title
MinhxNguyen7 Sep 16, 2023
9487d02
Fix styling inconsistency
MinhxNguyen7 Sep 16, 2023
880d3f6
Tweak section table columns spacings
MinhxNguyen7 Sep 16, 2023
ba6af16
feat: multiple locations on courses (#696)
ap0nia Sep 16, 2023
d310f3a
Remove underline from location link (#699)
MinhxNguyen7 Sep 16, 2023
8d37524
fixing behavior of buttons in AddedPane (#703)
srukelman Sep 21, 2023
9b14840
Make it clear you import a .ics file to other calendars. (#706)
EricPedley Sep 27, 2023
3368692
Added Analytics to Column Toggle (#707)
KevinWu098 Sep 27, 2023
ba8c973
Update fuzzy search index (#710)
EricPedley Sep 28, 2023
c7efe15
Fix Undefined Trim Bug (#709)
KevinWu098 Sep 29, 2023
67c7b0d
Fix Added Pane Course Grouping (#711)
KevinWu098 Sep 29, 2023
8286e60
Update reviewer lottery roster
EricPedley Sep 30, 2023
f70aa8d
Parallelize Schedule Load Websoc Requests (#713)
EricPedley Oct 1, 2023
e32c6d2
Resolve merge conflict
MinhxNguyen7 Oct 1, 2023
192a4b1
Re-add column analytics trigger
MinhxNguyen7 Oct 1, 2023
7229405
Update graphql/grades endpoint to PP prod
MinhxNguyen7 Oct 7, 2023
24d116e
Apply review suggestions
MinhxNguyen7 Oct 8, 2023
537a996
Make activeColumns dervied in ColumnStore
MinhxNguyen7 Oct 8, 2023
b77c0c7
update dependancy of tableMinWidth in SectionTable
MinhxNguyen7 Oct 10, 2023
ef40ee2
Merge branch 'main' into gpa
MinhxNguyen7 Oct 10, 2023
926cda4
Fix graphql field for queryGrades
MinhxNguyen7 Oct 10, 2023
edef526
Merge branch 'main' into gpa
MinhxNguyen7 Oct 10, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import {
Box,
Checkbox,
Expand All @@ -12,8 +12,7 @@ import {
type SxProps,
} from '@mui/material';
import { ArrowBack, Visibility, Refresh } from '@mui/icons-material';
import RightPaneStore, { type SectionTableColumn } from '../RightPaneStore';
import analyticsEnum, { logAnalytics } from '$lib/analytics';
import { useColumnStore, SECTION_TABLE_COLUMNS, type SectionTableColumn } from '$stores/ColumnStore';

/**
* All the interactive buttons have the same styles.
Expand All @@ -34,6 +33,7 @@ const columnLabels: Record<SectionTableColumn, string> = {
sectionCode: 'Code',
sectionDetails: 'Type',
instructors: 'Instructors',
gpa: 'GPA',
dayAndTime: 'Times',
location: 'Places',
sectionEnrollment: 'Enrollment',
Expand All @@ -53,51 +53,38 @@ function renderEmptySelectValue() {
return '';
}

const COLUMN_LABEL_ENTRIES = Object.entries(columnLabels);

/**
* Toggles certain columns on/off.
*
* e.g. show/hide the section code, instructors, etc.
*/
export function ColumnToggleButton() {
const [activeColumns, setActiveColumns] = useState(RightPaneStore.getActiveColumns());
const [selectedColumns, setSelectedColumns] = useColumnStore((store) => [
store.selectedColumns,
store.setSelectedColumns,
]);
const [open, setOpen] = useState(false);

const handleColumnChange = useCallback(
(newActiveColumns: SectionTableColumn[]) => {
logAnalytics({
category: analyticsEnum.classSearch.title,
action: analyticsEnum.classSearch.actions.TOGGLE_COLUMNS,
});

setActiveColumns(newActiveColumns);
},
[setActiveColumns]
);

const handleChange = useCallback(
(e: SelectChangeEvent<SectionTableColumn[]>) => {
if (typeof e.target.value !== 'string') {
RightPaneStore.setActiveColumns(e.target.value);
}
},
[RightPaneStore.setActiveColumns]
);
const handleChange = useCallback((e: SelectChangeEvent<SectionTableColumn[]>) => {
if (typeof e.target.value !== 'string') {
setSelectedColumns(e.target.value);
}
}, []);

const handleOpen = useCallback(() => {
setOpen(true);
}, [setOpen]);

const handleClose = useCallback(() => {
setOpen(false);
}, [setOpen]);
}, []);

useEffect(() => {
RightPaneStore.on('columnChange', handleColumnChange);

return () => {
RightPaneStore.removeListener('columnChange', handleColumnChange);
};
}, [handleColumnChange]);
const selectedColumnNames = useMemo(
() => SECTION_TABLE_COLUMNS.filter((_, index) => selectedColumns[index]),
[selectedColumns]
);

return (
<>
Expand All @@ -109,19 +96,16 @@ export function ColumnToggleButton() {
<FormControl>
<Select
multiple
value={activeColumns}
value={selectedColumnNames}
open={open}
onChange={handleChange}
onClose={handleClose}
renderValue={renderEmptySelectValue}
sx={{ visibility: 'hidden', position: 'absolute' }}
>
{Object.entries(columnLabels).map(([column, label]) => (
{COLUMN_LABEL_ENTRIES.map(([column, label], index) => (
<MenuItem key={column} value={column}>
<Checkbox
checked={activeColumns.indexOf(column as SectionTableColumn) > -1}
color="default"
/>
<Checkbox checked={selectedColumns[index]} color="default" />
<ListItemText primary={label} />
</MenuItem>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LazyLoad from 'react-lazyload';

import { Alert } from '@mui/material';
import { AACourse, AASection } from '@packages/antalmanac-types';
import { WebsocDepartment, WebsocSchool, WebsocAPIResponse } from 'peterportal-api-next-types';
import { WebsocDepartment, WebsocSchool, WebsocAPIResponse, GE } from 'peterportal-api-next-types';
import RightPaneStore from '../RightPaneStore';
import GeDataFetchProvider from '../SectionTable/GEDataFetchProvider';
import SectionTableLazyWrapper from '../SectionTable/SectionTableLazyWrapper';
Expand All @@ -15,9 +15,9 @@ import loadingGif from './SearchForm/Gifs/loading.gif';
import darkNoNothing from './static/dark-no_results.png';
import noNothing from './static/no_results.png';
import AppStore from '$stores/AppStore';
import { isDarkMode, queryWebsocMultiple } from '$lib/helpers';
import { isDarkMode, queryWebsoc, queryWebsocMultiple } from '$lib/helpers';
import Grades from '$lib/grades';
import analyticsEnum from '$lib/analytics';
import { queryWebsoc } from '$lib/course-helpers';

function flattenSOCObject(SOCObject: WebsocAPIResponse): (WebsocSchool | WebsocDepartment | AACourse)[] {
const courseColors = AppStore.getAddedCourses().reduce((accumulator, { section }) => {
Expand Down Expand Up @@ -162,14 +162,38 @@ export function CourseRenderPane() {
division: formData.division,
};

const websocQueryParams = {
department: formData.deptValue,
term: formData.term,
ge: formData.ge,
courseNumber: formData.courseNumber,
sectionCodes: formData.sectionCode,
instructorName: formData.instructor,
units: formData.units,
endTime: formData.endTime,
startTime: formData.startTime,
fullCourses: formData.coursesFull,
building: formData.building,
room: formData.room,
division: formData.division,
};

const gradesQueryParams = {
department: formData.deptValue,
ge: formData.ge as GE,
};

try {
// If params has a comma, it means that we are searching for multiple units.
const socObject = params.units.includes(',')
? await queryWebsocMultiple(params, 'units')
: await queryWebsoc(params);
// Query websoc for course information and populate gradescache
const [websocJsonResp, _] = await Promise.all([
websocQueryParams.units.includes(',')
? queryWebsocMultiple(websocQueryParams, 'units')
: queryWebsoc(websocQueryParams),
Grades.populateGradesCache(gradesQueryParams),
]);

setError(false);
setCourseData(flattenSOCObject(socObject));
setCourseData(flattenSOCObject(websocJsonResp));
} catch (error) {
setError(true);
} finally {
Expand Down
36 changes: 1 addition & 35 deletions apps/antalmanac/src/components/RightPane/RightPaneStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@ import { EventEmitter } from 'events';

import { getDefaultTerm } from '$lib/termData';

/**
* Search results are displayed in a tabular format.
*
* Users can toggle certain columns on/off.
*/
export const SECTION_TABLE_COLUMNS = [
// These two are omitted since they're not iterated over in the template.
// 'scheduleAdd',
// 'colorAndDelete',
'sectionCode',
'sectionDetails',
'instructors',
'dayAndTime',
'location',
'sectionEnrollment',
'restrictions',
'status',
] as const;

export type SectionTableColumn = (typeof SECTION_TABLE_COLUMNS)[number];

const defaultFormValues: Record<string, string> = {
deptValue: 'ALL',
deptLabel: 'ALL: Include All Departments',
Expand All @@ -47,7 +26,6 @@ export interface BuildingFocusInfo {

class RightPaneStore extends EventEmitter {
private formData: Record<string, string>;
private activeTab: number;
private doDisplaySearch: boolean;
private openSpotAlertPopoverActive: boolean;
private urlCourseCodeValue: string;
Expand All @@ -57,16 +35,10 @@ class RightPaneStore extends EventEmitter {
private urlDeptLabel: string;
private urlDeptValue: string;

/**
* The columns that are currently being displayed in the search results.
*/
private activeColumns: SectionTableColumn[] = [...SECTION_TABLE_COLUMNS];

constructor() {
super();
this.setMaxListeners(15);
this.formData = structuredClone(defaultFormValues);
this.activeTab = 0;
this.doDisplaySearch = true;
this.openSpotAlertPopoverActive = false;
const search = new URLSearchParams(window.location.search);
Expand Down Expand Up @@ -96,7 +68,6 @@ class RightPaneStore extends EventEmitter {
getUrlCourseNumValue = () => this.urlCourseNumValue;
getUrlDeptLabel = () => this.urlDeptLabel;
getUrlDeptValue = () => this.urlDeptValue;
getActiveColumns = () => this.activeColumns;

updateFormValue = (field: string, value: string) => {
this.formData[field] = value;
Expand All @@ -115,12 +86,7 @@ class RightPaneStore extends EventEmitter {
toggleOpenSpotAlert = () => {
this.openSpotAlertPopoverActive = !this.openSpotAlertPopoverActive;
};

setActiveColumns = (newActiveColumns: SectionTableColumn[]) => {
this.activeColumns = newActiveColumns;
this.emit('columnChange', newActiveColumns);
};
}

const store = new RightPaneStore();
export default store;
export default store;
Loading
Loading