// selecting the stimuli
var first_block = {
type: "html-button-response",
stimulus: createStimulusDisplayHTML(images),
prompt: "Please select your favorite color of these two.",
choices: ['1','2','3']
//on_finish: function(data) {
//var choice = data.button_pressed;
//jsPsych.data.addDataToLastTrial({choice: choice});
//}
};
/* rating selected stimuli
function displaySelectedImage() {
//var t1 = jsPsych.data.getTimelineVariable('choice');
//var t1 = jsPsych.data.get().last(1).values()[1];
var t1 = jsPsych.data.get().filter({trial_type: 'html-button-response',choice: choice})
console.log(t1)
return t1
};
*/
var options = ['Strongly Disagree','Somewhat Disagree','Neither Agree nor Disagree','Somewhat Disagree','Strongly Disagree'];
var ratings = {
type: 'survey-likert',
questions: [{prompt:'<b><i>Extraverted, enthusiastic</i></b>',labels:options}],
preamble: '<p>Please indicate the extent to which you agree each of the following items applies to the image shown below.</p>'+'<p>'+
parseInt(first_block.button_pressed,10)+'<br>'+'</p>'+
'<img src="'+images[parseInt(first_block.button_pressed,10)]+'<br>'+'">'
};
--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/884ae36c-1ad0-44b6-a288-c2c3cf3196b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I think what you want is:jsPsych.data.get().last(1).values()[0].button_pressed;Explainer:jsPsych.data.get() returns the full DataCollection (see https://www.jspsych.org/core_library/jspsych-data/#datacollection)..last(1) filters down to the last trial.values() returns the raw array of data[0] selects the first element of the array (the only trial in the array, since array.length == 1).button_pressed selects the button_pressed property in the object.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+unsubscribe@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/884ae36c-1ad0-44b6-a288-c2c3cf3196b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.