Skip to content

Commit

Permalink
Merging conflicting files for timeline-RT pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
moblim committed Aug 2, 2021
2 parents 2a4a41c + 1ef8d51 commit cbf3f8d
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 138 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
.DS_Store
.env*
.env

*.vs
npm-debug.log*
yarn-debug.log*
yarn-error.log*

psiturkit/*_turk
.vs/VSWorkspaceState.json
.vs/slnx.sqlite
.vs/Effort-Task-3/v16/.suo
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/config/experiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ exptBlock1.get_reward = [true, true, true, false];
exptBlock1.num_breaks = 3;

// 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];

export { exptBlock1 };
1 change: 1 addition & 0 deletions src/config/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ try {
// then assume it's online in the browser
// with MTurk or Prolific
ONLINE = AT_HOME && !IS_ELECTRON ? true : false;
//ONLINE = true;
console.log("ONLINE:", ONLINE);

// note: it _is_ possible to do both firebase & mturk if desired
Expand Down
2 changes: 1 addition & 1 deletion src/config/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const eventCodes = {
// rewardProbabilityEnd: 11, // reward probability (50% of 100%) offset
frameSpikeStart: 20, // frame and spike onset
// frameSpikeEnd: 21, // frame and spike offset
costBenefitsStart: 30, // points and effort values for both options onset
costBenefitsStart: 30, // points and effort values for both options onset
// costBenefitsEnd: 31, // points and effort values for both options offset
choiceStart: 40, // frame + spike + balloons, when participant can choose blue or green
// choiceEnd: 41, // frame + spike + balloons offset, once participant has made a choice
Expand Down
6 changes: 3 additions & 3 deletions src/language/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
"your_job": "Your job is to <b>pop</b> the balloons by pumping them up to a spike in order to win points!",
"pop_balloon_earn_money": "The points earned from popping a balloon will be shown with a '+' sign in front of it (i.e. <span class='text-large'><b>+1</b></span>).",
"points_to_bonus_conversion": "For every <span class='text-large'><b>20 points</b></span> that you win in the game, you will get <span class='text-large'><b>$1</b></span> at the end of the experiment.",
"cumulative_rewards": "You will be shown the total number of points earned at the end of each trial.",
"cumulative_rewards": "You will be shown the total number of points earned at the end of each trial. *Insert picture here*",
"two_balloons": "There are 2 kinds of balloons: <br><span class='text-green'><b>GREEN</b></span> and <span class='text-blue'><b>BLUE</b></span> balloons.",
"blue_balloon_points": "<span class='text-blue'><b>BLUE</b></span> balloons will <u>pop</u> after you <span class='text-blue'><b>pump 20 times</b></span> and you <span class='text-blue'><b><u>may</u> win 1 point</b></span>.",
"blue_balloon_points": "<span class='text-blue'><b>BLUE</b></span> balloons will <b>always pop</b> after you <span class='text-blue'><b>pump 20 times</b></span> and you <span class='text-blue'><b><u>may</u> win 1 point</b></span>.",
"green_balloon_points": "<span class='text-green'><b>GREEN</b></span> balloons <span class='text-green'><b>may win you more points</b></span>, but will <span class='text-green'><b>require more pumps</b></span>.",
"green_balloon_pop_time": "<span class='text-green'><b>GREEN</b></span> balloons will always pop after <span class='text-green'><b>25 seconds</b></span>.",
"green_balloon_pump_bonus": "If you continue to pump the <span class='text-green'><b>GREEN</b></span> balloon after it hits the spike within the <span class='text-green'><b>25 seconds</b></span> time limit, the bigger the balloon will get and the more <u>bonus</u> points you will earn.<br></br>If you pump the <span class='text-green'><b>GREEN</b></span> balloon and it does not reach the spike within the <span class='text-green'><b>25 seconds</b></span> time limit, you will earn <b>some</b> of the points for pumping the balloon. <br></br>(Example: If the total possible points you can earn for a balloon is 2 points and you pump the balloon halfway to the spike, you will earn 1 point.)<br></br>",
"green_balloon_variable_points_pumps": "For the <span class='text-green'><b>GREEN</b></span> balloon, the number of pumps needed and the number of points you could win <span class='text-green'><b><u>can change on each round</u></b></span>. The number of pumps and points are listed below the <span class='text-green'><b>GREEN</b></span> balloon.",
"blue_balloon_constant_points_pumps": "For the <span class='text-blue'><b>BLUE</b></span> balloon, the potential win <span class='text-blue'><b><u>will always stay the same</u></b></span> (<span class='text-blue'><b>1 point</b></span>),<br>and it will always require <span class='text-blue'><b>20 pumps</b></span>.",
"reward_prob_variable": "For some rounds, the chances that you will win points for either balloon are <b>50%</b> <br>(even after popping the balloon).",
"reward_prob_variable": "For some rounds, the chances that you will win points for either balloon are <b> 50% </b> <br> <u>(even after popping the balloon). </u>",
"reward_prob_certain": "In other rounds the chances of winning will be <b>100%</b>.",
"prob_display_location": "<b>The probability at which you will receive points for a trial will appear at the <u>bottom</u> of the screen.</b>",
"reward_prob_display_event": "The chances of winning points on that round, and the number of points possible to win, will be shown to you while you choose which balloon to inflate.",
Expand Down
18 changes: 9 additions & 9 deletions src/timelines/breakTrial.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/// import trials
// import trials
import { lang } from '../config/main'
import breakScreen from '../trials/breakScreen'
import buildCountdown from '../trials/countdown'

const breakTrial = () => {
const breakTrial = (iBreak) => {

let timeline = [
breakScreen(iBreak),
buildCountdown(lang.countdown.post_break_resume, 3)
]
let timeline = [
breakScreen(iBreak),
buildCountdown(lang.countdown.post_break_resume, 3)
]

return {
type: 'html_keyboard_response',
timeline: timeline
}
type: 'html_keyboard_response',
timeline: timeline
}
}

export default breakTrial
2 changes: 1 addition & 1 deletion src/timelines/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const onlineTimeline = MTURK
: // PROLIFIC VERSION OF THE TASK BELOW:
[
// commented out for now/quick debugging:
// experimentStart(),
experimentStart(),
userId(),
preamble,
bluePracticeInstructions(),
Expand Down
14 changes: 7 additions & 7 deletions src/timelines/taskBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import breakTrial from './breakTrial'
import { generateStartingOpts } from '../lib/taskUtils'

const taskBlock = (blockSettings) => {
// initialize block
// initialize block
const startingOpts = generateStartingOpts(blockSettings)

const blockDetails = {
block_earnings: 0.0,
const blockDetails = {
block_earnings: 0.0,
optimal_earnings: 0.0,
continue_block: true
}

// timeline = loop through trials
let timeline = startingOpts.map( (opt) => taskTrial(blockSettings, blockDetails, opt))
let timeline = startingOpts.map((opt) => taskTrial(blockSettings, blockDetails, opt))

if (blockSettings.num_breaks > 0) {
let breakInterval = Math.floor(timeline.length / (blockSettings.num_breaks + 1))
for (let iBreak = 1; iBreak < blockSettings.num_breaks + 1; iBreak++) {
timeline.splice(iBreak*breakInterval, 0, breakTrial(iBreak))
}
timeline.splice(iBreak * breakInterval, 0, breakTrial(iBreak))
}
}

return {
return {
type: 'html_keyboard_response',
timeline: timeline
}
Expand Down
31 changes: 25 additions & 6 deletions src/timelines/taskTrial.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// import trials

import fixation from "../trials/fixation";
import rewardProbability from "../trials/rewardProbability";
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";
Expand All @@ -26,21 +29,37 @@ const taskTrial = (blockSettings, blockDetails, opts) => {
// show condition
fixation(300),
rewardProbability(1000, blockSettings, opts, trialDetails),
frameSpike(700, blockSettings, opts, trialDetails),
costBenefits(1500, blockSettings, opts, trialDetails),
choice(5000, blockSettings, opts),
//frameSpike(700, blockSettings, opts, trialDetails),
//costBenefits(1500, blockSettings, opts, trialDetails),
choice(6000, blockSettings, opts, trialDetails),
pressBalloon(25000, blockSettings, opts),
fixation(500),
rewardFeedback(1000, blockSettings, opts, trialDetails),
fixation(500),
cumulativeReward(1000, blockSettings, blockDetails, opts, trialDetails),
// end the trial
trialEnd(500),
];
];

let timeline_inlab = [
// show condition
fixation(300),
rewardProbability(1000, blockSettings, opts, trialDetails),
frameSpike(700, blockSettings, opts, trialDetails),
costBenefits(1500, blockSettings, opts, trialDetails),
choice(5000, blockSettings, opts, trialDetails),
pressBalloon(25000, blockSettings, opts),
fixation(500),
rewardFeedback(1000, blockSettings, opts, trialDetails),
fixation(500),
cumulativeReward(1000, blockSettings, blockDetails, opts, trialDetails),
// end the trial
trialEnd(500),
];
return {
type: "html_keyboard_response",
timeline: timeline,
timeline: ONLINE ? timeline : timeline_inlab,
};
};

export default taskTrial;
export default taskTrial;
22 changes: 11 additions & 11 deletions src/trials/breakScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { lang } from "../config/main";
import { baseStimulus } from "../lib/markup/stimuli";

const breakScreen = (iBreak) => {
let stimulus = baseStimulus(
`
let stimulus = baseStimulus(
`
<div class='instructions'>
<h1>${lang.break.prompt}&{iBreak} out of 3
<h1>${lang.break.prompt}${iBreak} out of 3
</div>
`,
true
);
true
);

return {
type: "html_keyboard_response",
stimulus: stimulus,
prompt: lang.break.done,
response_ends_trial: true,
};
return {
type: "html_keyboard_response",
stimulus: stimulus,
prompt: lang.break.done,
response_ends_trial: true,
};
};

export default breakScreen;
16 changes: 14 additions & 2 deletions src/trials/choice.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const canvasHTML = `<canvas width="${CANVAS_SIZE}" height="${CANVAS_SIZE}" id="j
</canvas>`;
const fixationHTML = `<div id="fixation-dot" class="color-white"> </div>`;

const choice = (duration, blockSettings, opts) => {
const choice = (duration, blockSettings, opts, trialDetails) => {
let stimulus =
`<div class="effort-container">` +
canvasHTML +
Expand Down Expand Up @@ -133,7 +133,7 @@ const choice = (duration, blockSettings, opts) => {
canvasSettings.balloonYpos,
canvasSettings.balloonRadius
);
};
};

canvasDraw();
var timer = setInterval(function () {
Expand All @@ -159,7 +159,10 @@ const choice = (duration, blockSettings, opts) => {
jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
if (info.key === keys["Q"]) {
// 1 key
var timeWhenPressed = new Date().getTime();
var rt = timeWhenPressed - timeWhenStarted;
var returnObj = {
rt:rt,
key: info.key,
effort: effort[0],
value: value[0],
Expand All @@ -170,16 +173,25 @@ const choice = (duration, blockSettings, opts) => {
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: "choice",
};
done(returnObj);
}
}
trialDetails.probability = probability;
trialDetails.effort = effort;
trialDetails.high_effort = high_effort;
trialDetails.value = value;
trialDetails.subtrial_type = "choice";

var keyboardListener = jsPsych.pluginAPI.getKeyboardResponse({
callback_function: after_response,
Expand Down
Loading

0 comments on commit cbf3f8d

Please sign in to comment.