Skip to content

Commit 83f8a8d

Browse files
authored
Merge pull request #435 from topcoder-platform/TCA-796_fcc-last-lesson-callback
TCA-796 fcc last lesson callback -> dev
2 parents c5e2a7c + 5436a5a commit 83f8a8d

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

src-ts/tools/learn/course-details/CourseDetailsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const CourseDetailsPage: FC<{}> = () => {
4848
const {
4949
certificationProgress: progress,
5050
ready: progressReady,
51+
setCertificateProgress,
5152
}: UserCertificationProgressProviderData = useGetUserCertificationProgress(
5253
profile?.userId,
5354
routeParams.provider,
@@ -214,6 +215,7 @@ const CourseDetailsPage: FC<{}> = () => {
214215
progress={progress}
215216
progressReady={progressReady}
216217
profile={profile}
218+
setCertificateProgress={setCertificateProgress}
217219
/>
218220
</div>
219221
</div>

src-ts/tools/learn/course-details/course-curriculum/CourseCurriculum.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface CourseCurriculumProps {
3131
profile?: UserProfile
3232
progress?: LearnUserCertificationProgress
3333
progressReady?: boolean
34+
setCertificateProgress: (d: LearnUserCertificationProgress) => void
3435
}
3536

3637
const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProps) => {
@@ -108,7 +109,7 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
108109
}
109110

110111
if (!props.progress?.id) {
111-
await userCertificationProgressStartAsync(
112+
const progress: LearnUserCertificationProgress = await userCertificationProgressStartAsync(
112113
props.profile.userId,
113114
props.course.certificationId,
114115
props.course.id,
@@ -117,6 +118,9 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
117118
module: props.course.modules[0].meta.dashedName,
118119
},
119120
)
121+
122+
// update progress with data returned from calling the start progress endpoint
123+
props.setCertificateProgress(progress)
120124
} else {
121125
await userCertificationProgressUpdateAsync(
122126
props.progress.id,

src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { FccFrame } from './fcc-frame'
4545
import { FccSidebar } from './fcc-sidebar'
4646
import { TitleNav } from './title-nav'
4747
import styles from './FreeCodeCamp.module.scss'
48+
import { debounce } from 'lodash'
4849

4950
const FreeCodeCamp: FC<{}> = () => {
5051

@@ -211,7 +212,7 @@ const FreeCodeCamp: FC<{}> = () => {
211212
profile?.userId,
212213
])
213214

214-
const handleFccLessonComplete: (challengeUuid: string) => void = useCallback((challengeUuid: string) => {
215+
const handleFccLessonComplete: (challengeUuid: string) => void = useCallback(debounce((challengeUuid: string) => {
215216

216217
const currentLesson: { [key: string]: string } = {
217218
lesson: lessonParam,
@@ -239,7 +240,7 @@ const FreeCodeCamp: FC<{}> = () => {
239240

240241
})
241242
// eslint-disable-next-line react-hooks/exhaustive-deps
242-
}, [
243+
}, 30), [
243244
certificateProgress,
244245
lessonParam,
245246
moduleParam,
@@ -297,14 +298,14 @@ const FreeCodeCamp: FC<{}> = () => {
297298
* Handle the navigation away from the last step of the course in the FCC frame
298299
* @returns
299300
*/
300-
const handleFccLastLessonNavigation: () => void = useCallback(() => {
301+
const handleFccLastLessonNavigation: () => void = useCallback(debounce(() => {
301302

302303
if (!certificateProgress) {
303304
return
304305
}
305306

306307
// course is completed, return user to course completed screen
307-
if (certificateProgress.courseProgressPercentage === 100) {
308+
if (certificateProgress.status === UserCertificationProgressStatus.completed) {
308309
const completedPath: string = getCertificationCompletedPath(
309310
providerParam,
310311
certificationParam,
@@ -343,7 +344,7 @@ const FreeCodeCamp: FC<{}> = () => {
343344

344345
navigate(nextLessonPath)
345346
// eslint-disable-next-line react-hooks/exhaustive-deps
346-
}, [
347+
}, 30), [
347348
certificateProgress,
348349
certificationParam,
349350
courseData?.modules,

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certification-progress.provider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ export function useGetUserCertificationProgress(
2727
isPaused: () => !userId || !certification,
2828
})
2929

30+
const certificationProgress: LearnUserCertificationProgress | undefined = find(data, { certification })
31+
3032
return {
31-
certificationProgress: find(data, { certification }),
33+
certificationProgress,
3234
loading: !!userId && !data && !error,
33-
ready: !userId || data || error,
35+
ready: !userId || !!data || !!error,
3436
refetch: () => mutate(),
3537
setCertificateProgress: progress => mutate([progress]),
3638
}

0 commit comments

Comments
 (0)