diff --git a/.github/workflows/build_firebase.yml b/.github/workflows/build_firebase.yml index 2c43145..e6f60a3 100644 --- a/.github/workflows/build_firebase.yml +++ b/.github/workflows/build_firebase.yml @@ -43,6 +43,8 @@ jobs: run: npm test env: CI: true + REACT_APP_FIREBASE: true + REACT_APP_AT_HOME: true # deploy - name: deploy to firebase diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e835f2..1fee00f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,6 +84,12 @@ jobs: - name: Install PsiTurk if: startsWith(matrix.os, 'ubuntu') run: pip install psiturk + - name: PsiTurk Build + if: startswith(matrix.os, 'ubuntu') + run: npm run build:turk + env: + CI: true + REACT_APP_AT_HOME: true - name: Create Psiturk Build if: startsWith(matrix.os, 'ubuntu') run: | diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml index e84e728..086cb85 100644 --- a/.github/workflows/make-release.yml +++ b/.github/workflows/make-release.yml @@ -89,7 +89,7 @@ jobs: run: npm run build:turk env: CI: true - REACT_APP_AT_HOME: false + REACT_APP_AT_HOME: true REACT_APP_FIREBASE: false REACT_APP_TURK: true - name: Create Psiturk Build diff --git a/package.json b/package.json index 23e73ad..53cf0bb 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,8 @@ "build:win:home": "cross-env REACT_APP_AT_HOME=\"true\" npm run build", "build:win:clinic": "cross-env REACT_APP_AT_HOME=\"true\" npm run build", "build:home": "REACT_APP_AT_HOME=\"true\" npm run build", - "build:turk": "REACT_APP_FIREBASE=\"false\" REACT_APP_AT_HOME=\"false\" REACT_APP_TURK=\"true\" npm run build", - "build:firebase": "REACT_APP_FIREBASE=\"true\" REACT_APP_AT_HOME=\"false\" npm run build" + "build:turk": "REACT_APP_FIREBASE=\"false\" REACT_APP_AT_HOME=\"true\" REACT_APP_TURK=\"true\" npm run build", + "build:firebase": "REACT_APP_FIREBASE=\"true\" REACT_APP_AT_HOME=\"true\" npm run build" }, "eslintConfig": { "extends": "react-app" diff --git a/src/App.js b/src/App.js index afa6c91..a95543a 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,14 @@ import React from "react"; import { Experiment } from "jspsych-react"; import { tl } from "./timelines/main"; -import { MTURK, IS_ELECTRON, FIREBASE, PROLIFIC, AT_HOME } from "./config/main"; +import { + ONLINE, + MTURK, + IS_ELECTRON, + FIREBASE, + PROLIFIC, + AT_HOME, +} from "./config/main"; import "./App.css"; import "bootstrap/dist/css/bootstrap.css"; import "@fortawesome/fontawesome-free/css/all.css"; @@ -23,6 +30,7 @@ if (IS_ELECTRON) { class App extends React.Component { render() { + console.log("Online:", ONLINE); console.log("MTurk:", MTURK); console.log("Firebase:", FIREBASE); console.log("Prolific:", PROLIFIC); @@ -44,6 +52,7 @@ class App extends React.Component { addToFirebase(data); } } + // electron if (ipcRenderer) { ipcRenderer.send("data", data); } else if (psiturk) { diff --git a/src/config/main.js b/src/config/main.js index 5550a55..df832a6 100644 --- a/src/config/main.js +++ b/src/config/main.js @@ -2,6 +2,7 @@ // This is the main configuration file where universal and default settings should be placed. // These settings can then be imported anywhere in the app as they are exported at the botom of the file. +// import { jsPsych } from "jspsych-react"; import _ from "lodash"; import { eventCodes } from "./trigger"; @@ -52,6 +53,7 @@ const keys = { // all the possible environments for the task: const AT_HOME = process.env.REACT_APP_AT_HOME === "true"; const MTURK = process.env.REACT_APP_TURK === "true"; +// const MTURK = !jsPsych.turk.turkInfo().outsideTurk; let IS_ELECTRON = true; let ONLINE = false; let FIREBASE = process.env.REACT_APP_FIREBASE === "true"; @@ -61,17 +63,20 @@ try { window.require("electron"); } catch { IS_ELECTRON = false; +} + +// if AT_HOME and not in-lab/in-clinic EEG electron version, +// then assume it's online in the browser +// with MTurk or Prolific +ONLINE = AT_HOME && !IS_ELECTRON ? true : false; +console.log("ONLINE:", ONLINE); - // if !AT_HOME and not in-lab/in-clinic EEG electron version, - // then assume it's online in the browser - // with MTurk or Prolific - ONLINE = !AT_HOME && !IS_ELECTRON ? true : false; - console.log("ONLINE:", ONLINE); - if (ONLINE) { - PROLIFIC = !MTURK; - if (PROLIFIC) { - FIREBASE = true; - } +// note: it _is_ possible to do both firebase & mturk if desired +// but for now assumine if not mturk then it's prolific and firebase: +if (ONLINE) { + PROLIFIC = !MTURK; + if (PROLIFIC) { + FIREBASE = true; } } @@ -80,6 +85,7 @@ const PHOTODIODE_ON = false; // get language file const lang = require("../language/en_us.json"); +// note: prolific lang is lumped in with en_us.json if (MTURK) { // if this is mturk, merge in the mturk specific language const mlang = require("../language/en_us.mturk.json"); diff --git a/src/language/en_us.mturk.json b/src/language/en_us.mturk.json index 619712e..2e1b213 100644 --- a/src/language/en_us.mturk.json +++ b/src/language/en_us.mturk.json @@ -1,7 +1,4 @@ { - "welcome": { - "message": "Welcome to the NEURO experiment." - }, "userid": { "set": "Setting up user ID." } diff --git a/src/timelines/main.js b/src/timelines/main.js index cf4c9a8..a3af588 100644 --- a/src/timelines/main.js +++ b/src/timelines/main.js @@ -46,6 +46,7 @@ const inLabTimeline = [ experimentEnd(5000), ]; +// online just means not using electron aka in-browser const onlineTimeline = MTURK ? [ experimentStart(), diff --git a/src/trials/showPayment.js b/src/trials/showPayment.js index c2e731b..f9e46ec 100644 --- a/src/trials/showPayment.js +++ b/src/trials/showPayment.js @@ -26,6 +26,7 @@ const showPayment = (duration, blockSettings) => { const value = jsPsych.data.get().select("value").values; const last = value[value.length - 1]; const total_cumulative = last.trial_cumulative_earnings; + total_earnings += total_cumulative / 20; // $1 for every 20 pts trial.stimulus = @@ -58,6 +59,9 @@ const showPayment = (duration, blockSettings) => { const value = jsPsych.data.get().select("value").values; const last = value[value.length - 1]; const total_cumulative = last.trial_cumulative_earnings; + // NOTE TO FUTURE SELF: likely to be changing payment scheme for online + // version, divisor likely to change from 20 to 450 + // to match prev mturk samples total_earnings += total_cumulative / 20; // $1 for every 20 pts trial.stimulus = diff --git a/src/trials/userId.js b/src/trials/userId.js index 77abc28..78112d5 100644 --- a/src/trials/userId.js +++ b/src/trials/userId.js @@ -1,42 +1,40 @@ -import { lang, ONLINE, MTURK, PROLIFIC } from "../config/main"; +import { lang, MTURK, PROLIFIC } from "../config/main"; import { getUserId, getTurkUniqueId, getProlificId } from "../lib/utils"; import { baseStimulus } from "../lib/markup/stimuli"; const userId = () => { - if (ONLINE) { - if (MTURK) { - return { - type: "html_keyboard_response", - stimulus: baseStimulus(`