Skip to content

Commit

Permalink
Merge pull request #143 from lnccbrown/feat-end-of-practice-event-code
Browse files Browse the repository at this point in the history
feat: practice & main block divider event code; feat: display task version on task title (1st) screen
  • Loading branch information
wasita authored Nov 24, 2020
2 parents 433aed1 + ca46b86 commit f2aad7d
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "task-effort",
"description": "all-in-one app with jsPsych + React + Electron + psiturk",
"name": "effort-v1.3.2",
"description": "all-in-one app with jsPsych + React + Electron + psiTurk",
"author": {
"name": "Wasita Mahaphanit & Rashi Dhar (Brown CCV)",
"name": "Wasita Mahaphanit (Brown) & Rashi Dhar (Brown CCV)",
"email": "[email protected]",
"url": "https://lnccbrown.com"
},
"version": "1.3.1",
"version": "1.3.2",
"license": "MIT",
"private": true,
"main": "public/electron.js",
Expand Down
21 changes: 11 additions & 10 deletions public/config/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ const comName = "COM7";

// NOTE - these event codes must match what is in src/config/trigger.js
const eventCodes = {
practiceAndMainBlockDivider: 250,
fixationStart: 1, // this is fixation dot onset
fixationEnd: 2, // this is fixation dot offset
// fixationEnd: 2, // this is fixation dot offset
rewardProbabilityStart: 10, // reward probability (50% or 100%) onset
rewardProbabilityEnd: 11, // reward probability (50% of 100%) offset
// rewardProbabilityEnd: 11, // reward probability (50% of 100%) offset
frameSpikeStart: 20, // frame and spike onset
frameSpikeEnd: 21, // frame and spike offset
// frameSpikeEnd: 21, // frame and spike offset
costBenefitsStart: 30, // points and effort values for both options onset
costBenefitsEnd: 31, // points and effort values for both options offset
// 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
// choiceEnd: 41, // frame + spike + balloons offset, once participant has made a choice
pressBalloonStart: 50, // once participant is able to pump the balloon by pressing a key
pressBalloonEnd: 51, // once the balloon has popped (once 25 secs from pressBalloonStart is over)
// pressBalloonEnd: 51, // once the balloon has popped (once 25 secs from pressBalloonStart is over)
cumulativeRewardsStart: 60, // total points earned thus far onset
cumulativeRewardsEnd: 61, // total points earned thus far offse
// cumulativeRewardsEnd: 61, // total points earned thus far offse
rewardFeedbackStart: 70, // trial reward feedback onset
rewardFeedbackEnd: 71, // trial reward feedback offset
// rewardFeedbackEnd: 71, // trial reward feedback offset
showPaymentStart: 80, // end of task earnings screen onset
showPaymentEnd: 81, // end of task earnings screen offset
// showPaymentEnd: 81, // end of task earnings screen offset
trialFinishStart: 90, // marks when trial starts (fixation onset) -- currently NOT in use
trialFinishEnd: 91, // marks when trial ends (reward feedback offset)
// trialFinishEnd: 91, // marks when trial ends (reward feedback offset)
test_connect: 4,
open_task: 5, // when the app is opened, send this code
};
Expand Down
21 changes: 11 additions & 10 deletions src/config/trigger.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
// NOTE - these event codes must match what is in public/config/trigger.js
const eventCodes = {
practiceAndMainBlockDivider: 250,
fixationStart: 1, // this is fixation dot onset
fixationEnd: 2, // this is fixation dot offset
// fixationEnd: 2, // this is fixation dot offset
rewardProbabilityStart: 10, // reward probability (50% or 100%) onset
rewardProbabilityEnd: 11, // reward probability (50% of 100%) offset
// rewardProbabilityEnd: 11, // reward probability (50% of 100%) offset
frameSpikeStart: 20, // frame and spike onset
frameSpikeEnd: 21, // frame and spike offset
// frameSpikeEnd: 21, // frame and spike offset
costBenefitsStart: 30, // points and effort values for both options onset
costBenefitsEnd: 31, // points and effort values for both options offset
// 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
// choiceEnd: 41, // frame + spike + balloons offset, once participant has made a choice
pressBalloonStart: 50, // once participant is able to pump the balloon by pressing a key
pressBalloonEnd: 51, // once the balloon has popped (once 25 secs from pressBalloonStart is over)
// pressBalloonEnd: 51, // once the balloon has popped (once 25 secs from pressBalloonStart is over)
cumulativeRewardsStart: 60, // total points earned thus far onset
cumulativeRewardsEnd: 61, // total points earned thus far offse
// cumulativeRewardsEnd: 61, // total points earned thus far offse
rewardFeedbackStart: 70, // trial reward feedback onset
rewardFeedbackEnd: 71, // trial reward feedback offset
// rewardFeedbackEnd: 71, // trial reward feedback offset
showPaymentStart: 80, // end of task earnings screen onset
showPaymentEnd: 81, // end of task earnings screen offset
// showPaymentEnd: 81, // end of task earnings screen offset
trialFinishStart: 90, // marks when trial starts (fixation onset) -- currently NOT in use
trialFinishEnd: 91, // marks when trial ends (reward feedback offset)
// trialFinishEnd: 91, // marks when trial ends (reward feedback offset)
test_connect: 4,
open_task: 5, // when the app is opened, send this code
};
Expand Down
3 changes: 2 additions & 1 deletion src/language/en_us.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"task": {
"name": "Effort Task",
"end": "This experiment has ended."
"end": "This experiment has ended.",
"version": "v1.3.2"
},
"prompt": {
"continue": {
Expand Down
2 changes: 2 additions & 0 deletions src/timelines/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import buildCountdown from "../trials/countdown";
import preamble from "./preamble";
import experimentStart from "../trials/experimentStart";
import experimentEnd from "../trials/experimentEnd";
import practiceAndMainBlockDivider from "../trials/practiceAndMainBlockDivider";
import taskBlock from "./taskBlock";
import showPayment from "../trials/showPayment";
import redirectToProlific from "../trials/redirectToProlific";
Expand Down Expand Up @@ -41,6 +42,7 @@ const inLabTimeline = [
recordNow(),
postPracticeInstructions(),
buildCountdown(lang.countdown.expt1, 3),
practiceAndMainBlockDivider(500),
taskBlock(exptBlock1),
showPayment(5000, exptBlock1),
experimentEnd(5000),
Expand Down
3 changes: 1 addition & 2 deletions src/trials/experimentStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { baseStimulus } from "../lib/markup/stimuli";

const experimentStart = () => {
let stimulus =
baseStimulus(`<h1>${lang.task.name}</h1>`, true) + photodiodeGhostBox();

baseStimulus(`<h1>${lang.task.name}<br>${lang.task.version}</h1>`, true) + photodiodeGhostBox()
return {
type: "html_button_response",
stimulus: stimulus,
Expand Down
26 changes: 26 additions & 0 deletions src/trials/practiceAndMainBlockDivider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { eventCodes } from "../config/main";
import { jitter50, removeCursor } from "../lib/utils";
import { pdSpotEncode } from "../lib/markup/photodiode";
import { jsPsych } from "jspsych-react";

const practiceAndMainBlockDivider = (duration) => {

const startCode = eventCodes.practiceAndMainBlockDivider;

return {
type: "html_keyboard_response",
choices: jsPsych.NO_KEYS,
stimulus: '',
response_ends_trial: false,
trial_duration: jitter50(duration),
on_load: () => {
removeCursor("experiment");
pdSpotEncode(startCode);
},
on_finish: (data) => {
data.code = startCode;
},
};
};

export default practiceAndMainBlockDivider;

0 comments on commit f2aad7d

Please sign in to comment.