From e5cee24668ec408f3cdb27c7a90ec0e999cdb2fe Mon Sep 17 00:00:00 2001 From: YUUU23 Date: Sat, 6 Jul 2024 13:41:03 -0500 Subject: [PATCH 1/2] feat: add getCurrentTrialData form gearshift into utils.js --- src/lib/utils.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/utils.js b/src/lib/utils.js index d5a58392c..2c48b7bd1 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -111,3 +111,12 @@ export function getSeconds(ms) { export function getTimeString(ms) { return `${getMinute(ms)}:${getSeconds(ms).toString().padStart(2, "0")}`; } + +/** + * Retrieves the data object from the current trial in JsPsych + * @param {JsPsych} jsPsych jsPsych instance being used to run the task + * @returns + */ +export function getCurrentTrialData(jsPsych) { + return jsPsych.getCurrentTrial().data; +} From 65462c5b8f29e0a597b26cea1e1251fed031fecd Mon Sep 17 00:00:00 2001 From: Megan <113795130+YUUU23@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:48:03 -0500 Subject: [PATCH 2/2] Update utils.js (fix accidentally deleted comment starts) --- src/lib/utils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index 2789aa73a..03f21db1b 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -113,14 +113,14 @@ export function getTimeString(ms) { } /** - * Retrieves the data object from the current trial in JsPsych * @param {JsPsych} jsPsych jsPsych instance being used to run the task * @returns */ export function getCurrentTrialData(jsPsych) { return jsPsych.getCurrentTrial().data; - +} +/** * Retrieves the data object from the last trial in JsPsych * @param {JsPsych} jsPsych jsPsych instance being used to run the task * @returns {Object} @@ -128,7 +128,8 @@ export function getCurrentTrialData(jsPsych) { export function getLastTrialData(jsPsych) { const dataCollection = jsPsych.data.getLastTrialData(); return dataCollection.trials[0]; - +} +/** * Randomly retrieves a single element from an array * @param {JsPsych} jsPsych The jsPsych instance being used to run the task * @param {Array} array A given array of elements @@ -136,6 +137,4 @@ export function getLastTrialData(jsPsych) { */ export function getRandomElement(jsPsych, array) { return jsPsych.randomization.sampleWithoutReplacement(array, 1)[0]; - - }