From a26a7773583b1aa32437dfbfa0139fc91e2d7524 Mon Sep 17 00:00:00 2001 From: Alina086 Date: Tue, 17 Jun 2025 11:53:40 -0400 Subject: [PATCH 1/4] Added new studypages for start-of-task logging --- frontend/src/editor/index.tsx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/frontend/src/editor/index.tsx b/frontend/src/editor/index.tsx index 329471d8..237b874a 100644 --- a/frontend/src/editor/index.tsx +++ b/frontend/src/editor/index.tsx @@ -116,10 +116,13 @@ function EditorScreen() { const studyPageNames = [ 'study-intro', 'study-introSurvey', + 'study-startTask1', 'study-task1', 'study-postTask1', + 'study-startTask2', 'study-task2', 'study-postTask2', + 'study-startTask3', 'study-task3', 'study-postTask3', 'study-postStudySurvey', @@ -233,7 +236,38 @@ function Router({ ); } + else if (page.startsWith('study-startTask')) { + const urlParams = new URLSearchParams(window.location.search); + + const startTaskNumber = page.replace('study-startTask', ''); + const taskConfig = taskConfigs[startTaskNumber as keyof typeof taskConfigs]; + + if (!taskConfig) { + return
Invalid task number
; + } + const taskCondition = taskConfig.condition; + + return ( +
+ +
+ ); + } else if (page.startsWith('study-task')){ const urlParams = new URLSearchParams(window.location.search); From 76a81d6733817510bdecba6561bb4ec9429a3a65 Mon Sep 17 00:00:00 2001 From: Alina086 Date: Tue, 17 Jun 2025 14:17:39 -0400 Subject: [PATCH 2/4] Counterbalancing suggestion types for StudyPage --- frontend/src/editor/index.tsx | 57 ++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/frontend/src/editor/index.tsx b/frontend/src/editor/index.tsx index 237b874a..b4b498e0 100644 --- a/frontend/src/editor/index.tsx +++ b/frontend/src/editor/index.tsx @@ -137,20 +137,33 @@ const SURVEY_URLS = { postStudy: '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.', - }, - }; + '1': { + 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': { + 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.' + }, + '3': { + 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.' + } +} + +const letterToCondition = { + e: 'Completion', + q: 'Question', + r: 'RMove' +}; + +// This is the mapping of condition order letter abbreviation received from the URL parameter (eg. eqr, req, ...) to conditions. +function mapInputToDict(input: string) { + const result: Record = {}; + input.split('').forEach((letter, idx) => { + result[(idx + 1).toString()] = { condition: letterToCondition[letter as keyof typeof letterToCondition] }; + }); + return result; +} function Router({ page @@ -173,10 +186,18 @@ function Router({ const urlParams = new URLSearchParams(window.location.search); const username = urlParams.get('username'); + const conditionOrder = urlParams.get('order'); + if (!username) { return
Please provide a username in the URL parameter.
; } + if (!conditionOrder) { + return
Please provide a condition order in the URL parameter.
; + } + + const conditionConfigs = mapInputToDict(conditionOrder); + const studyPageIndex = studyPageNames.indexOf(page); if (studyPageIndex === -1) { return
Unknown study page
; @@ -240,13 +261,13 @@ function Router({ const urlParams = new URLSearchParams(window.location.search); const startTaskNumber = page.replace('study-startTask', ''); - const taskConfig = taskConfigs[startTaskNumber as keyof typeof taskConfigs]; + const conditionConfig = conditionConfigs[startTaskNumber as keyof typeof conditionConfigs]; - if (!taskConfig) { + if (!conditionConfig) { return
Invalid task number
; } - const taskCondition = taskConfig.condition; + const taskCondition = conditionConfig.condition; return (
@@ -273,10 +294,12 @@ function Router({ const taskNumber = page.replace('study-task', ''); const taskConfig = taskConfigs[taskNumber as keyof typeof taskConfigs]; + const conditionConfig = conditionConfigs[taskNumber as keyof typeof conditionConfigs]; + if (!taskConfig) { return
Invalid task number
; } - getDefaultStore().set(studyConditionAtom, taskConfig.condition); + getDefaultStore().set(studyConditionAtom, conditionConfig.condition); getDefaultStore().set(taskDescriptionAtom, taskConfig.taskDescription); return ( From 759bc2bad07f1614d9693e4bf5fa1c9d802fe4e9 Mon Sep 17 00:00:00 2001 From: Alina086 Date: Tue, 17 Jun 2025 16:02:54 -0400 Subject: [PATCH 3/4] Added consent form studypage --- frontend/src/editor/index.tsx | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/frontend/src/editor/index.tsx b/frontend/src/editor/index.tsx index b4b498e0..c5b6533d 100644 --- a/frontend/src/editor/index.tsx +++ b/frontend/src/editor/index.tsx @@ -114,6 +114,7 @@ function EditorScreen() { } const studyPageNames = [ + 'study-consentForm', 'study-intro', 'study-introSurvey', 'study-startTask1', @@ -130,6 +131,7 @@ const studyPageNames = [ ]; const SURVEY_URLS = { + consentForm: 'https://calvin.co1.qualtrics.com/jfe/form/SV_3adI70Zxk7e2ueW', 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', @@ -205,12 +207,33 @@ function Router({ const nextPage = studyPageNames[studyPageIndex + 1] || 'study-intro'; - if (page === 'study-intro') { - // TODO: consent form + if (page === 'study-consentForm') { + const nextUrlParams = new URLSearchParams(window.location.search); + nextUrlParams.set('page', nextPage); + const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); + const consentFormURL = SURVEY_URLS.consentForm; + + return ; + } + else if (page === 'study-intro') { return

Welcome!

- Thank you for participating in our writing study. You'll complete three writing tasks on different topics. + Thank you for agreeing to participate in our writing study. You'll complete three writing tasks on different topics. After completing each task, click 'Done' to save your work and continue to the next task. As you write, pay attention to the suggestions the writing tool offers and use them when they seem helpful. There are no right or wrong ways to interact with the tool. @@ -233,7 +256,7 @@ function Router({

; } - if (page === 'study-introSurvey') { + else if (page === 'study-introSurvey') { const nextUrlParams = new URLSearchParams(window.location.search); nextUrlParams.set('page', nextPage); const redirectURL = encodeURIComponent(window.location.origin + `/editor.html?${nextUrlParams.toString()}`); From 7a5411c223ac257eb5de5ae9b78e44d5cafd219c Mon Sep 17 00:00:00 2001 From: Alina086 Date: Tue, 17 Jun 2025 16:49:36 -0400 Subject: [PATCH 4/4] Validated condition order input in URL --- frontend/src/editor/index.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/src/editor/index.tsx b/frontend/src/editor/index.tsx index c5b6533d..34d5b995 100644 --- a/frontend/src/editor/index.tsx +++ b/frontend/src/editor/index.tsx @@ -198,6 +198,17 @@ function Router({ return
Please provide a condition order in the URL parameter.
; } + const isValidOrder = + // Check if the condition order only contains valid letters (e, q, r) and has no duplicates + conditionOrder.split('').every((letter) => + Object.keys(letterToCondition).includes(letter) + ) && + new Set(conditionOrder.split('')).size === conditionOrder.length; + + if (!isValidOrder) { + return
Invalid condition order. Please use a unique combination of 'e', 'q', and 'r'.
; + } + const conditionConfigs = mapInputToDict(conditionOrder); const studyPageIndex = studyPageNames.indexOf(page);