diff --git a/frontend/src/editor/index.tsx b/frontend/src/editor/index.tsx index f725213b..6e0da970 100644 --- a/frontend/src/editor/index.tsx +++ b/frontend/src/editor/index.tsx @@ -114,25 +114,40 @@ function EditorScreen() { } const studyPageNames = [ - 'study-introSurvey', 'study-intro', + 'study-introSurvey', 'study-task1', - 'study-posttask1', + 'study-postTask1', 'study-task2', - 'study-posttask2', + 'study-postTask2', 'study-task3', - 'study-posttask3', + 'study-postTask3', 'study-final' ]; const SURVEY_URLS = { - preStudy: 'https://calvin.co1.qualtrics.com/jfe/form/SV_eM6R5Yw7nnJ3jh4', // Pre-study survey + preStudy: 'https://calvin.co1.qualtrics.com/jfe/form/SV_eM6R5Yw7nnJ3jh4', postTask1: 'https://calvin.co1.qualtrics.com/jfe/form/SV_6Vuc9vgqMuEqzVY', postTask2: 'https://calvin.co1.qualtrics.com/jfe/form/SV_7X8tAiech6zP79A', postTask3: 'https://calvin.co1.qualtrics.com/jfe/form/SV_1M8MN5b0H9pfYsm', final: 'https://calvin.co1.qualtrics.com/jfe/form/SV_79DIQlYz4SJCwnk' }; +const taskConfigs = { + '1': { + condition: 'Completion', + taskDescription: 'Task 1: Should companies adopt a four-day work week (working Monday through Thursday) instead of the traditional five-day schedule? Consider impacts on productivity, employee well-being, and business operations.', + }, + '2': { + condition: 'Question', + taskDescription: 'Task 2: Write a cover letter for the position described. The applicant is a recent college graduate with a major in Environmental Sustainability and a minor in Marketing, with relevant internship experience. Demonstrate how their background aligns with the company’s mission and requirements. [Details are given below in the editor document]', + }, + '3': { + condition: 'RMove', + taskDescription: 'Task 3: After reading these paragraphs, write a summary that explains CRISPR gene editing to your 11th grade biology classmates. Your goal is to help them understand what CRISPR is, how it works, and why it matters, using language and examples they would find clear and engaging.', + }, + }; + function Router({ page }: { @@ -148,22 +163,23 @@ function Router({ return ; } else if (page.startsWith('study')) { + + getDefaultStore().set(pageNameAtom, PageName.Study); + getDefaultStore().set(overallModeAtom, OverallMode.study); + const urlParams = new URLSearchParams(window.location.search); const username = urlParams.get('username'); if (!username) { - return
Please provide an username in the URL parameter.
; + return
Please provide a username in the URL parameter.
; } - getDefaultStore().set(pageNameAtom, PageName.Study); - getDefaultStore().set(overallModeAtom, OverallMode.study); - const studyPageIndex = studyPageNames.indexOf(page); if (studyPageIndex === -1) { return
Unknown study page
; } - - //const nextPage = studyPageNames[studyPageIndex + 1] || 'study-intro'; - + + const nextPage = studyPageNames[studyPageIndex + 1] || 'study-intro'; + if (page === 'study-intro') { // TODO: consent form return
@@ -182,7 +198,7 @@ function Router({ event: 'StartStudy', interaction: 'User clicked Start Study button' }); - urlParams.set('page', 'study-introSurvey') + urlParams.set('page', nextPage) window.location.search = urlParams.toString() ; }} className={classes.startButton} @@ -194,22 +210,19 @@ function Router({ } if (page === 'study-introSurvey') { const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-task1'); - const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); - - //const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?page=study-task1`); - const introSurveyURL = 'https://calvin.co1.qualtrics.com/jfe/form/SV_eM6R5Yw7nnJ3jh4'; + nextUrlParams.set('page', nextPage); + const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); + const introSurveyURL = SURVEY_URLS.preStudy; + return (
- { log ({ username: username, event: 'StartIntroSurvey', interaction: 'User clicked Intro Survey button' }); - urlParams.set('page', 'study-task1') - window.location.search = urlParams.toString() ; }} href={`${introSurveyURL}?redirect_url=${redirectURL}`} className={classes.startButton} @@ -219,169 +232,63 @@ function Router({
); } - - else if (page === 'study-task1') { - const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-posttask1'); - - const condition = 'Completion'; // This would be dynamically set based on the study task - getDefaultStore().set(studyConditionAtom, condition); - const taskDescription = 'Task 1: Should companies adopt a four-day work week (working Monday through Thursday) instead of the traditional five-day schedule? Consider impacts on productivity, employee well-being, and business operations.'; - getDefaultStore().set(taskDescriptionAtom, taskDescription); - return
-
{taskDescription}
+ else if (page.startsWith('study-task')){ + const urlParams = new URLSearchParams(window.location.search); - - - -
; - } - else if (page === 'study-posttask1') { - const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-task2'); - const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); - - return
-

Thank you for completing Task 1. Please take a moment to complete a brief survey.

- -
; + const taskNumber = page.replace('study-task', ''); + const taskConfig = taskConfigs[taskNumber as keyof typeof taskConfigs]; + if (!taskConfig) { + return
Invalid task number
; } - else if (page === 'study-task2') { - const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-posttask2'); - - const condition = 'Question' // This would be dynamically set based on the study task - getDefaultStore().set(studyConditionAtom, condition); - const taskDescription = 'Task 2: Write a cover letter for the position described. The applicant is a recent college graduate with a major in Environmental Sustainability and a minor in Marketing, with relevant internship experience. Demonstrate how their background aligns with the company’s mission and requirements. [Details are given below in the editor document]'; - getDefaultStore().set(taskDescriptionAtom, taskDescription); + getDefaultStore().set(studyConditionAtom, taskConfig.condition); + getDefaultStore().set(taskDescriptionAtom, taskConfig.taskDescription); - return
-
{taskDescription}
- - - - - -
; - } - else if (page === 'study-posttask2') { - const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-task3'); - const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); - - return
-

Thank you for completing Task 2. Please take a moment to complete a brief survey.

- -
; - } - else if (page === 'study-task3') { - const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-posttask3'); - - const condition = 'RMove' // This would be dynamically set based on the study task - getDefaultStore().set(studyConditionAtom, condition); - const taskDescription = 'Task 3: After reading these paragraphs, write a summary that explains CRISPR gene editing to your 11th grade biology classmates. Your goal is to help them understand what CRISPR is, how it works, and why it matters, using language and examples they would find clear and engaging.'; - getDefaultStore().set(taskDescriptionAtom, taskDescription); - - return
-
{taskDescription}
- - + return ( +
+
{taskConfig.taskDescription}
- + -
; + +
+ ); } - else if (page === 'study-posttask3') { + else if (page.startsWith('study-postTask')) { const nextUrlParams = new URLSearchParams(window.location.search); - nextUrlParams.set('page', 'study-final'); - const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); + nextUrlParams.set('page', nextPage); + const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); + const postTaskNumber = page.replace('study-postTask', ''); + const postTaskSurveyURL = SURVEY_URLS[`postTask${postTaskNumber}` as keyof typeof SURVEY_URLS]; return
-

Thank you for completing Task 3. Please take a moment to complete a brief survey.

-
+
; } else if (page === 'study-final') {