Skip to content

Commit

Permalink
assignments for instructors were added because they were missing befo…
Browse files Browse the repository at this point in the history
…re. Now they will display in the home page. I fetched the assignments in the same matter that enrolled courses were being fetched in the homepage
  • Loading branch information
ashwaqaljanahi2021 committed Oct 12, 2024
1 parent d7d1db7 commit 0dd5c4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions devU-client/src/components/listItems/userCourseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const UserCourseListItem = ({course, assignments, past = false, instructor = fal
return(
<ListItemWrapper to={null} tag={course.number} containerStyle={styles.container}>

<div className={styles.name}>{instructor ? (course.name + " (Instructor)") : course.name.toUpperCase() + " " + course.number + " " + "(" + course.semester + ")" }</div>
<div className={styles.name}>{instructor ? (course.name + " " + course.number + " (" + course.semester + ")" + " Instructor") : course.name.toUpperCase() + " " + course.number + " " + "(" + course.semester + ")" }</div>
<div className={styles.subText}>
{assignments && assignments.length > 0 ? (assignments.map((assignment) => (
<SimpleAssignmentListItem assignment={assignment} key={assignment.id}/>
))) : ((past || instructor) ? <div></div> : <div className={styles.No_assignments}>No Assignments Due Yet</div>)}
))) : ((past) ? <div></div> : <div className={styles.No_assignments}>No Assignments Due Yet</div>)}
<div className={styles.Buttons}>
<button className={styles.gradebook_button} onClick={(e) => {
e.stopPropagation();
Expand Down
13 changes: 10 additions & 3 deletions devU-client/src/components/pages/homePage/homePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const HomePage = () => {
instructorCourses: Course[];
activeCourses: Course[];
pastCourses: Course[];
upcomingCourses: Course[];//TODO: Add upcoming courses feature
upcomingCourses: Course[];
}>(`/api/courses/user/${userId}`);
const enrolledCourses: Course[] = allCourses.activeCourses;
const upcomingCourses: Course[] = allCourses.upcomingCourses;
Expand All @@ -46,6 +46,13 @@ const HomePage = () => {
})
const assignmentResults = await Promise.all(assignmentPromises)
assignmentResults.forEach(([course, assignments]) => assignmentMap.set(course, assignments))

const assignmentPromises_instructor = instructorCourses.map((course) => {
const assignments = RequestService.get<Assignment[]>(`/api/course/${course.id}/assignments/released`)
return Promise.all([course, assignments])
})
const assignmentResults_instructor = await Promise.all(assignmentPromises_instructor)
assignmentResults_instructor.forEach(([course, assignments]) => assignmentMap.set(course, assignments))

setAssignments(assignmentMap)
setPastCourses(pastCourses)
Expand Down Expand Up @@ -81,10 +88,10 @@ const HomePage = () => {
<div className={styles.largeLine}></div>
</div>
<div className={styles.coursesContainer}>
{instructorCourses && instructorCourses.map((course) => (
{instructorCourses.map((course) => (
<div className={styles.courseCard} key={course.id}>
<UserCourseListItem course={course} assignments={assignments.get(course)} key={course.id}
instructor={true}/>
instructor = {true}/>
</div>
))}
</div>
Expand Down

0 comments on commit 0dd5c4f

Please sign in to comment.