-
Notifications
You must be signed in to change notification settings - Fork 2
feat: display optional completion information on the cards #48
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ export const QUERY_KEYS = { | |
| LEARNER_DASHBOARD: ['learnerDashboard'], | ||
| COURSE_DETAILS: (courseId) => ['course', courseId], | ||
| COURSE_COMPLETIONS: ['courseCompletions'], | ||
| COURSE_COMPLETION: (courseId) => ['courseCompletion', courseId], | ||
| COURSE_ENROLLMENT_STATUS: (courseId) => ['courseEnrollmentStatus', courseId], | ||
| ORGANIZATIONS: ['organizations'], | ||
| CREDENTIAL_CONFIGURATION: (learningContextKey) => ['credentialConfiguration', learningContextKey], | ||
|
|
@@ -70,9 +69,19 @@ export const useLearningPaths = () => { | |
| }; | ||
| } | ||
|
|
||
| let hasOptionalCompletion = false; | ||
| let hasUnearnedOptionalCompletion = false; | ||
| const totalCompletion = lp.steps.reduce((sum, step) => { | ||
| const completion = completionsMap[step.courseKey]; | ||
| return sum + (completion?.percent ?? 0); | ||
| const completionData = completionsMap[step.courseKey]; | ||
| const optionalPossible = completionData?.optionalCompletion?.possible ?? 0; | ||
| const optionalEarned = completionData?.optionalCompletion?.earned ?? 0; | ||
| if (optionalPossible > 0) { | ||
| hasOptionalCompletion = true; | ||
| if (optionalPossible > optionalEarned) { | ||
| hasUnearnedOptionalCompletion = true; | ||
| } | ||
| } | ||
| return sum + (completionData?.completion?.percent ?? 0); | ||
|
Comment on lines
+72
to
+84
|
||
| }, 0); | ||
|
|
||
| const percent = totalCompletion / totalCourses; | ||
|
|
@@ -104,6 +113,8 @@ export const useLearningPaths = () => { | |
| minDate, | ||
| maxDate, | ||
| percent, | ||
| hasOptionalCompletion, | ||
| hasUnearnedOptionalCompletion, | ||
| type: 'learning_path', | ||
| org: lp.key.match(/path-v1:([^+]+)/)[1], | ||
| enrollmentDate: lp.enrollmentDate ? new Date(lp.enrollmentDate) : null, | ||
|
|
@@ -215,12 +226,6 @@ export const useLearnerDashboard = () => { | |
| }); | ||
| }; | ||
|
|
||
| export const useCourseCompletions = () => useQuery({ | ||
| queryKey: QUERY_KEYS.COURSE_COMPLETIONS, | ||
| queryFn: api.fetchAllCourseCompletions, | ||
| staleTime: STALE_TIMES.COMPLETIONS, | ||
| }); | ||
|
|
||
| export const useCoursesByIds = (courseIds) => { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
|
|
@@ -314,12 +319,6 @@ export const usePrefetchCourseDetail = (courseId) => { | |
| staleTime: STALE_TIMES.COURSE_DETAIL, | ||
| }); | ||
|
|
||
| queryClient.fetchQuery({ | ||
| queryKey: QUERY_KEYS.COURSE_COMPLETION(courseId), | ||
| queryFn: () => api.fetchCourseCompletion(courseId), | ||
| staleTime: STALE_TIMES.COMPLETIONS, | ||
| }); | ||
|
|
||
| queryClient.prefetchQuery({ | ||
| queryKey: QUERY_KEYS.CREDENTIAL_CONFIGURATION(courseId), | ||
| queryFn: () => api.fetchCredentialConfiguration(courseId), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.