Skip to content

Commit

Permalink
Added backend for the total number of students on canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
colton456p committed Dec 4, 2024
1 parent 528e719 commit 9dd60ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { useCourse } from "@/app/(app)/course/[courseId]/(hooks)/useCourse"
import { useQuery } from "@tanstack/react-query"

const useTotalStudentsQuery = ({ courseId }: { courseId: number }) => {
const studentQuery = useQuery<unknown, unknown, { count: number }>({
queryKey: [`courses/${courseId}/students`],
const studentQuery = useQuery<
unknown,
unknown,
{ total_students: number; opted_in_students: number }
>({
queryKey: [`courses/${courseId}/student-counts`],
})

return {
Expand All @@ -21,7 +25,8 @@ export const useTotalStudents = () => {
})

return {
totalStudents: data?.count ?? 0,
totalStudents: data?.total_students ?? 0,
optedInStudents: data?.opted_in_students ?? 0,
isLoading,
error,
refetch: getTotalStudentsAsync,
Expand Down
6 changes: 3 additions & 3 deletions src/app/(app)/course/[courseId]/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { useTotalStudents } from "./(hooks)/useTotalStudents"
const HomePage = () => {
const { courseId } = useCourse()
const { completionPercentage, nextStepTitle } = CalculateOnboardingCompletion()
const { totalStudents, error: totalStudentsError } = useTotalStudents()
const { totalStudents, optedInStudents, error: totalStudentsError } = useTotalStudents()
const { data: pastAttributes, error: pastAttributesError } = usePastAttributes()

useHandleErrors({ totalStudentsError, pastAttributesError })

const signUpStats = [
{ label: "Students Enrolled on Your LMS", value: 30 },
{ label: "Total Team Formation Acceptions", value: totalStudents },
{ label: "Students Enrolled on Your LMS", value: totalStudents },
{ label: "Total Team Formation Acceptions", value: optedInStudents },
]

const previousTeamFormation = [
Expand Down

0 comments on commit 9dd60ed

Please sign in to comment.