Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions task-launcher/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const sequentialStimulus = stringToBoolean(urlParams.get('sequentialStimulus'),
const storeItemId = stringToBoolean(urlParams.get('storeItemId'), false);
const cat = stringToBoolean(urlParams.get('cat'), false);
const heavyInstructions = stringToBoolean(urlParams.get('heavyInstructions'), false);
const debug = stringToBoolean(urlParams.get('debug'), false);

const emulatorConfig = EMULATORS ? firebaseJSON.emulators : undefined;
// if running in demo mode, no data will be saved to Firestore
Expand Down Expand Up @@ -99,6 +100,7 @@ async function startWebApp() {
heavyInstructions,
demoMode,
taskVersion,
debug,
};

const taskInfo = {
Expand Down
18 changes: 18 additions & 0 deletions task-launcher/src/styles/layout/_containers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,21 @@
align-items: center;
gap: 30px;
}

.theta-estimate-container {
position: absolute;
top: 30px;
left: 30px;
flex-direction: column;
justify-content: center;
align-items: center;
width: 30%;
max-height: 50%;
border: 1px solid red;
border-radius: 10px;
background-color: $bg-bubble-base;
color: black;
font-size: 1.5rem;
font-weight: $font-weight-bold;
padding: 10px;
}
3 changes: 3 additions & 0 deletions task-launcher/src/taskStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { InputCapability } from '../utils/detectInput';
* @property {boolean} taskComplete - Whether the task has ended - if true, the user should return to dashboard.
* @property {Object} assetsPerTask - Object containing list of assets belonging to each task.
* @property {boolean} demoMode - Whether the task is running in demo mode (no interaction with Firestore), default is false.
* @property {boolean} debug - Shows theta estimate on the screen for cat debugging when enabled.
* @property {number} currentCatBlock - The current block number to select trials from in a CAT.
* @property {number[]} blockThresholds - Array of theta thresholds.
* @property {number} totalTrialCount - Total number of trials, including practice and instructions.
Expand Down Expand Up @@ -89,6 +90,7 @@ export type TaskStoreDataType = {
language?: string;
maxTime?: number;
demoMode: boolean;
debug: boolean;
taskVersion: number;
currentCatBlock?: number;
blockThresholds?: number[];
Expand Down Expand Up @@ -144,6 +146,7 @@ export const setTaskStore = (config: TaskStoreDataType) => {
testPhase: false,
maxTime: config.maxTime,
demoMode: config.demoMode,
debug: config.debug,
taskVersion: config.taskVersion || 1,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { finishExperiment } from '../../shared/trials';
import { taskStore } from '../../../taskStore';
import { updateTheta } from '../../shared/helpers';
import { sdsProgressComponentFilled, sdsProgressComponentEmpty } from '../../shared/helpers/components';
import { displayDebugInfo } from '../../shared/helpers/displayDebugInfo';

let selectedCards: string[] = [];
let selectedCardIdxs: number[] = [];
Expand Down Expand Up @@ -332,6 +333,8 @@ export const afcMatch = (trial?: StimulusType) => {
}),
);
}

displayDebugInfo(stim);
},
response_ends_trial: () => {
return (trial || taskStore().nextStimulus).trialType === 'instructions' && taskStore().taskVersion === 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { taskStore } from '../../../taskStore';
import { handleStaggeredButtons } from '../../shared/helpers/staggerButtons';
import { updateTheta } from '../../shared/helpers';
import { setNextCatTrial } from '../helpers/setNextCatTrial';
import { displayDebugInfo } from '../../shared/helpers/displayDebugInfo';

const replayButtonHtmlId = 'replay-btn-revisited';
let incorrectPracticeResponses: string[] = [];
Expand Down Expand Up @@ -249,6 +250,8 @@ export const legacyStimulus = (trial?: StimulusType) => {
});
});
}

displayDebugInfo(stimulus);
},
on_finish: (data: any) => {
const stim = trial || taskStore().nextStimulus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { taskStore } from '../../../taskStore';
import { updateTheta } from '../../shared/helpers';
import { setNextCatTrial } from '../helpers/setNextCatTrial';
import { shouldTerminateCat } from '../../shared/helpers/shouldTerminateCat';
import { displayDebugInfo } from '../../shared/helpers/displayDebugInfo';

const replayButtonHtmlId = 'replay-btn-revisited';
let incorrectPracticeResponses: string[] = [];
Expand Down Expand Up @@ -401,6 +402,8 @@ export const stimulus = (trial?: StimulusType) => {
});
});
}

displayDebugInfo(stimulus);
},
on_finish: (data: any) => {
PageAudioHandler.stopAndDisconnectNode();
Expand Down
2 changes: 2 additions & 0 deletions task-launcher/src/tasks/shared/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const setSharedConfig = async (
startingTheta,
demoMode,
taskVersion,
debug,
} = cleanParams;

const config = {
Expand Down Expand Up @@ -125,6 +126,7 @@ export const setSharedConfig = async (
startingTheta: Number(startingTheta),
demoMode: !!demoMode,
taskVersion: Number(taskVersion || 1),
debug: !!debug,
displayPromptDurations: {},
};

Expand Down
34 changes: 34 additions & 0 deletions task-launcher/src/tasks/shared/helpers/displayDebugInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { taskStore } from "../../../taskStore";
import { jsPsych, cat } from "../../taskSetup";

function isRealTrial(trial: any) {
return (
trial.assessment_stage &&
trial.assessment_stage !== 'practice_response' &&
trial.assessment_stage !== 'instructions'
);
}

export function displayDebugInfo(stim: StimulusType) {
if (taskStore().debug && taskStore().runCat) {
const lastRealTrial = jsPsych.data.get().filterCustom(isRealTrial).last().values()[0];
const thetaEstimate = cat.theta;
const currentTrialDifficulty = stim.difficulty;
const CurrentTrialUid = stim.itemUid;

let previousResponse = 'N/A';
if (lastRealTrial?.correct !== undefined) {
previousResponse = lastRealTrial.correct ? 'Correct' : 'Incorrect';
}

const thetaEstimateContainer = document.createElement('div');
thetaEstimateContainer.classList.add('theta-estimate-container');
thetaEstimateContainer.innerHTML = `
<p>Theta estimate: ${thetaEstimate}</p>
<p>Previous response: ${previousResponse}</p>
<p>Current trial difficulty: ${currentTrialDifficulty}</p>
<p>Current trial UID: ${CurrentTrialUid}</p>
`;
document.body.appendChild(thetaEstimateContainer);
}
};
2 changes: 0 additions & 2 deletions task-launcher/src/tasks/shared/helpers/getMediaAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ export async function getMediaAssets(

function isLanguageAndDeviceValid(filePath: string, languageCode: string, taskName: string) {
const parts = filePath.split('/');
console.log('languageCode', languageCode);
console.log('taskName', taskName);

if (parts.length !== 3) {
return false;
Expand Down
10 changes: 9 additions & 1 deletion task-launcher/src/tasks/shared/trials/afcStimulus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For all tasks except: H&F, Memory Game, Same Different Selection
import jsPsychHtmlMultiResponse from '@jspsych-contrib/plugin-html-multi-response';
import _toNumber from 'lodash/toNumber';
import { jsPsych, isTouchScreen } from '../../taskSetup';
import { jsPsych, isTouchScreen, cat } from '../../taskSetup';
import {
arrowKeyEmojis,
replayButtonSvg,
Expand All @@ -20,6 +20,7 @@ import {
import { mediaAssets } from '../../..';
import { finishExperiment } from '.';
import { taskStore } from '../../../taskStore';
import { displayDebugInfo } from '../helpers/displayDebugInfo';

const replayButtonHtmlId = 'replay-btn-revisited';
// Previously chosen responses for current practice trial
Expand Down Expand Up @@ -290,6 +291,9 @@ function doOnLoad(layoutConfigMap: Record<string, LayoutConfigType>, trial?: Sti
}

setupReplayAudio(pageStateHandler);

// display debug info if enabled
displayDebugInfo(stim);
}

function doOnFinish(
Expand All @@ -301,6 +305,10 @@ function doOnFinish(
) {
PageAudioHandler.stopAndDisconnectNode();

if (taskStore().debug) {
document.body.removeChild(document.querySelector('.theta-estimate-container') as Node);
}

// note: nextStimulus is actually the current stimulus
const stimulus = trial || taskStore().nextStimulus;
const itemLayoutConfig = layoutConfigMap?.[stimulus.itemId];
Expand Down
Loading