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 pre-/post-requisite tree under each class #188

Merged
merged 70 commits into from
Dec 15, 2024

Conversation

aattiyah
Copy link
Contributor

@aattiyah aattiyah commented Dec 12, 2024

Description

This pull request adds the requisite tree feature, which shows a tree of pre-requisites and post-requisites of courses in the course detail page. The feature enhances the user experience by providing a clear and organized visual representation of course dependencies.

tree

Closes #53

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

This feature was tested mainly through manual testing since most parts of the implementation were about the visualization and rendering of the tree. Error handling techniques were used to ensure error-free code, as well as manual validation. Backend testing also took place, as we tested the outputs of new functions we implemented.

Test Configuration:

  • Node.js version: 22.7.0
  • Desktop/Mobile: Desktop
  • OS: Mac Sonoma
  • Browser: Chrome

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@aattiyah aattiyah added the enhancement New feature or request label Dec 12, 2024
@Xavilien Xavilien self-requested a review December 12, 2024 20:08
Copy link
Member

@Xavilien Xavilien left a comment

Choose a reason for hiding this comment

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

See comments in the various files. Additionally, some potential ideas/comments for improvements (which you don't necessarily need to do within this PR but would be great if you could implement):

  • Tooltips to show more information about the course upon hover like course name, description, etc. There's actually a tooltip component somewhere in the codebase which could make this a quick addition
  • Being able to traverse more than one level forwards or backwards in the tree. Based on how you guys have implemented the tree, might need a bit of rewrite, but would be interesting to explore the tree a bit more. So like I might be able to currently see that course A is needed for course B, but if I can also expand the prereqs to course B to see that course C is also needed in addition to course A, that could be helpful
  • Showing the relationship between courses a bit clearer. For example, in the picture below, 15-300 only needs (76-101 and 15-210 and 15-213) or (76-101 and 15-213 and 15-251) or (76-101 and 15-210 and 15-251), not all of them at the same time.
image

Design nitpicks

  • Would be nice to have the current course centered in the middle at all times so that expanding to the left/right doesn't shift the whole thing. (Can make it scrollable if we want to expand the tree further)
  • Being able to expand more than one course at the same time
  • I feel like the "no further postrequisites" is a bit of a mouthful haha, changing it to something else could be fun

@@ -21,6 +21,7 @@ app.route("/course/:courseID").get(getCourseByID);
app.route("/courses").get(getCourses);
app.route("/courses").post(isUser, getCourses);
app.route("/courses/all").get(getAllCourses);
app.route("/courses/relations").get(getCourseRelations);
Copy link
Member

Choose a reason for hiding this comment

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

Is this endpoint being used? I don’t see it being used so if it’s not it would be best to remove the dead code

@@ -0,0 +1,136 @@
import React from "react";
import Link from "next/link"; // Import Next.js Link component
Copy link
Member

Choose a reason for hiding this comment

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

Remove this dead code if it's not being used

apps/frontend/src/components/PostReqCourses.tsx Outdated Show resolved Hide resolved
import React from "react";
import { useFetchCourseInfo } from "~/app/api/course";

interface TreeNode {
Copy link
Member

Choose a reason for hiding this comment

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

I notice use define TreeNode in a few files, would be good to put one standard definition in apps/types

Copy link

vercel bot commented Dec 12, 2024

@aattiyah is attempting to deploy a commit to the ScottyLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cmucourses-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 9:33pm


{/* Normal vertical Line connector */}
{nodes && nodes.length > 1 && nodes.indexOf(node) !== 0 && nodes.indexOf(node) !== nodes.length - 1 && (
<div className="w-[1px] bg-[#d1d5db] self-stretch"></div>
Copy link
Member

Choose a reason for hiding this comment

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

Generally it would be nicer to use w-1/w-0.5 instead of hard coding pixels

@Xavilien
Copy link
Member

Additionally, the mobile view isn't doing great right now:

image

Adding overflow behavior could be helpful along with resizing the length of the lines between the nodes as well: https://tailwindcss.com/docs/overflow

@mohamed-elzeni mohamed-elzeni marked this pull request as draft December 13, 2024 16:09
@mohamed-elzeni
Copy link
Member

We have refactored the code to address most of the comments above including refactoring types, removing dead and redundant code, and removing fixed values for colors or sizes.

We have also heavily revised the look of the tree, making it more responsive to various screen sizes and the colors responsive to light and dark modes.

We have attempted the following, but I believe we won't be able to complete them in this PR since we are short on time:

  • Although we were able to add tooltips quickly, we realized that to show any additional course info we would have to make calls to the backend to fetch info for all pre/postreqs, which the tree card doesnt have right now, and would require a lot of changes.
  • For traversing more levels of pre/postreqs, we would have to change the structure heavily too and refactor too much code.
  • Showing relationships would require also changing the core logic of how the tree is rendered right now, and parsing the prereqs string is a bit trickier than what we thought.

All of these changes are possible, and we are happy to work on them. But we would like to do them in another PR (with priority given to course relationships).

Would be great if you could take a look at the current changes.

@mohamed-elzeni mohamed-elzeni marked this pull request as ready for review December 14, 2024 13:34
Copy link
Member

@Xavilien Xavilien left a comment

Choose a reason for hiding this comment

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

LGTM

@Xavilien Xavilien merged commit cbfef27 into ScottyLabs:main Dec 15, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Prerequisite (and Postrequisite) Tree
6 participants