-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-/post-requisite tree under each class (#188)
* create component ReqTreeCard.tsx * create card for pre.post.corequisite tree * add comments * import ReqTreeCard into CourseDetail.tsx * add card to course details * change heading title of ReqTreeCard * add guiding comments * Add postrequisites fetching * Add postreqs to tree card * Update ReqTreeCard to render the prerequisite list * Create ReqTreeDetail to render the tree diagram * Update ReqTreeCard to build tree diagram and CourseDetail to fetch data * Update ReqTreeDetail for UI enhancements and link courses to pages * Updated ReqTreeCard to display message if tree unavailable * slight bug fixes and the addetion to an expanding pre req tree * adjusting the arrow feature aand adding a collapse * adjusting the arrow feature and fixing the bugs in it * fixing the bugs in it * add PostReqCourses for tree * modify ReqTreeDetail for more postreq courses * link ReqTreeCard for more postreq courses * properly adding the view more feature * fixing it slightly * organize visualization of buttons * organize the post-reqs of post-reqs * remove redudant code * resolving conflicts * resolving conflicts * resolving conflicts * resolving conflicts * resolving conflicts * resolving conflicts * resolving conflicts * resolving conflicts * resolving conflicts * resolving minor bugs * resolving minor bugs * add lines to the postreq nodes * adding the link to the traversal of prereq * adjusting imports and functionality * adding corereq to the req card * fixing bugs * centered course req * fixing rendering issue * shifting the view more to the left side * added parser function in utils.ts for prereqString * added a function that get the postreqs and prereqs elements of the tree * added a new route for course/relations endpoint * fix coreqs placement * fix pre-req placements * Enhance tree branches * Minor requisite tree branches fix * update style consistency using trailwind * Update requisites fetching * Requisite tree UI enhancements * Standardize tree interface * change labels * Enhance requisites tree UI * Fix tree branches * Add expanding multiple courses simultaneously * Refactor requsisites tree code * Minor refactoring --------- Co-authored-by: Mohamed Elzeni <[email protected]> Co-authored-by: “akobaidan” <[email protected]> Co-authored-by: akobaidan <[email protected]> Co-authored-by: Latifa Al-Hitmi <[email protected]> Co-authored-by: lhitmi <[email protected]> Co-authored-by: Fatou GUEYE <[email protected]> Co-authored-by: Mohamed Elzeni <[email protected]>
- Loading branch information
1 parent
e4e0c4e
commit cbfef27
Showing
11 changed files
with
528 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from "react"; | ||
import { useFetchCourseRequisites } from "~/app/api/course"; | ||
import { TreeNode } from "~/app/types"; | ||
import { CourseIDButton } from "./Buttons"; | ||
|
||
interface Props { | ||
courseID: string; | ||
} | ||
|
||
export const PostReqCourses = ({ courseID }: Props) => { | ||
const { isPending: isCourseInfoPending, data: requisites } = useFetchCourseRequisites(courseID); | ||
|
||
if (isCourseInfoPending || !requisites) { | ||
return null; | ||
} | ||
|
||
// Recursive function to render only the child branches | ||
const renderTree = (nodes: TreeNode[]) => { | ||
return ( | ||
<div className="flex flex-col"> | ||
{nodes.map((node) => ( | ||
<div key={node.courseID} className="flex items-center"> | ||
{/* Half vertical line for the first postreq */} | ||
{nodes && nodes.length > 1 && nodes.indexOf(node) === 0 && ( | ||
<div className="flex flex-col w-0.5 self-stretch"> | ||
<div className="h-1/2 self-stretch"></div> | ||
<div className="w-0.5 h-1/2 bg-gray-400 self-stretch"></div> | ||
</div> | ||
)} | ||
|
||
{/* Normal vertical Line connector */} | ||
{nodes && nodes.length > 1 && nodes.indexOf(node) !== 0 && nodes.indexOf(node) !== nodes.length - 1 && ( | ||
<div className="w-0.5 bg-gray-400 self-stretch"></div> | ||
)} | ||
|
||
{/* Half vertical line for the last prereq in the list */} | ||
{nodes && nodes.length > 1 && nodes.indexOf(node) === nodes.length - 1 && ( | ||
<div className="flex flex-col w-0.5 self-stretch"> | ||
<div className="w-0.5 h-1/2 bg-gray-400 self-stretch"></div> | ||
<div className="h-1/2 self-stretch"></div> | ||
</div> | ||
)} | ||
|
||
{/* Line left to node */} | ||
{nodes && nodes.length > 1 && ( | ||
<div className="w-3 h-0.5 bg-gray-400"></div> | ||
)} | ||
|
||
{/* Course ID button */} | ||
<CourseIDButton courseID={node.courseID} /> | ||
|
||
{/* Render child nodes recursively */} | ||
{node.postreqs && renderTree(node.postreqs)} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
// Transform fetched data into a tree structure excluding the parent node | ||
const childNodes: TreeNode[] = requisites.postreqs?.map((postreq: string) => ({ | ||
courseID: postreq, | ||
})) || []; | ||
|
||
return ( | ||
<div> | ||
{childNodes.length > 0 ? ( | ||
renderTree(childNodes) | ||
) : ( | ||
<div | ||
className="italic ml-2 text-gray-700 text-center text-lg font-semibold rounded-md" | ||
> | ||
None | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default PostReqCourses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from "react"; | ||
import { useFetchCourseRequisites } from "~/app/api/course"; | ||
import { TreeNode } from "~/app/types"; | ||
import { CourseIDButton } from "./Buttons"; | ||
|
||
interface Props { | ||
courseID: string; | ||
} | ||
|
||
export const PreReqCourses = ({ courseID }: Props) => { | ||
const { isPending: isCourseInfoPending, data: requisites } = useFetchCourseRequisites(courseID); | ||
|
||
if (isCourseInfoPending || !requisites) { | ||
return null; | ||
} | ||
|
||
// Recursive function to render only the child branches | ||
const renderTree = (nodes: TreeNode[]) => { | ||
return ( | ||
<div className="flex flex-col"> | ||
{nodes.map((node) => ( | ||
<div key={node.courseID} className="flex items-center"> | ||
{/* Course ID button */} | ||
<CourseIDButton courseID={node.courseID} /> | ||
|
||
{/* Line connector right to node */} | ||
{nodes && nodes.length > 1 && ( | ||
<div className="w-3 h-0.5 bg-gray-400"></div> | ||
)} | ||
|
||
{/* Half vertical line for the first prereq in the list */} | ||
{nodes && nodes.length > 1 && nodes.indexOf(node) === 0 && ( | ||
<div className="flex flex-col w-0.5 self-stretch"> | ||
<div className="h-1/2 self-stretch"></div> | ||
<div className="w-0.5 h-1/2 bg-gray-400 self-stretch"></div> | ||
</div> | ||
)} | ||
|
||
{/* Normal vertical Line connector */} | ||
{nodes && nodes.length > 1 && nodes.indexOf(node) !== 0 && nodes.indexOf(node) !== nodes.length - 1 && ( | ||
<div className="w-0.5 bg-gray-400 self-stretch"></div> | ||
)} | ||
|
||
{/* Half vertical line for the last prereq in the list */} | ||
{nodes && nodes.length > 1 && nodes.indexOf(node) === nodes.length - 1 && ( | ||
<div className="flex flex-col w-0.5 self-stretch"> | ||
<div className="w-0.5 h-1/2 bg-gray-400 self-stretch"></div> | ||
<div className="h-1/2 self-stretch"></div> | ||
</div> | ||
)} | ||
|
||
{/* Render child nodes recursively */} | ||
{node.prereqs && renderTree(node.prereqs)} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
// Transform fetched data into a tree structure excluding the parent node | ||
const childNodes: TreeNode[] = requisites.prereqs.map((prereq: string) => ({ | ||
courseID: prereq, | ||
})) || []; | ||
|
||
return ( | ||
<div> | ||
{childNodes.length > 0 ? ( | ||
renderTree(childNodes) | ||
) : ( | ||
<div | ||
className="italic mr-2 text-gray-700 text-center text-lg font-semibold rounded-md" | ||
> | ||
None | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default PreReqCourses; |
Oops, something went wrong.