From 8ce141d4d792c5304dd9b744a419408e1213a6c0 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Mon, 16 Dec 2019 17:07:58 -0500 Subject: [PATCH 01/13] fix: trialEnd triggers --- public/config/trigger.js | 1 + src/config/trigger.js | 2 ++ src/trials/trialEnd.js | 6 ++---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/public/config/trigger.js b/public/config/trigger.js index 70aa181..24c4611 100644 --- a/public/config/trigger.js +++ b/public/config/trigger.js @@ -21,6 +21,7 @@ const eventCodes = { rewardFeedbackEnd: 71, showPaymentStart: 80, showPaymendEnd: 81, + trialFinish: 3, test_connect: 4, open_task: 5 } diff --git a/src/config/trigger.js b/src/config/trigger.js index 50eae7f..1bfb99b 100644 --- a/src/config/trigger.js +++ b/src/config/trigger.js @@ -18,6 +18,8 @@ const eventCodes = { rewardFeedbackEnd: 71, showPaymentStart: 80, showPaymendEnd: 81, + trialFinishStart: 90, + trialFinishEnd: 91, test_connect: 4, open_task: 5 } diff --git a/src/trials/trialEnd.js b/src/trials/trialEnd.js index 62208ef..f6a80a4 100644 --- a/src/trials/trialEnd.js +++ b/src/trials/trialEnd.js @@ -2,8 +2,7 @@ import { eventCodes, MTURK } from '../config/main' import { photodiodeGhostBox, pdSpotEncode } from '../lib/markup/photodiode' const trialEnd = (trialDetails, duration) => { - const startCode = eventCodes.trialFinishStart - const endCode = eventCodes.trialFinishEnd + const endCode = eventCodes.trialFinish return { type: 'html_keyboard_response', @@ -11,14 +10,13 @@ const trialEnd = (trialDetails, duration) => { response_ends_trial: false, trial_duration: duration, on_load: () => { - pdSpotEncode(startCode) }, on_start: (trial) => { if (!MTURK) trial.stimulus += photodiodeGhostBox() }, on_finish: (data) => { pdSpotEncode(endCode) - data.code = [startCode, endCode] + data.code = endCode } } } From dd75085d578e5fb944e51403d49636f2ec8aa2e1 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Mon, 16 Dec 2019 17:21:18 -0500 Subject: [PATCH 02/13] refactor: cleaning up pressBalloon a bit --- src/config/experiment.js | 24 ++++++++++++------------ src/timelines/main.js | 26 +++++++++++++------------- src/trials/pressBalloon.js | 27 +++++++++++---------------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/config/experiment.js b/src/config/experiment.js index e398808..a8c20b7 100644 --- a/src/config/experiment.js +++ b/src/config/experiment.js @@ -6,20 +6,20 @@ import { deepCopy } from '../lib/utils' // create copy of default settings let exptBlock1 = deepCopy(defaultBlockSettings) -exptBlock1.probs = ["100%", "100%", "50%", "50%"] -exptBlock1.counterbalance = true -exptBlock1.value = [3, 5, 7] -exptBlock1.effort = [100, 120, 150] -exptBlock1.keys = ['q', 'p'] -exptBlock1.get_reward = [true, true, true, false] - -// debug settings where there are only 2 trials in main task block -// exptBlock1.probs = ["100%"] +// exptBlock1.probs = ["100%", "100%", "50%", "50%"] // exptBlock1.counterbalance = true -// exptBlock1.value = [3] -// exptBlock1.effort = [20] +// exptBlock1.value = [3, 5, 7] +// exptBlock1.effort = [100, 120, 150] // exptBlock1.keys = ['q', 'p'] -// exptBlock1.get_reward = [true] +// exptBlock1.get_reward = [true, true, true, false] + +// debug settings where there are only 2 trials in main task block +exptBlock1.probs = ["100%"] +exptBlock1.counterbalance = true +exptBlock1.value = [3] +exptBlock1.effort = [20] +exptBlock1.keys = ['q', 'p'] +exptBlock1.get_reward = [true] diff --git a/src/timelines/main.js b/src/timelines/main.js index ae3459a..818926f 100644 --- a/src/timelines/main.js +++ b/src/timelines/main.js @@ -14,19 +14,19 @@ import quizTimeline from '../trials/quizTrials' const primaryTimeline = [ experimentStart(), userId(), - preamble, - bluePracticeInstructions(), - buildCountdown(lang.countdown.practice1, 3), - taskBlock(practiceBlock1), - greenPracticeInstructions(), - buildCountdown(lang.countdown.practice2, 3), - taskBlock(practiceBlock2), - realPracticeInstructions(), - buildCountdown(lang.countdown.practice3, 3), - taskBlock(practiceBlock3), - quizTimeline(practiceBlock1), - postPracticeInstructions(), - buildCountdown(lang.countdown.expt1, 3), + // preamble, + // bluePracticeInstructions(), + // buildCountdown(lang.countdown.practice1, 3), + // taskBlock(practiceBlock1), + // greenPracticeInstructions(), + // buildCountdown(lang.countdown.practice2, 3), + // taskBlock(practiceBlock2), + // realPracticeInstructions(), + // buildCountdown(lang.countdown.practice3, 3), + // taskBlock(practiceBlock3), + // quizTimeline(practiceBlock1), + // postPracticeInstructions(), + // buildCountdown(lang.countdown.expt1, 3), taskBlock(exptBlock1), showPayment(5000), experimentEnd(5000) diff --git a/src/trials/pressBalloon.js b/src/trials/pressBalloon.js index 763a306..dcf9493 100644 --- a/src/trials/pressBalloon.js +++ b/src/trials/pressBalloon.js @@ -97,7 +97,7 @@ const pressBalloon = (duration, blockSettings) => { // this.deleteCircle(); reward = computeReward() - data ={ + data = { "reward": reward, "is_practice": is_practice, "subtrial_type": 'inflate_balloon', @@ -149,39 +149,34 @@ const pressBalloon = (duration, blockSettings) => { balloonYpos -= inflateBy; // redraw - if (choice.key === keys['Q']){ + if (choice.key === keys['Q']) { drawBalloon(ctx, choice.effort, choice.high_effort, canvasSettings.balloonXpos[0], balloonYpos, radius) } - if (choice.key === keys['P']){ + if (choice.key === keys['P']) { drawBalloon(ctx, choice.effort, choice.high_effort, canvasSettings.balloonXpos[1], balloonYpos, radius) } - if (hitSpike() && !choice.high_effort){ + if (hitSpike() && !choice.high_effort) { pop() } - if (hitSpike() && choice.high_effort) - { - if (choice.key === keys['Q']) - { + if (hitSpike() && choice.high_effort) { + if (choice.key === keys['Q']) { drawSpike(ctx, canvasSettings.spikeWidth, spikeHeight, canvasSettings.spikeXpos[0], canvasSettings.spikeYpos, canvasSettings.frameLinecolor, canvasSettings.frameLinecolor, true) drawBalloon(ctx, choice.effort, choice.high_effort, canvasSettings.balloonXpos[0], balloonYpos, radius) } - if (choice.key === keys['P']) - { + if (choice.key === keys['P']) { drawSpike(ctx, canvasSettings.spikeWidth, spikeHeight, canvasSettings.spikeXpos[1], canvasSettings.spikeYpos, canvasSettings.frameLinecolor, canvasSettings.frameLinecolor, true) drawBalloon(ctx, choice.effort, choice.high_effort, canvasSettings.balloonXpos[1], balloonYpos, radius) } var balloonBase = canvasSettings.balloonBaseHeight - var balloonHeight = (balloonBase + (2* radius)); + var balloonHeight = (balloonBase + (2 * radius)); spikeHeight = canvasSettings.frameDimensions[1] - balloonHeight - canvasSettings.spiketopHeight - if (choice.key === keys['Q']) - { + if (choice.key === keys['Q']) { drawSpike(ctx, canvasSettings.spikeWidth, spikeHeight, canvasSettings.spikeXpos[0], canvasSettings.spikeYpos, canvasSettings.frameLinecolor, canvasSettings.frameLinecolor, false) } - if (choice.key === keys['P']) - { + if (choice.key === keys['P']) { drawSpike(ctx, canvasSettings.spikeWidth, spikeHeight, canvasSettings.spikeXpos[1], canvasSettings.spikeYpos, canvasSettings.frameLinecolor, canvasSettings.frameLinecolor, false) } - if (countPumps > choice.effort+10){ + if (countPumps > choice.effort + 10) { pop() return } From d1372bb41a5b0e6c29e604abfab8baeb7424ed56 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 11:32:59 -0500 Subject: [PATCH 03/13] refactor: taskUtils.js --- src/lib/taskUtils.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/lib/taskUtils.js b/src/lib/taskUtils.js index df85877..af68713 100644 --- a/src/lib/taskUtils.js +++ b/src/lib/taskUtils.js @@ -3,23 +3,19 @@ import _ from 'lodash' // initialize starting conditions for each trial within a block const generateStartingOpts = (blockSettings) => { - if(blockSettings.is_practice) - { + if (blockSettings.is_practice) { let startingOptions = blockSettings.probs.map( (c) => { // Repeat each starting condition the same number of times return _.range(blockSettings.repeats_per_condition).map( () => c ) }) - return _.shuffle(_.flatten(startingOptions)) - } - else - { + } else { let opts = [] - for (let i = 0; i < blockSettings.probs.length; i++){ - for (let val in blockSettings.value){ - for (let eff in blockSettings.effort){ - opts.push({prob: blockSettings.probs[i], effort: [blockSettings.effort[eff],20], value: [blockSettings.value[val], 1], high_effort: [true, false], get_reward: [blockSettings.get_reward[i], blockSettings.get_reward[i]]}) - if (blockSettings.counterbalance){ + for (let i = 0; i < blockSettings.probs.length; i++) { + for (let val in blockSettings.value) { + for (let eff in blockSettings.effort) { + opts.push({prob : blockSettings.probs[i], effort: [blockSettings.effort[eff],20], value: [blockSettings.value[val], 1], high_effort: [true, false], get_reward: [blockSettings.get_reward[i], blockSettings.get_reward[i]]}) + if (blockSettings.counterbalance) { opts.push({prob: blockSettings.probs[i], effort: [20, blockSettings.effort[eff]], value: [1, blockSettings.value[val]], high_effort: [false, true], get_reward: [blockSettings.get_reward[i], blockSettings.get_reward[i]]}); } } From 612e860647368e0d9f84e65525f01db712239ed6 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 11:54:37 -0500 Subject: [PATCH 04/13] feat: save out rts and pump counts from pressBalloon.js phase --- src/trials/pressBalloon.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/trials/pressBalloon.js b/src/trials/pressBalloon.js index dcf9493..d3efcfd 100644 --- a/src/trials/pressBalloon.js +++ b/src/trials/pressBalloon.js @@ -101,6 +101,8 @@ const pressBalloon = (duration, blockSettings) => { "reward": reward, "is_practice": is_practice, "subtrial_type": 'inflate_balloon', + "rt": rts, + "pumps": countPumps } }; function popTimeout() { @@ -117,6 +119,8 @@ const pressBalloon = (duration, blockSettings) => { "reward": reward, "is_practice": is_practice, "subtrial_type": 'inflate_balloon', + "rt": rts, + "pumps": countPumps } }; function hitSpike() { @@ -129,12 +133,14 @@ const pressBalloon = (duration, blockSettings) => { } return crash; } + + let rts = [] + function inflate(choice) { // if (popped){ // return // } - let rts = [] // Record RT relative to when trial started var timeWhenPressed = (new Date()).getTime(); var rt = timeWhenPressed - timeWhenStarted From 871a2eab4886b1272627f6a6cb74ee5f57782a97 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 13:42:11 -0500 Subject: [PATCH 05/13] fix: showPayment total_earnings saved out --- src/trials/showPayment.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/trials/showPayment.js b/src/trials/showPayment.js index ba9a5e2..b70225b 100644 --- a/src/trials/showPayment.js +++ b/src/trials/showPayment.js @@ -9,14 +9,14 @@ const showPayment = (duration) => { const startCode = eventCodes.showPaymentStart const endCode = eventCodes.showPaymentEnd - const total_earnings = 0 // initialize idk + let total_earnings = 0 // initialize idk if (!AT_HOME || MTURK) { return { type: 'html_keyboard_response', stimulus: '', - response_ends_trial: false, - trial_duration: duration, + response_ends_trial: true, + // trial_duration: duration, on_load: () => { pdSpotEncode(startCode) addCursor('experiment') @@ -25,7 +25,7 @@ const showPayment = (duration) => { const value = jsPsych.data.get().select('value').values const last = value[value.length - 1] const total_cumulative = last.trial_cumulative_earnings - const total_earnings = total_cumulative / 20 // $1 for every 20 pts + total_earnings += (total_cumulative / 20) // $1 for every 20 pts trial.stimulus = baseStimulus(`

${lang.payment.earned}
${formatDollars(total_earnings)}

`, true) + photodiodeGhostBox() @@ -40,7 +40,7 @@ const showPayment = (duration) => { else { return { type: 'html_keyboard_response', - trial_duration: 1, + // trial_duration: 1, on_load: () => addCursor('experiment') } } From a59b445df2a2b85e6d243bb28ef8e9985ce45734 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 13:50:57 -0500 Subject: [PATCH 06/13] feat: add instruction to inform experimenter or earnings/task finish --- src/trials/showPayment.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trials/showPayment.js b/src/trials/showPayment.js index b70225b..227d462 100644 --- a/src/trials/showPayment.js +++ b/src/trials/showPayment.js @@ -27,13 +27,14 @@ const showPayment = (duration) => { const total_cumulative = last.trial_cumulative_earnings total_earnings += (total_cumulative / 20) // $1 for every 20 pts - trial.stimulus = baseStimulus(`

${lang.payment.earned}
${formatDollars(total_earnings)}

`, true) + + trial.stimulus = baseStimulus(`

${lang.payment.earned}
${formatDollars(total_earnings)}

${lang.payment.experimenter}

`, true) + photodiodeGhostBox() }, on_finish: (data) => { pdSpotEncode(endCode) data.code = [startCode, endCode] data.total_earnings = total_earnings + data.subtrial_type = "show_payment" } } } From fbd31743a65da4899cda8c5b081f6f9548f54fda Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 13:54:35 -0500 Subject: [PATCH 07/13] fix: payment end code --- src/config/trigger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/trigger.js b/src/config/trigger.js index 1bfb99b..2974780 100644 --- a/src/config/trigger.js +++ b/src/config/trigger.js @@ -17,7 +17,7 @@ const eventCodes = { rewardFeedbackStart: 70, rewardFeedbackEnd: 71, showPaymentStart: 80, - showPaymendEnd: 81, + showPaymentEnd: 81, trialFinishStart: 90, trialFinishEnd: 91, test_connect: 4, From b0e24e164924350f4a67fd0ebd700a09423fb1aa Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 13:55:56 -0500 Subject: [PATCH 08/13] docs: uncomment timeline and main config --- src/config/experiment.js | 24 ++++++++++++------------ src/timelines/main.js | 26 +++++++++++++------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/config/experiment.js b/src/config/experiment.js index a8c20b7..e398808 100644 --- a/src/config/experiment.js +++ b/src/config/experiment.js @@ -6,20 +6,20 @@ import { deepCopy } from '../lib/utils' // create copy of default settings let exptBlock1 = deepCopy(defaultBlockSettings) -// exptBlock1.probs = ["100%", "100%", "50%", "50%"] -// exptBlock1.counterbalance = true -// exptBlock1.value = [3, 5, 7] -// exptBlock1.effort = [100, 120, 150] -// exptBlock1.keys = ['q', 'p'] -// exptBlock1.get_reward = [true, true, true, false] - -// debug settings where there are only 2 trials in main task block -exptBlock1.probs = ["100%"] +exptBlock1.probs = ["100%", "100%", "50%", "50%"] exptBlock1.counterbalance = true -exptBlock1.value = [3] -exptBlock1.effort = [20] +exptBlock1.value = [3, 5, 7] +exptBlock1.effort = [100, 120, 150] exptBlock1.keys = ['q', 'p'] -exptBlock1.get_reward = [true] +exptBlock1.get_reward = [true, true, true, false] + +// debug settings where there are only 2 trials in main task block +// exptBlock1.probs = ["100%"] +// exptBlock1.counterbalance = true +// exptBlock1.value = [3] +// exptBlock1.effort = [20] +// exptBlock1.keys = ['q', 'p'] +// exptBlock1.get_reward = [true] diff --git a/src/timelines/main.js b/src/timelines/main.js index 818926f..ae3459a 100644 --- a/src/timelines/main.js +++ b/src/timelines/main.js @@ -14,19 +14,19 @@ import quizTimeline from '../trials/quizTrials' const primaryTimeline = [ experimentStart(), userId(), - // preamble, - // bluePracticeInstructions(), - // buildCountdown(lang.countdown.practice1, 3), - // taskBlock(practiceBlock1), - // greenPracticeInstructions(), - // buildCountdown(lang.countdown.practice2, 3), - // taskBlock(practiceBlock2), - // realPracticeInstructions(), - // buildCountdown(lang.countdown.practice3, 3), - // taskBlock(practiceBlock3), - // quizTimeline(practiceBlock1), - // postPracticeInstructions(), - // buildCountdown(lang.countdown.expt1, 3), + preamble, + bluePracticeInstructions(), + buildCountdown(lang.countdown.practice1, 3), + taskBlock(practiceBlock1), + greenPracticeInstructions(), + buildCountdown(lang.countdown.practice2, 3), + taskBlock(practiceBlock2), + realPracticeInstructions(), + buildCountdown(lang.countdown.practice3, 3), + taskBlock(practiceBlock3), + quizTimeline(practiceBlock1), + postPracticeInstructions(), + buildCountdown(lang.countdown.expt1, 3), taskBlock(exptBlock1), showPayment(5000), experimentEnd(5000) From a224c791afddc5e14094d11314a12f412d9d38e1 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 15:58:57 -0500 Subject: [PATCH 09/13] fix: payment screen typo; feat: experimenterKey to exit payment screen; refactor: comment out event marker msg --- public/electron.js | 53 +++++++++++++++++++------------------- src/config/experiment.js | 24 ++++++++--------- src/config/main.js | 3 ++- src/language/en_us.json | 2 +- src/timelines/main.js | 28 ++++++++++---------- src/trials/pressBalloon.js | 11 ++++++-- src/trials/showPayment.js | 5 +++- 7 files changed, 69 insertions(+), 57 deletions(-) diff --git a/public/electron.js b/public/electron.js index 151ec21..5d8367e 100644 --- a/public/electron.js +++ b/public/electron.js @@ -111,32 +111,33 @@ const setUpPort = async () => { } } -const handleEventSend = (code) => { - if (!portAvailable && !SKIP_SENDING_DEV) { - let message = "Event Marker not connected" - log.warn(message) - - let buttons = ["Quit", "Retry"] - if (process.env.ELECTRON_START_URL) { - buttons.push("Continue Anyway") - } - dialog.showMessageBox(mainWindow, {type: "error", message: message, title: "Task Error", buttons: buttons, defaultId: 0}) - .then((resp) => { - let opt = resp.response - if (opt == 0) { // quit - app.exit() - } else if (opt == 1) { // retry - setUpPort() - .then(() => handleEventSend(code)) - } else if (opt == 2) { - SKIP_SENDING_DEV = true - } - }) - - } else if (!SKIP_SENDING_DEV) { - sendToPort(triggerPort, code) - } -} +// EVENT MARKER NOT CONNECTED POP UP WARNING +// const handleEventSend = (code) => { +// if (!portAvailable && !SKIP_SENDING_DEV) { +// let message = "Event Marker not connected" +// log.warn(message) +// +// let buttons = ["Quit", "Retry"] +// if (process.env.ELECTRON_START_URL) { +// buttons.push("Continue Anyway") +// } +// dialog.showMessageBox(mainWindow, {type: "error", message: message, title: "Task Error", buttons: buttons, defaultId: 0}) +// .then((resp) => { +// let opt = resp.response +// if (opt == 0) { // quit +// app.exit() +// } else if (opt == 1) { // retry +// setUpPort() +// .then(() => handleEventSend(code)) +// } else if (opt == 2) { +// SKIP_SENDING_DEV = true +// } +// }) +// +// } else if (!SKIP_SENDING_DEV) { +// sendToPort(triggerPort, code) +// } +// } // EVENT TRIGGER diff --git a/src/config/experiment.js b/src/config/experiment.js index e398808..abcf5ce 100644 --- a/src/config/experiment.js +++ b/src/config/experiment.js @@ -6,20 +6,20 @@ import { deepCopy } from '../lib/utils' // create copy of default settings let exptBlock1 = deepCopy(defaultBlockSettings) -exptBlock1.probs = ["100%", "100%", "50%", "50%"] -exptBlock1.counterbalance = true -exptBlock1.value = [3, 5, 7] -exptBlock1.effort = [100, 120, 150] -exptBlock1.keys = ['q', 'p'] -exptBlock1.get_reward = [true, true, true, false] - -// debug settings where there are only 2 trials in main task block -// exptBlock1.probs = ["100%"] +// exptBlock1.probs = ["100%", "100%", "50%", "50%"] // exptBlock1.counterbalance = true -// exptBlock1.value = [3] -// exptBlock1.effort = [20] +// exptBlock1.value = [3, 5, 7] +// exptBlock1.effort = [100, 120, 150] // exptBlock1.keys = ['q', 'p'] -// exptBlock1.get_reward = [true] +// exptBlock1.get_reward = [true, true, true, false] + +// debug settings where there are only 2 trials in main task block +exptBlock1.probs = ["100%"] +exptBlock1.counterbalance = true +exptBlock1.value = [3] +exptBlock1.effort = [5] +exptBlock1.keys = ['q', 'p', 'm'] +exptBlock1.get_reward = [true] diff --git a/src/config/main.js b/src/config/main.js index 1789fa2..ee331ce 100644 --- a/src/config/main.js +++ b/src/config/main.js @@ -42,7 +42,8 @@ const canvasSettings = { const keys = { "P": 80, "Q": 81, - "space": 32 + "space": 32, + "experimenter": 'm' // key experimenter presses to quit payment screen } // is this mechanical turk? diff --git a/src/language/en_us.json b/src/language/en_us.json index f6ae68b..d8645ce 100644 --- a/src/language/en_us.json +++ b/src/language/en_us.json @@ -74,7 +74,7 @@ "total": "Total:
" }, "payment": { - "earned": "You you have earned", + "earned": "You have earned", "experimenter": "Please inform the experimenter." } } diff --git a/src/timelines/main.js b/src/timelines/main.js index ae3459a..3fd0f8b 100644 --- a/src/timelines/main.js +++ b/src/timelines/main.js @@ -14,21 +14,21 @@ import quizTimeline from '../trials/quizTrials' const primaryTimeline = [ experimentStart(), userId(), - preamble, - bluePracticeInstructions(), - buildCountdown(lang.countdown.practice1, 3), - taskBlock(practiceBlock1), - greenPracticeInstructions(), - buildCountdown(lang.countdown.practice2, 3), - taskBlock(practiceBlock2), - realPracticeInstructions(), - buildCountdown(lang.countdown.practice3, 3), - taskBlock(practiceBlock3), - quizTimeline(practiceBlock1), - postPracticeInstructions(), - buildCountdown(lang.countdown.expt1, 3), + // preamble, + // bluePracticeInstructions(), + // buildCountdown(lang.countdown.practice1, 3), + // taskBlock(practiceBlock1), + // greenPracticeInstructions(), + // buildCountdown(lang.countdown.practice2, 3), + // taskBlock(practiceBlock2), + // realPracticeInstructions(), + // buildCountdown(lang.countdown.practice3, 3), + // taskBlock(practiceBlock3), + // quizTimeline(practiceBlock1), + // postPracticeInstructions(), + // buildCountdown(lang.countdown.expt1, 3), taskBlock(exptBlock1), - showPayment(5000), + showPayment(5000, exptBlock1), experimentEnd(5000) ] diff --git a/src/trials/pressBalloon.js b/src/trials/pressBalloon.js index d3efcfd..4c9ec70 100644 --- a/src/trials/pressBalloon.js +++ b/src/trials/pressBalloon.js @@ -90,6 +90,7 @@ const pressBalloon = (duration, blockSettings) => { return points; } + function pop() { clearInterval(timer); // pop balloon @@ -102,9 +103,13 @@ const pressBalloon = (duration, blockSettings) => { "is_practice": is_practice, "subtrial_type": 'inflate_balloon', "rt": rts, - "pumps": countPumps + "pumps": countPumps, + "timeWhenPopped": (new Date()).getTime(), + "firstPress": rts[0], + "lastPress": rts[rts.length - 1], } }; + function popTimeout() { clearInterval(timer); // pop balloon @@ -120,7 +125,9 @@ const pressBalloon = (duration, blockSettings) => { "is_practice": is_practice, "subtrial_type": 'inflate_balloon', "rt": rts, - "pumps": countPumps + "pumps": countPumps, + "firstPress": rts[0], + "lastPress": rts[rts.length - 1], } }; function hitSpike() { diff --git a/src/trials/showPayment.js b/src/trials/showPayment.js index 227d462..ae6025f 100644 --- a/src/trials/showPayment.js +++ b/src/trials/showPayment.js @@ -5,16 +5,19 @@ import { baseStimulus } from '../lib/markup/stimuli' import { formatDollars, addCursor } from '../lib/utils' -const showPayment = (duration) => { +const showPayment = (duration, blockSettings) => { const startCode = eventCodes.showPaymentStart const endCode = eventCodes.showPaymentEnd let total_earnings = 0 // initialize idk + let experimenterKey = blockSettings.keys[2] // 0 is q, 1 is p, 2 is m + console.log(experimenterKey) if (!AT_HOME || MTURK) { return { type: 'html_keyboard_response', stimulus: '', + choices: experimenterKey, response_ends_trial: true, // trial_duration: duration, on_load: () => { From b356cd12d34985241c4c7aaa1b0da910c02751b4 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 16:01:33 -0500 Subject: [PATCH 10/13] fix: commenting out event marker warning --- public/electron.js | 53 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/public/electron.js b/public/electron.js index 5d8367e..376a383 100644 --- a/public/electron.js +++ b/public/electron.js @@ -111,33 +111,32 @@ const setUpPort = async () => { } } -// EVENT MARKER NOT CONNECTED POP UP WARNING -// const handleEventSend = (code) => { -// if (!portAvailable && !SKIP_SENDING_DEV) { -// let message = "Event Marker not connected" -// log.warn(message) -// -// let buttons = ["Quit", "Retry"] -// if (process.env.ELECTRON_START_URL) { -// buttons.push("Continue Anyway") -// } -// dialog.showMessageBox(mainWindow, {type: "error", message: message, title: "Task Error", buttons: buttons, defaultId: 0}) -// .then((resp) => { -// let opt = resp.response -// if (opt == 0) { // quit -// app.exit() -// } else if (opt == 1) { // retry -// setUpPort() -// .then(() => handleEventSend(code)) -// } else if (opt == 2) { -// SKIP_SENDING_DEV = true -// } -// }) -// -// } else if (!SKIP_SENDING_DEV) { -// sendToPort(triggerPort, code) -// } -// } +const handleEventSend = (code) => { + // if (!portAvailable && !SKIP_SENDING_DEV) { + // let message = "Event Marker not connected" + // log.warn(message) + // + // let buttons = ["Quit", "Retry"] + // if (process.env.ELECTRON_START_URL) { + // buttons.push("Continue Anyway") + // } + // dialog.showMessageBox(mainWindow, {type: "error", message: message, title: "Task Error", buttons: buttons, defaultId: 0}) + // .then((resp) => { + // let opt = resp.response + // if (opt == 0) { // quit + // app.exit() + // } else if (opt == 1) { // retry + // setUpPort() + // .then(() => handleEventSend(code)) + // } else if (opt == 2) { + // SKIP_SENDING_DEV = true + // } + // }) + // + // } else if (!SKIP_SENDING_DEV) { + sendToPort(triggerPort, code) + // } +} // EVENT TRIGGER From c725fe0d3a9cd8d534437b4a5a3c4de4b0121205 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 16:07:36 -0500 Subject: [PATCH 11/13] fix: properly comment out event marker msg freal this time; refactor: keys --- public/electron.js | 4 ++-- src/config/experiment.js | 24 ++++++++++++------------ src/config/main.js | 2 +- src/trials/showPayment.js | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/public/electron.js b/public/electron.js index 376a383..93d6c1c 100644 --- a/public/electron.js +++ b/public/electron.js @@ -129,12 +129,12 @@ const handleEventSend = (code) => { // setUpPort() // .then(() => handleEventSend(code)) // } else if (opt == 2) { - // SKIP_SENDING_DEV = true + SKIP_SENDING_DEV = true // } // }) // // } else if (!SKIP_SENDING_DEV) { - sendToPort(triggerPort, code) + // sendToPort(triggerPort, code) // } } diff --git a/src/config/experiment.js b/src/config/experiment.js index abcf5ce..053491c 100644 --- a/src/config/experiment.js +++ b/src/config/experiment.js @@ -6,20 +6,20 @@ import { deepCopy } from '../lib/utils' // create copy of default settings let exptBlock1 = deepCopy(defaultBlockSettings) -// exptBlock1.probs = ["100%", "100%", "50%", "50%"] -// exptBlock1.counterbalance = true -// exptBlock1.value = [3, 5, 7] -// exptBlock1.effort = [100, 120, 150] -// exptBlock1.keys = ['q', 'p'] -// exptBlock1.get_reward = [true, true, true, false] +exptBlock1.probs = ["100%", "100%", "50%", "50%"] +exptBlock1.counterbalance = true +exptBlock1.value = [3, 5, 7] +exptBlock1.effort = [100, 120, 150] +// exptBlock1.keys = ['q', 'p', 'm'] +exptBlock1.get_reward = [true, true, true, false] // debug settings where there are only 2 trials in main task block -exptBlock1.probs = ["100%"] -exptBlock1.counterbalance = true -exptBlock1.value = [3] -exptBlock1.effort = [5] -exptBlock1.keys = ['q', 'p', 'm'] -exptBlock1.get_reward = [true] +// exptBlock1.probs = ["100%"] +// exptBlock1.counterbalance = true +// exptBlock1.value = [3] +// exptBlock1.effort = [5] +// exptBlock1.keys = ['q', 'p', 'm'] +// exptBlock1.get_reward = [true] diff --git a/src/config/main.js b/src/config/main.js index ee331ce..c4d10bd 100644 --- a/src/config/main.js +++ b/src/config/main.js @@ -67,7 +67,7 @@ const defaultBlockSettings = { high_effort: [], get_reward:[], counterbalance: false, - keys: [], + keys: keys, repeats_per_condition: 1, // number of times every condition is repeated is_practice: false, photodiode_active: false, diff --git a/src/trials/showPayment.js b/src/trials/showPayment.js index ae6025f..b585310 100644 --- a/src/trials/showPayment.js +++ b/src/trials/showPayment.js @@ -10,7 +10,7 @@ const showPayment = (duration, blockSettings) => { const endCode = eventCodes.showPaymentEnd let total_earnings = 0 // initialize idk - let experimenterKey = blockSettings.keys[2] // 0 is q, 1 is p, 2 is m + let experimenterKey = blockSettings.keys['experimenter'] console.log(experimenterKey) if (!AT_HOME || MTURK) { From 21bfa273f795cd38707a17c592bd972c3a279f8b Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 16:11:35 -0500 Subject: [PATCH 12/13] fix: expKey --- src/config/experiment.js | 22 +++++++++++----------- src/config/main.js | 2 +- src/trials/showPayment.js | 3 +-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/config/experiment.js b/src/config/experiment.js index 053491c..66fb5dc 100644 --- a/src/config/experiment.js +++ b/src/config/experiment.js @@ -6,20 +6,20 @@ import { deepCopy } from '../lib/utils' // create copy of default settings let exptBlock1 = deepCopy(defaultBlockSettings) -exptBlock1.probs = ["100%", "100%", "50%", "50%"] -exptBlock1.counterbalance = true -exptBlock1.value = [3, 5, 7] -exptBlock1.effort = [100, 120, 150] -// exptBlock1.keys = ['q', 'p', 'm'] -exptBlock1.get_reward = [true, true, true, false] +// exptBlock1.probs = ["100%", "100%", "50%", "50%"] +// exptBlock1.counterbalance = true +// exptBlock1.value = [3, 5, 7] +// exptBlock1.effort = [100, 120, 150] +// // exptBlock1.keys = ['q', 'p', 'm'] +// exptBlock1.get_reward = [true, true, true, false] // debug settings where there are only 2 trials in main task block -// exptBlock1.probs = ["100%"] -// exptBlock1.counterbalance = true -// exptBlock1.value = [3] -// exptBlock1.effort = [5] +exptBlock1.probs = ["100%"] +exptBlock1.counterbalance = true +exptBlock1.value = [3] +exptBlock1.effort = [5] // exptBlock1.keys = ['q', 'p', 'm'] -// exptBlock1.get_reward = [true] +exptBlock1.get_reward = [true] diff --git a/src/config/main.js b/src/config/main.js index c4d10bd..ee331ce 100644 --- a/src/config/main.js +++ b/src/config/main.js @@ -67,7 +67,7 @@ const defaultBlockSettings = { high_effort: [], get_reward:[], counterbalance: false, - keys: keys, + keys: [], repeats_per_condition: 1, // number of times every condition is repeated is_practice: false, photodiode_active: false, diff --git a/src/trials/showPayment.js b/src/trials/showPayment.js index b585310..ff6afe5 100644 --- a/src/trials/showPayment.js +++ b/src/trials/showPayment.js @@ -10,8 +10,7 @@ const showPayment = (duration, blockSettings) => { const endCode = eventCodes.showPaymentEnd let total_earnings = 0 // initialize idk - let experimenterKey = blockSettings.keys['experimenter'] - console.log(experimenterKey) + let experimenterKey = blockSettings.keys[2] // 0 is q, 1 is p, 2 is m if (!AT_HOME || MTURK) { return { From 74ba7dabf29acf7558875d4c60ce396cc6d417e0 Mon Sep 17 00:00:00 2001 From: wasita mahaphanit Date: Tue, 17 Dec 2019 16:15:49 -0500 Subject: [PATCH 13/13] docs: uncomment timeline --- src/config/experiment.js | 22 +++++++++++----------- src/timelines/main.js | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/config/experiment.js b/src/config/experiment.js index 66fb5dc..61681c8 100644 --- a/src/config/experiment.js +++ b/src/config/experiment.js @@ -6,20 +6,20 @@ import { deepCopy } from '../lib/utils' // create copy of default settings let exptBlock1 = deepCopy(defaultBlockSettings) -// exptBlock1.probs = ["100%", "100%", "50%", "50%"] -// exptBlock1.counterbalance = true -// exptBlock1.value = [3, 5, 7] -// exptBlock1.effort = [100, 120, 150] -// // exptBlock1.keys = ['q', 'p', 'm'] -// exptBlock1.get_reward = [true, true, true, false] +exptBlock1.probs = ["100%", "100%", "50%", "50%"] +exptBlock1.counterbalance = true +exptBlock1.value = [3, 5, 7] +exptBlock1.effort = [100, 120, 150] +exptBlock1.keys = ['q', 'p', 'm'] +exptBlock1.get_reward = [true, true, true, false] // debug settings where there are only 2 trials in main task block -exptBlock1.probs = ["100%"] -exptBlock1.counterbalance = true -exptBlock1.value = [3] -exptBlock1.effort = [5] +// exptBlock1.probs = ["100%"] +// exptBlock1.counterbalance = true +// exptBlock1.value = [3] +// exptBlock1.effort = [5] // exptBlock1.keys = ['q', 'p', 'm'] -exptBlock1.get_reward = [true] +// exptBlock1.get_reward = [true] diff --git a/src/timelines/main.js b/src/timelines/main.js index 3fd0f8b..c98a5b6 100644 --- a/src/timelines/main.js +++ b/src/timelines/main.js @@ -14,19 +14,19 @@ import quizTimeline from '../trials/quizTrials' const primaryTimeline = [ experimentStart(), userId(), - // preamble, - // bluePracticeInstructions(), - // buildCountdown(lang.countdown.practice1, 3), - // taskBlock(practiceBlock1), - // greenPracticeInstructions(), - // buildCountdown(lang.countdown.practice2, 3), - // taskBlock(practiceBlock2), - // realPracticeInstructions(), - // buildCountdown(lang.countdown.practice3, 3), - // taskBlock(practiceBlock3), - // quizTimeline(practiceBlock1), - // postPracticeInstructions(), - // buildCountdown(lang.countdown.expt1, 3), + preamble, + bluePracticeInstructions(), + buildCountdown(lang.countdown.practice1, 3), + taskBlock(practiceBlock1), + greenPracticeInstructions(), + buildCountdown(lang.countdown.practice2, 3), + taskBlock(practiceBlock2), + realPracticeInstructions(), + buildCountdown(lang.countdown.practice3, 3), + taskBlock(practiceBlock3), + quizTimeline(practiceBlock1), + postPracticeInstructions(), + buildCountdown(lang.countdown.expt1, 3), taskBlock(exptBlock1), showPayment(5000, exptBlock1), experimentEnd(5000)