From 3ff6e01b6d2762cb50828cee803046b991aa643c Mon Sep 17 00:00:00 2001 From: Zio-4 Date: Wed, 5 Jun 2024 14:38:26 -0700 Subject: [PATCH] Saving display trials for sds and memory game --- .../src/tasks/math/trials/instructions.js | 2 +- .../src/tasks/math/trials/sliderStimulus.js | 1 - .../memory-game/helpers/getMemoryGameType.js | 7 +++++++ .../src/tasks/memory-game/trials/stimulus.js | 13 ++++++++----- .../trials/stimulus.js | 19 ++++++++----------- .../shared/helpers/fetchAndParseCorpus.js | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 task-launcher/src/tasks/memory-game/helpers/getMemoryGameType.js diff --git a/task-launcher/src/tasks/math/trials/instructions.js b/task-launcher/src/tasks/math/trials/instructions.js index e43bdb4e..f9dcb3da 100644 --- a/task-launcher/src/tasks/math/trials/instructions.js +++ b/task-launcher/src/tasks/math/trials/instructions.js @@ -13,7 +13,7 @@ export const instructions1 = { const t = store.session.get('translations'); return `

${t.instructions}

- +

${t.mathAdultInstructions1}

diff --git a/task-launcher/src/tasks/math/trials/sliderStimulus.js b/task-launcher/src/tasks/math/trials/sliderStimulus.js index 35f47efd..e4b05e39 100644 --- a/task-launcher/src/tasks/math/trials/sliderStimulus.js +++ b/task-launcher/src/tasks/math/trials/sliderStimulus.js @@ -243,6 +243,5 @@ export const slider = { }); setSkipCurrentBlock(stimulus.trialType); - }, }; diff --git a/task-launcher/src/tasks/memory-game/helpers/getMemoryGameType.js b/task-launcher/src/tasks/memory-game/helpers/getMemoryGameType.js new file mode 100644 index 00000000..0465c30a --- /dev/null +++ b/task-launcher/src/tasks/memory-game/helpers/getMemoryGameType.js @@ -0,0 +1,7 @@ +export const getMemoryGameType = (mode, reverse) => { + if (mode === 'input') { + return reverse ? 'backward' : 'forward'; + } else { + return reverse ? 'backward-training' : 'forward-training'; + } +} \ No newline at end of file diff --git a/task-launcher/src/tasks/memory-game/trials/stimulus.js b/task-launcher/src/tasks/memory-game/trials/stimulus.js index 6f965d56..2cc16fdf 100644 --- a/task-launcher/src/tasks/memory-game/trials/stimulus.js +++ b/task-launcher/src/tasks/memory-game/trials/stimulus.js @@ -5,6 +5,7 @@ import { jsPsych } from '../../taskSetup'; import _isEqual from 'lodash/isEqual'; import { finishExperiment } from '../../shared/trials'; import { mediaAssets } from '../../..'; +import { getMemoryGameType } from '../helpers/getMemoryGameType'; const x = 20; @@ -54,18 +55,20 @@ export function getCorsiBlocks({ mode, reverse = false, isPractice = false}) { incorrect_color: () => isPractice ? '#f00' : 'rgba(215, 215, 215, 0.93)', data: { // not camelCase because firekit - save_trial: mode === 'input', + save_trial: true, assessment_stage: 'memory-game', // not for firekit isPracticeTrial: isPractice, }, on_load: () => doOnLoad(mode, isPractice), on_finish: (data) => { + jsPsych.data.addDataToLastTrial({ + correct: _isEqual(data.response, data.sequence), + selectedCoordinates: selectedCoordinates, + corpusTrialType: getMemoryGameType(mode, reverse), + }); + if (mode === 'input') { - jsPsych.data.addDataToLastTrial({ - correct: _isEqual(data.response, data.sequence), - selectedCoordinates: selectedCoordinates - }); store.session.set('currentTrialCorrect', data.correct) if (data.correct && !isPractice) { diff --git a/task-launcher/src/tasks/same-different-selection/trials/stimulus.js b/task-launcher/src/tasks/same-different-selection/trials/stimulus.js index 88482d25..19aa543e 100644 --- a/task-launcher/src/tasks/same-different-selection/trials/stimulus.js +++ b/task-launcher/src/tasks/same-different-selection/trials/stimulus.js @@ -126,16 +126,13 @@ export const stimulus = { correct: isCorrect, }); - // Only save on ss2 since ss1 is a display trial - if (stim.trialType === 'something-same-2' || stim.trialType == 'test-dimensions') { - jsPsych.data.addDataToLastTrial({ - // specific to this trial - item: stim.item, - answer: stim.answer, - distractors: stim.distractors, - corpusTrialType: stim.trialType, - response: choices[data.button_response], - }); - } + jsPsych.data.addDataToLastTrial({ + // specific to this trial + item: stim.item, + answer: stim.answer, + distractors: stim.distractors, + corpusTrialType: stim.trialType, + response: choices[data.button_response], + }); }, }; \ No newline at end of file diff --git a/task-launcher/src/tasks/shared/helpers/fetchAndParseCorpus.js b/task-launcher/src/tasks/shared/helpers/fetchAndParseCorpus.js index 56c2458e..517d81e3 100644 --- a/task-launcher/src/tasks/shared/helpers/fetchAndParseCorpus.js +++ b/task-launcher/src/tasks/shared/helpers/fetchAndParseCorpus.js @@ -42,7 +42,7 @@ const transformCSV = (csvInput, numOfPracticeTrials, sequentialStimulus) => { csvInput.forEach((row) => { // Leaving this here for quick testing of a certain type of trial - // if (!row.trial_type.includes('Fraction')) return; + // if (!row.trial_type.includes('Slider')) return; const newRow = { source: row.source,