diff --git a/.gitignore b/.gitignore index 9df9658..c34a3a4 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,8 @@ psiturkit/*_turk .vs/VSWorkspaceState.json .vs/slnx.sqlite .vs/Effort-Task-3/v16/.suo +.vs/Effort-Task-3/v16/.suo +*.sqlite +.vs/Effort-Task-3/v16/.suo +*.json +*.sqlite diff --git a/src/timelines/taskTrial.js b/src/timelines/taskTrial.js index 24f3e81..a0aaee0 100644 --- a/src/timelines/taskTrial.js +++ b/src/timelines/taskTrial.js @@ -6,7 +6,6 @@ import frameSpike from "../trials/frameSpike"; import choice from "../trials/choice"; import costBenefits from "../trials/costBenefits"; import { ONLINE } from "../config/main"; -import { addData } from "../lib/taskUtils"; import pressBalloon from "../trials/pressBalloon"; import rewardFeedback from "../trials/rewardFeedback"; import cumulativeReward from "../trials/cumulativeReward"; @@ -47,7 +46,7 @@ const taskTrial = (blockSettings, blockDetails, opts) => { rewardProbability(1000, blockSettings, opts, trialDetails), frameSpike(700, blockSettings, opts, trialDetails), costBenefits(1500, blockSettings, opts, trialDetails), - choice(5000, blockSettings, opts, trialDetails), + choice(6000, blockSettings, opts, trialDetails), pressBalloon(25000, blockSettings, opts), fixation(500), rewardFeedback(1000, blockSettings, opts, trialDetails), diff --git a/src/trials/choice.js b/src/trials/choice.js index 8851022..4ca8b92 100644 --- a/src/trials/choice.js +++ b/src/trials/choice.js @@ -153,7 +153,7 @@ const choice = (duration, blockSettings, opts, trialDetails) => { }; done(returnObj); } - }, 50); + }, 20); function after_response(info) { clearInterval(timer); jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener); diff --git a/src/trials/costBenefits.js b/src/trials/costBenefits.js index d6dff62..27bf646 100644 --- a/src/trials/costBenefits.js +++ b/src/trials/costBenefits.js @@ -3,7 +3,6 @@ import { jsPsych } from "jspsych-react"; import { eventCodes, keys, canvasSize, canvasSettings } from "../config/main"; import { photodiodeGhostBox, pdSpotEncode } from "../lib/markup/photodiode"; import { removeCursor } from "../lib/utils"; -import { addData } from "../lib/taskUtils"; import { drawEffort, drawSpike, drawText } from "../lib/drawUtils"; const CANVAS_SIZE = canvasSize; @@ -41,7 +40,7 @@ const costBenefits = (duration, blockSettings, opts, trialDetails) => { trialDetails.high_effort = high_effort; trialDetails.value = value; trialDetails.subtrial_type = "costBenefits"; - addData(trialDetails, blockSettings, opts); + //addData(trialDetails, blockSettings, opts); // add stimulus to the DOM document.getElementById("jspsych-content").innerHTML = stimulus; // $('#jspsych-content').addClass('task-container') @@ -142,7 +141,7 @@ const costBenefits = (duration, blockSettings, opts, trialDetails) => { }; done(returnObj); } - }, 50); + }, 20); function after_response(info) { clearInterval(timer); jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener); @@ -151,7 +150,7 @@ const costBenefits = (duration, blockSettings, opts, trialDetails) => { var timeWhenPressed = new Date().getTime(); var rt = timeWhenPressed - timeWhenStarted; var returnObj = { - rt:rt, + rt: rt, key: info.key, effort: effort[0], value: value[0], @@ -159,24 +158,39 @@ const costBenefits = (duration, blockSettings, opts, trialDetails) => { get_reward: get_reward[0], subtrial_type: "costBenefits", }; - done(returnObj); - } else if (info.key === keys["P"]) { - // 0 key - timeWhenPressed = new Date().getTime(); - rt = timeWhenPressed - timeWhenStarted; - returnObj = { - rt: rt, - key: info.key, - effort: effort[1], - value: value[1], - high_effort: high_effort[1], - get_reward: get_reward[1], - subtrial_type: "costBenefits" - }; - done(returnObj); + var timer1 = setInterval(function () { + var now = new Date().getTime(); + var percTimePassed = (now - timeWhenStarted) / 1000 / (duration / 1000); + + if (percTimePassed >= 1) { + clearInterval(timer1); + done(returnObj); + } + }, 20); + } + else if (info.key === keys["P"]) { + // 0 key + timeWhenPressed = new Date().getTime(); + rt = timeWhenPressed - timeWhenStarted; + returnObj = { + rt: rt, + key: info.key, + effort: effort[1], + value: value[1], + high_effort: high_effort[1], + get_reward: get_reward[1], + subtrial_type: "costBenefits", + }; + var timer2 = setInterval(function () { + var now = new Date().getTime(); + var percTimePassed = (now - timeWhenStarted) / 1000 / (duration / 1000); + if (percTimePassed >= 1) { + clearInterval(timer2); + done(returnObj); + } + }, 50); } } - var keyboardListener = jsPsych.pluginAPI.getKeyboardResponse({ callback_function: after_response, valid_responses: valid_keys,