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

Add Grade History Table to Course Details Page #48

Merged
merged 1 commit into from
May 29, 2024
Merged
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
22 changes: 22 additions & 0 deletions frontend/src/main/pages/CourseDetails/CourseDetailsIndexPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useBackend, _useBackendMutation } from "main/utils/useBackend";
import CourseDetailsTable from "main/components/CourseDetails/CourseDetailsTable";
import { yyyyqToQyy } from "main/utils/quarterUtilities";
import CourseDescriptionTable from "main/components/Courses/CourseDescriptionTable";
import GradeHistoryTable from "main/components/GradeHistory/GradeHistoryTable";

export default function CourseDetailsIndexPage() {
// Stryker disable next-line all : Can't test state because hook is internal
Expand All @@ -26,6 +27,25 @@ export default function CourseDetailsIndexPage() {
},
);

let courseId = moreDetails?.courseId || "";
let subject = "";
let course = "";
if (courseId) {
[subject, course] = courseId.split(/\s+/);
}
const { data: gradeData } = useBackend(
// Stryker disable all : hard to test for query caching
[`/api/gradehistory/search?subjectArea=${subject}&courseNumber=${course}`],
{
method: "GET",
url: `/api/gradehistory/search`,
params: {
subjectArea: subject,
courseNumber: course,
},
},
);

return (
<BasicLayout>
<div className="pt-2">
Expand All @@ -37,6 +57,8 @@ export default function CourseDetailsIndexPage() {

{moreDetails && <CourseDetailsTable details={[moreDetails]} />}
{moreDetails && <CourseDescriptionTable course={moreDetails} />}
{moreDetails && <h5>Grade History for {moreDetails.courseId}</h5>}
{gradeData && <GradeHistoryTable grades={gradeData} />}
</div>
</BasicLayout>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CourseDetailsIndexPage from "main/pages/CourseDetails/CourseDetailsIndexP
import { apiCurrentUserFixtures } from "fixtures/currentUserFixtures";
import { systemInfoFixtures } from "fixtures/systemInfoFixtures";
import { personalSectionsFixtures } from "fixtures/personalSectionsFixtures";
import { gradeHistoryFixtures } from "fixtures/gradeHistoryFixtures";

const mockToast = jest.fn();
jest.mock("react-toastify", () => {
Expand Down Expand Up @@ -56,6 +57,11 @@ describe("Course Details Index Page tests", () => {
params: { qtr: "20221", enrollCode: "06619" },
})
.reply(200, personalSectionsFixtures.singleSection);
axiosMock
.onGet("/api/gradehistory/search", {
params: { subjectArea: "CHEM", courseNumber: "184" },
})
.reply(200, gradeHistoryFixtures.threeGrades);
});

const queryClient = new QueryClient();
Expand Down
Loading