diff --git a/src/lib/utils.js b/src/lib/utils.js index d0d3f78a..77f8bee5 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -113,6 +113,15 @@ export function getTimeString(ms) { } /** + + * Retrieves the data object from the last trial in JsPsych + * @param {JsPsych} jsPsych jsPsych instance being used to run the task + * @returns {Object} + */ +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 @@ -120,4 +129,5 @@ export function getTimeString(ms) { */ export function getRandomElement(jsPsych, array) { return jsPsych.randomization.sampleWithoutReplacement(array, 1)[0]; + }