Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions task-launcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class TaskLauncher {

const { taskName } = this.gameParams;
let { language } = this.gameParams;
taskStore('language', language);

// adding this to handle old 'es' variant language param values
if (language === 'es') {
Expand Down
4 changes: 3 additions & 1 deletion task-launcher/src/taskStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export const setTaskStore = (config: TaskStoreDataType) => {
maxIncorrect: config.maxIncorrect,
keyHelpers: config.keyHelpers,
runCat: config.cat,
heavyInstructions: config.heavyInstructions || config.userMetadata.age <= 4,
heavyInstructions:
(config.heavyInstructions || config.userMetadata.age <= 4) &&
(config.language?.toLowerCase().startsWith('en') ?? false),
semThreshold: config.semThreshold,
startingTheta: config.startingTheta,
storeItemId: config.storeItemId,
Expand Down
4 changes: 3 additions & 1 deletion task-launcher/src/tasks/child-survey/helpers/stimulus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export const surveyItem = ({
let responseValue = null;
let responseIndex = null;

const t = taskStore().translations;
const corpus = taskStore().corpus;
const stim = taskStore().nextStimulus;
const itemLayoutConfig: LayoutConfigType = layoutConfigMap?.[stim.itemId];
Expand All @@ -214,7 +215,8 @@ export const surveyItem = ({
audioFile: stim.audioFile,
corpus: corpus,
audioButtonPresses: PageAudioHandler.replayPresses,
correct: false,
correct: false, // false because there is no correct answer
answer: stim.distractors[selectedButtonIndex]
});

// corpusId and itemId fields are used by ROAR but not ROAD
Expand Down
4 changes: 2 additions & 2 deletions task-launcher/src/tasks/matrix-reasoning/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function buildMatrixTimeline(config: Record<string, any>, mediaAs

const layoutConfigMap: Record<string, LayoutConfigType> = {};
let i = 0;
for (const c of fullCorpus) {
for (const c of (heavyInstructions ? fullCorpus : defaultCorpus)) {
const { itemConfig, errorMessages } = getLayoutConfig(c, translations, mediaAssets, i);
layoutConfigMap[c.itemId] = itemConfig;
if (errorMessages.length) {
Expand Down Expand Up @@ -148,7 +148,7 @@ export default function buildMatrixTimeline(config: Record<string, any>, mediaAs
downexInstructions5,
],
conditional_function: () => {
const run = checkFallbackCriteria() && !fellBack && !heavyInstructions;
const run = checkFallbackCriteria() && !fellBack;
if (run) {
fellBack = true;
}
Expand Down
9 changes: 7 additions & 2 deletions task-launcher/src/tasks/memory-game/trials/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ const instructions = instructionData.map((data) => {
// set the display prompt durations here, since awaiting promise during a display trial is not possible in the jsPsych plugin
if (!setPromptDurations) {
setPromptDurations = true;
const displayPromptDurations = {

const displayPromptDurations = taskStore().language === 'en' ?
{
'memoryGameInstruct7Downex': await PageAudioHandler.getAudioDuration(mediaAssets.audio.memoryGameInstruct7Downex),
'memoryGameDisplay': await PageAudioHandler.getAudioDuration(mediaAssets.audio.memoryGameDisplay),
'memoryGameInstruct2Downex': await PageAudioHandler.getAudioDuration(mediaAssets.audio.memoryGameInstruct2Downex),
"memoryGameInstruct4Downex": await PageAudioHandler.getAudioDuration(mediaAssets.audio.memoryGameInstruct4Downex),
}
} :
{
'memoryGameDisplay': await PageAudioHandler.getAudioDuration(mediaAssets.audio.memoryGameDisplay),
}

taskStore('displayPromptDurations', displayPromptDurations);
}
Expand Down
31 changes: 30 additions & 1 deletion task-launcher/src/tasks/mental-rotation/catTimeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
combineMediaAssets,
filterMedia,
prepareMultiBlockCat,
checkFallbackCriteria,
} from '../shared/helpers';
// trials
import {
Expand All @@ -31,6 +32,7 @@ import {
practiceTransition,
setupStimulusFromCurrentCatBlock,
setupNextBlock,
repeatInstructionsMessage,
} from '../shared/trials';
import { getLayoutConfig } from './helpers/config';
import { prepareCorpus } from '../shared/helpers/prepareCat';
Expand Down Expand Up @@ -167,6 +169,27 @@ export default function buildMentalRotationCatTimeline(config: Record<string, an
}
};

const firstBlockPractice: StimulusType[] = corpus.filter((trial) =>
Number(trial.block_index) === 1 && trial.assessmentStage === 'practice_response'
);

let fellBack = false;
const fallbackInstructions = {
timeline: [
repeatInstructionsMessage,
...downexInstructions,
...firstBlockPractice.map((trial) => afcStimulusTemplate(trialConfig, trial)),
],
conditional_function: () => {
const run = checkFallbackCriteria() && !fellBack;
if (run) {
fellBack = true;
}

return run;
},
};

function addInstructionPractice() {
batchedCorpus.forEach((block, index) => {
timeline.push(instructionPracticeBlock(index + 1));
Expand All @@ -184,7 +207,9 @@ export default function buildMentalRotationCatTimeline(config: Record<string, an
addInstructionPractice();

if (index === 0) {
timeline.push(practiceTransition(() => 'mentalRotationInstruct5Downex'));
timeline.push(practiceTransition(
heavyInstructions ? () => 'mentalRotationInstruct5Downex' : undefined,
));

// push in starting block
corpora.start.forEach((trial: StimulusType) => {
Expand All @@ -197,7 +222,11 @@ export default function buildMentalRotationCatTimeline(config: Record<string, an
}

const numOfTrials = block.length / 3;
const fallBackIndex = 4;
for (let i = 0; i < numOfTrials; i++) {
if (i <= fallBackIndex && index === 0) {
timeline.push(fallbackInstructions);
}
timeline.push(stimulusBlock(index));
};

Expand Down
2 changes: 1 addition & 1 deletion task-launcher/src/tasks/mental-rotation/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function buildMentalRotationTimeline(config: Record<string, any>,
return heavyInstructions && taskStore().nextStimulus.trialType === '2D' ? 'mentalRotationInstruct5Downex' : 'generalYourTurn';
}

const numOfTrials = taskStore().totalTrials;
const numOfTrials = corpus.length;
taskStore('totalTestTrials', getRealTrials(corpus));
const numOfInitialPracticeTrials = firstBlockPractice.length;
const fallbackIndex = numOfInitialPracticeTrials + 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export const afcMatch = (trial?: StimulusType) => {
if (
compareSelections([firstSelection, secondSelection], previousSelections, ['number', 'bgcolor'])
) {
console.log(firstSelection, secondSelection);
responseBtns[i].style.animation = 'pulse 2s infinite';
responseBtns[j].style.animation = 'pulse 2s infinite';
animationStarted = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { taskStore } from "../../../taskStore";
import { jsPsych } from "../../taskSetup";

export const checkFallbackCriteria = (filterInputTrials: boolean = false) => {
Expand All @@ -9,6 +10,5 @@ export const checkFallbackCriteria = (filterInputTrials: boolean = false) => {
}

const numIncorrect = incorrectTrials.count();

return numIncorrect >= 2;
return numIncorrect >= 2 && taskStore().language === 'en';
};
4 changes: 2 additions & 2 deletions task-launcher/src/tasks/shared/helpers/prepareCat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function prepareCorpus(
downexCorpus?: StimulusType[],
fillInSdsDifficulty: boolean = false
) {
const excludedTrialTypes = '3D';
const excludedTrialTypes = ['3D', 'polygon'];
// limit random starting items so that their difficulty is less than 0
const maxTrialDifficulty = 0;
const cat: boolean = taskStore().runCat;
Expand Down Expand Up @@ -59,7 +59,7 @@ export function prepareCorpus(
// determine start items
const possibleStartItems: StimulusType[] = normedTrials.filter(
(trial) =>
trial.trialType !== excludedTrialTypes &&
!excludedTrialTypes.includes(trial.trialType) &&
((taskStore().task == 'egma-math' && trial.block_index === 0) || taskStore().task !== 'egma-math') &&
Number(trial.difficulty) <= maxTrialDifficulty,
);
Expand Down
Loading