You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you help me with the code for a simple interactive task?
I want to present participants with a choice between two pictures:
Depending on which picture they choose, they will presented with text A or B.
The text that participants are presented with should be paired with a picture that is chosen randomly from a seperate list.
It is important that participants can input text while attending the paired text and picture.
The process is iterated over multiple trials.
What I got so far is pasted below. Obviously I don't have a list with pictures that are sampled (I will sample without replacement). If you include an example list I can probably work it out from there.
What I want to do is basically present my chosen picture together with what I got in my variable "trialtest" as the returned content in the variable "testfeedback".
var test = {
type: jsPsychHtmlKeyboardResponse,
stimulus:`
<div style='width: 700px;'>
<div style='float: left;'><img src='stimuli_img/DESCRIBE.jpg'></img>
<p class='small'><strong>Press the A key for option "DESCRIBE"</strong></p></div>
<div style='float: right;'><img src='stimuli_img/FEEL.jpg'</img>
<p class='small'><strong>Press the K key for option "FEEL"</strong></p></div>
`,
choices: ['a','k'],
on_finish: function(data){
// Score the response as correct or incorrect.
if(jsPsych.pluginAPI.compareKeys(data.response, "k")){
data.correct = true;
} else {
data.correct = false;
}
}
}
var testfeedback = {
type: jsPsychHtmlKeyboardResponse,
stimulus: function(){
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if(last_trial_correct){
return "FEEL"; // the parameter value has to be returned from the function
} else {
return "DESCRIBE"; // the parameter value has to be returned from the function
}
}
}
var trialtest = {
type: jsPsychSurveyText,
preamble: `<img src="stimuli/CFD-BF-037-013-A.jpg" style="width:400px;"></img>`,
questions: [
{prompt: 'How old are you?',
required: true,
rows: 5,
columns: 30
},
]
}
timeline.push(test, testfeedback,trialtest);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Could you help me with the code for a simple interactive task?
I want to present participants with a choice between two pictures:
Depending on which picture they choose, they will presented with text A or B.
The text that participants are presented with should be paired with a picture that is chosen randomly from a seperate list.
It is important that participants can input text while attending the paired text and picture.
The process is iterated over multiple trials.
What I got so far is pasted below. Obviously I don't have a list with pictures that are sampled (I will sample without replacement). If you include an example list I can probably work it out from there.
What I want to do is basically present my chosen picture together with what I got in my variable "trialtest" as the returned content in the variable "testfeedback".
Someone's got any ideas?
Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions