Skip to content

Commit c5e2a7c

Browse files
Merge pull request #432 from topcoder-platform/TCA-790_assessments
TCA-790 Delay survey if the cert is completed -> dev
2 parents c30680a + 67defd5 commit c5e2a7c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,26 @@ const FreeCodeCamp: FC<{}> = () => {
271271
return
272272
}
273273

274-
// this is the last lesson to be completed in the first module completed,
275-
// so it's good to show the trigger
276-
surveyTriggerForUser('TCA First Module Completed', profile?.userId)
274+
// This is the last lesson to be completed in the first module completed,
275+
// so it's time to trigger the survey
276+
const surveyTrigger: string = 'TCA First Module Completed'
277+
278+
// If there is only one assessment in a cert (e.g. Data Analysis w/Python),
279+
// the cert is also completed, which redirects the user to the cert page.
280+
// So the survey needs to be delayed so that it appears on the completed
281+
// cert page instead of the current lesson.
282+
283+
// NOTE: we can't use the cert's status here bc it doesn't get set to
284+
// completed until the UI notices the cert is complete and initiates
285+
// the completion. And we have to use >= instead of === because it's
286+
// possible TCA data isn't in sync w/the latest FCC curriculum.
287+
if (progress.certificationProgressPercentage >= 100) {
288+
setTimeout(async () => {
289+
surveyTriggerForUser(surveyTrigger, profile?.userId)
290+
}, 1000)
291+
} else {
292+
surveyTriggerForUser(surveyTrigger, profile?.userId)
293+
}
277294
}
278295

279296
/**

0 commit comments

Comments
 (0)