From 1a3ca8cc69b375c0e31f285fa674330c19d59a54 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 28 Feb 2014 17:07:07 -0500 Subject: [PATCH] Add option to return flattened data object Related to issue #31 because it moves a utility function into the core library. --- jspsych.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jspsych.js b/jspsych.js index 93acbe86..55e33b14 100755 --- a/jspsych.js +++ b/jspsych.js @@ -83,12 +83,19 @@ // core.data returns all of the data objects for each block as an array // where core.data[0] = data object from block 0, etc... + // if flatten is true, then the hierarchical structure of the data + // is removed and each array entry will be a single trial. - core.data = function() { + core.data = function(flatten) { var all_data = []; for (var i = 0; i < exp_blocks.length; i++) { all_data[i] = exp_blocks[i].data; } + + if(flatten===true){ + all_data = flattenData(all_data); + } + return all_data; };