Skip to content

Commit

Permalink
Merge pull request #121 from levante-framework/sds-memory-saving
Browse files Browse the repository at this point in the history
Saving display trials for sds and memory game
  • Loading branch information
kachergis authored Jun 5, 2024
2 parents cb8abaf + 3ff6e01 commit ed7d959
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion task-launcher/src/tasks/math/trials/instructions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const instructions1 = {
const t = store.session.get('translations');
return `<div class='instructions-container'>
<h1 class='instructions-title'>${t.instructions}</h1>
<p>
${t.mathAdultInstructions1}
</p>
Expand Down
1 change: 0 additions & 1 deletion task-launcher/src/tasks/math/trials/sliderStimulus.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,5 @@ export const slider = {
});

setSkipCurrentBlock(stimulus.trialType);

},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const getMemoryGameType = (mode, reverse) => {
if (mode === 'input') {
return reverse ? 'backward' : 'forward';
} else {
return reverse ? 'backward-training' : 'forward-training';
}
}
13 changes: 8 additions & 5 deletions task-launcher/src/tasks/memory-game/trials/stimulus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ed7d959

Please sign in to comment.