From 8c10a2cac01e4d787c25b8691779053a0605f1ab Mon Sep 17 00:00:00 2001 From: Brooke Date: Wed, 7 Dec 2022 10:34:51 -0800 Subject: [PATCH 1/5] TCA-790 #comment add delay if the cert is completed #time 2h --- src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx index 33829d44c..64517b891 100644 --- a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx +++ b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx @@ -271,9 +271,17 @@ const FreeCodeCamp: FC<{}> = () => { return } - // this is the last lesson to be completed in the first module completed, - // so it's good to show the trigger - surveyTriggerForUser('TCA First Module Completed', profile?.userId) + // This is the last lesson to be completed in the first module completed, + // so it's time to trigger the survey + + // If there is only one assessment in a cert (e.g. Data Analysis w/Python), + // the cert is also completed, which redirects the user to the cert page. + // So the survey needs to be delayed so that it appears on the completed + // cert page instead of the current lesson. + const delay: number = progress.status === UserCertificationProgressStatus.completed ? 3000 : 0 + setTimeout(async () => { + surveyTriggerForUser('TCA First Module Completed', profile?.userId) + }, delay) } /** From 3e0ee9904ae589c941d5ae04f3c73ab112b5a347 Mon Sep 17 00:00:00 2001 From: Brooke Date: Wed, 7 Dec 2022 15:22:49 -0800 Subject: [PATCH 2/5] TCA-790 #comment This commit sets a timeout and uses the cert progress #time 1h --- src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx index 64517b891..bdac73d99 100644 --- a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx +++ b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx @@ -273,15 +273,19 @@ const FreeCodeCamp: FC<{}> = () => { // This is the last lesson to be completed in the first module completed, // so it's time to trigger the survey + const surveyTrigger: string = 'TCA First Module Completed' // If there is only one assessment in a cert (e.g. Data Analysis w/Python), // the cert is also completed, which redirects the user to the cert page. // So the survey needs to be delayed so that it appears on the completed // cert page instead of the current lesson. - const delay: number = progress.status === UserCertificationProgressStatus.completed ? 3000 : 0 - setTimeout(async () => { - surveyTriggerForUser('TCA First Module Completed', profile?.userId) - }, delay) + if (progress.certificationProgressPercentage === 100) { + setTimeout(async () => { + surveyTriggerForUser(surveyTrigger, profile?.userId) + }, 1000) + } else { + surveyTriggerForUser(surveyTrigger, profile?.userId) + } } /** From db66c098f6598ae5622c90a1eafc1e5d5447f58a Mon Sep 17 00:00:00 2001 From: Brooke Date: Thu, 8 Dec 2022 12:28:56 -0800 Subject: [PATCH 3/5] TCA-790 fix naming --- .../{survey.functions.tsx => survey.functions.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src-ts/lib/functions/survey-functions/{survey.functions.tsx => survey.functions.ts} (100%) diff --git a/src-ts/lib/functions/survey-functions/survey.functions.tsx b/src-ts/lib/functions/survey-functions/survey.functions.ts similarity index 100% rename from src-ts/lib/functions/survey-functions/survey.functions.tsx rename to src-ts/lib/functions/survey-functions/survey.functions.ts From 181918fc68b0e8db026a350ff6ec62dc2977daed Mon Sep 17 00:00:00 2001 From: Brooke Date: Thu, 8 Dec 2022 15:58:08 -0800 Subject: [PATCH 4/5] TCA-790 #comment This commit supports the fact that a certificate can actually be more than 100% when data isn't in sync w/FCC. #time 15m --- src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx index bdac73d99..b565da434 100644 --- a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx +++ b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx @@ -279,7 +279,7 @@ const FreeCodeCamp: FC<{}> = () => { // the cert is also completed, which redirects the user to the cert page. // So the survey needs to be delayed so that it appears on the completed // cert page instead of the current lesson. - if (progress.certificationProgressPercentage === 100) { + if (progress.certificationProgressPercentage >= 100) { setTimeout(async () => { surveyTriggerForUser(surveyTrigger, profile?.userId) }, 1000) From 67defd52af786f1853822f9fb5709a07bbc3aff7 Mon Sep 17 00:00:00 2001 From: Brooke Date: Thu, 8 Dec 2022 16:00:18 -0800 Subject: [PATCH 5/5] TCA-790 comments --- src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx index b565da434..fb7764d0e 100644 --- a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx +++ b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx @@ -279,6 +279,11 @@ const FreeCodeCamp: FC<{}> = () => { // the cert is also completed, which redirects the user to the cert page. // So the survey needs to be delayed so that it appears on the completed // cert page instead of the current lesson. + + // NOTE: we can't use the cert's status here bc it doesn't get set to + // completed until the UI notices the cert is complete and initiates + // the completion. And we have to use >= instead of === because it's + // possible TCA data isn't in sync w/the latest FCC curriculum. if (progress.certificationProgressPercentage >= 100) { setTimeout(async () => { surveyTriggerForUser(surveyTrigger, profile?.userId)