Skip to content

Commit 4cb96f3

Browse files
Merge pull request #210 from topcoder-platform/PROD-2549_resume
PROD-2549 Add Course State to Course Cards -> dev
2 parents dc5b059 + 5424707 commit 4cb96f3

File tree

55 files changed

+700
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+700
-514
lines changed

src-ts/tools/learn/Learn.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { FC, useContext } from 'react'
22
import { Outlet, Routes } from 'react-router-dom'
33

44
import {
5-
ContentLayout,
65
routeContext,
76
RouteContextData,
87
} from '../../lib'

src-ts/tools/learn/course-completed/CourseCompletedPage.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import {
1111
ProfileContextData
1212
} from '../../../lib'
1313
import {
14-
CertificationsProviderData,
14+
AllCertificationsProviderData,
1515
CollapsiblePane,
1616
CourseOutline,
1717
CoursesProviderData,
1818
CourseTitle,
19-
MyCertificationProgressProviderData,
20-
MyCertificationProgressStatus,
21-
useCertificationsProvider,
22-
useCoursesProvider,
23-
useMyCertificationProgress
19+
useAllCertifications,
20+
useCourses,
21+
UserCertificationProgressProviderData,
22+
UserCertificationProgressStatus,
23+
useUserCertificationProgress
2424
} from '../learn-lib'
2525
import { getCertificatePath, getCoursePath } from '../learn.routes'
2626

@@ -39,12 +39,12 @@ const CourseCompletedPage: FC<{}> = () => {
3939
const {
4040
course: courseData,
4141
ready: courseDataReady,
42-
}: CoursesProviderData = useCoursesProvider(providerParam, certificationParam)
42+
}: CoursesProviderData = useCourses(providerParam, certificationParam)
4343

4444
const {
45-
certificateProgress: progress,
45+
certificationProgress: progress,
4646
ready: progressReady,
47-
}: MyCertificationProgressProviderData = useMyCertificationProgress(
47+
}: UserCertificationProgressProviderData = useUserCertificationProgress(
4848
profile?.userId,
4949
routeParams.provider,
5050
routeParams.certification
@@ -53,7 +53,7 @@ const CourseCompletedPage: FC<{}> = () => {
5353
const {
5454
certification,
5555
ready: certifReady,
56-
}: CertificationsProviderData = useCertificationsProvider(providerParam, progress?.certificationId, {
56+
}: AllCertificationsProviderData = useAllCertifications(providerParam, progress?.certificationId, {
5757
enabled: progressReady && !!progress,
5858
})
5959

@@ -66,9 +66,9 @@ const CourseCompletedPage: FC<{}> = () => {
6666
], [coursePath, courseData])
6767

6868
useEffect(() => {
69-
if (ready && progress?.status !== MyCertificationProgressStatus.completed) {
70-
navigate(coursePath)
71-
}
69+
if (ready && progress?.status !== UserCertificationProgressStatus.completed) {
70+
navigate(coursePath)
71+
}
7272
}, [
7373
coursePath,
7474
navigate,

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import {
1313
import {
1414
CoursesProviderData,
1515
CourseTitle,
16-
MyCertificationProgressProviderData,
17-
MyCertificationProgressStatus,
1816
ResourceProviderData,
19-
useCoursesProvider,
20-
useMyCertificationProgress,
21-
useResourceProvider
17+
useCourses,
18+
UserCertificationProgressProviderData,
19+
UserCertificationProgressStatus,
20+
useResourceProvider,
21+
useUserCertificationProgress
2222
} from '../learn-lib'
2323

2424
import { CourseCurriculum } from './course-curriculum'
@@ -37,12 +37,12 @@ const CourseDetailsPage: FC<{}> = () => {
3737
const {
3838
course,
3939
ready: courseReady,
40-
}: CoursesProviderData = useCoursesProvider(routeParams.provider ?? '', routeParams.certification)
40+
}: CoursesProviderData = useCourses(routeParams.provider ?? '', routeParams.certification)
4141

4242
const {
43-
certificateProgress: progress,
43+
certificationProgress: progress,
4444
ready: progressReady,
45-
}: MyCertificationProgressProviderData = useMyCertificationProgress(
45+
}: UserCertificationProgressProviderData = useUserCertificationProgress(
4646
profile?.userId,
4747
routeParams.provider,
4848
routeParams.certification,
@@ -59,7 +59,7 @@ const CourseDetailsPage: FC<{}> = () => {
5959
return
6060
}
6161

62-
return progress?.status === MyCertificationProgressStatus.completed ? (
62+
return progress?.status === UserCertificationProgressStatus.completed ? (
6363
<>
6464
<h3 className='details'>Suggested next steps</h3>
6565

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

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ import {
99
LearningHat,
1010
LearnLesson,
1111
LearnModule,
12-
LearnMyCertificationProgress,
13-
MyCertificationProgressStatus,
14-
startMyCertificationsProgressAsync,
15-
UpdateMyCertificateProgressActions,
16-
updateMyCertificationsProgressAsync
12+
LearnUserCertificationProgress,
13+
userCertificationProgressStartAsync,
14+
UserCertificationProgressStatus,
15+
userCertificationProgressUpdateAsync,
16+
UserCertificationUpdateProgressActions
1717
} from '../../learn-lib'
18-
import { authenticateAndStartCourseRoute, getCertificatePath, getFccLessonPath, LEARN_PATHS } from '../../learn.routes'
18+
import {
19+
authenticateAndStartCourseRoute,
20+
getCertificatePath,
21+
getLessonPathFromCurrentLesson,
22+
LEARN_PATHS,
23+
} from '../../learn.routes'
1924

2025
import styles from './CourseCurriculum.module.scss'
2126
import { CurriculumSummary } from './curriculum-summary'
@@ -24,41 +29,48 @@ import { TcAcademyPolicyModal } from './tc-academy-policy-modal'
2429
interface CourseCurriculumProps {
2530
course: LearnCourse
2631
profile?: UserProfile
27-
progress?: LearnMyCertificationProgress
32+
progress?: LearnUserCertificationProgress
2833
progressReady?: boolean
2934
}
3035

3136
const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProps) => {
37+
3238
const navigate: NavigateFunction = useNavigate()
3339
const [searchParams]: any = useSearchParams()
3440

3541
const isLoggedIn: boolean = !!props.profile
3642

3743
const [isTcAcademyPolicyModal, setIsTcAcademyPolicyModal]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
3844

39-
const status: string = props.progress?.status ?? 'init'
45+
const status: string = props.progress?.status ?? UserCertificationProgressStatus.inititialized
4046
const completedPercentage: number = (props.progress?.courseProgressPercentage ?? 0) / 100
41-
const inProgress: boolean = status === MyCertificationProgressStatus.inProgress || !!props.progress?.currentLesson
42-
const isCompleted: boolean = status === MyCertificationProgressStatus.completed
47+
const inProgress: boolean = status === UserCertificationProgressStatus.inProgress || !!props.progress?.currentLesson
48+
const isCompleted: boolean = status === UserCertificationProgressStatus.completed
4349

4450
/**
4551
* Redirect user to the currentLesson if there's already some progress recorded
4652
* otherwise redirect to first module > first lesson
4753
*/
4854
const handleStartCourse: () => void = useCallback(() => {
49-
const current: Array<string> = (props.progress?.currentLesson ?? '').split('/')
55+
5056
const course: LearnCourse = props.course
5157
const module: LearnModule = course.modules[0]
5258
const lesson: LearnLesson = module.lessons[0]
5359

54-
const lessonPath: string = getFccLessonPath(
60+
const lessonPath: string = getLessonPathFromCurrentLesson(
5561
course.provider,
5662
course.certification,
57-
current[0] || module.meta.dashedName,
58-
current[1] || lesson.dashedName,
63+
props.progress?.currentLesson,
64+
module.meta.dashedName,
65+
lesson.dashedName,
5966
)
6067
navigate(lessonPath)
61-
}, [props.course, props.progress, navigate])
68+
}, [
69+
getLessonPathFromCurrentLesson,
70+
navigate,
71+
props.course,
72+
props.progress,
73+
])
6274

6375
/**
6476
* Handle user click on start course/resume/login button
@@ -97,7 +109,7 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
97109
}
98110

99111
if (!props.progress?.id) {
100-
await startMyCertificationsProgressAsync(
112+
await userCertificationProgressStartAsync(
101113
props.profile.userId,
102114
props.course.certificationId,
103115
props.course.id,
@@ -107,9 +119,9 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
107119
}
108120
)
109121
} else {
110-
await updateMyCertificationsProgressAsync(
122+
await userCertificationProgressUpdateAsync(
111123
props.progress.id,
112-
UpdateMyCertificateProgressActions.acceptHonestyPolicy,
124+
UserCertificationUpdateProgressActions.acceptHonestyPolicy,
113125
{}
114126
)
115127
}
@@ -134,9 +146,9 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
134146
* proceed as if the user just clicked "Start course" button
135147
*/
136148
useEffect(() => {
137-
if (props.progressReady && isLoggedIn && searchParams.get('start-course') !== null) {
138-
handleStartCourseClick()
139-
}
149+
if (props.progressReady && isLoggedIn && searchParams.get('start-course') !== null) {
150+
handleStartCourseClick()
151+
}
140152
}, [handleStartCourseClick, isLoggedIn, props.progressReady, searchParams])
141153

142154
return (

0 commit comments

Comments
 (0)