Survey text - auto-fill issue and trouble providing feedback #2488
-
Hello! I'm having two issues with survey-text trials. The first issue is I suspect less specific to my code - when I use Chrome to view my experiment, even with an incognito browser, it suggests prior responses that I've typed for auto-replace during survey-text trials, even though I've set "autocomplete" to "false". I've noticed this doesn't happen when I run it with Safari - should I just tell my participants not to use Chrome? The second issue has to do with how I provide feedback on whether the participant's typed entry matches the correct answer. My code is below - I looked at two other discussions on this issue and I wasn't able to fix my problem. It breaks when I reach the end of the survey-text trial, and I believe the issue is specifically with the lines "if (data.response.typed_word.toUpperCase() == data.word)" because when I comment out that if statement and just let tm = false, everything else works fine. Thank you for your help with this! <!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="jspsych-psychophysics-master/js/jspsych.js"></script>
<script src="jspsych-psychophysics-master/js/jspsych-html-keyboard-response.js"></script>
<script src="jspsych-psychophysics-master/js/jspsych-fullscreen.js"></script>
<script src="jspsych-psychophysics-master/js/jspsych-survey-text.js"></script>
<script src="jspsych-psychophysics-master/js/jspsych-html-button-response.js"></script>
<script src="jspsych-psychophysics-master/js/svg.js"></script>
<script src="jsPsych/jspsych.js" type="text/javascript"></script>
<link rel="stylesheet" href="jspsych-psychophysics-master/css/jspsych.css">
</link>
</head>
<body></body>
<script>
var timeline = [];
var iti = 300; // gap between trials - 300 ms
var break_dur = 30000; // break duration (unless they press key to continue) - 30 seconds
var feedback_dur = 1200;
var def_list = [ // This is where the variables that will be iterated through are listed - same trial but different word pair
{
word: 'LIVE', def: 'to exist', comp1: 'die', comp1_rel: 1, comp2: 'clock', comp2_rel: 0, comp3: 'match', comp3_rel: 0,
def_foil1: 'to hold 6 objects', def_foil2: 'to fall from great height', def_foil3: 'to name a newborn baby',
def_foil4: 'to burn accidentally', def_pos1: 0, def_pos2: 2, def_pos3: 1
},
{
word: 'WIN', def: 'to not lose', comp1: 'ripple', comp1_rel: 0, comp2: 'prize', comp2_rel: 1, comp3: 'beat', comp3_rel: 1,
def_foil1: 'to hold 6 objects', def_foil2: 'to fall from great height', def_foil3: 'to name a newborn baby',
def_foil4: 'to burn accidentally', def_pos1: 2, def_pos2: 1, def_pos3: 0
},
{
word: 'CLIMB', def: 'to ascend', comp1: 'banana', comp1_rel: 0, comp2: 'mountain', comp2_rel: 1, comp3: 'wizard', comp3_rel: 0,
def_foil1: 'to hold 6 objects', def_foil2: 'to fall from great height', def_foil3: 'to name a newborn baby',
def_foil4: 'to burn accidentally', def_pos1: 2, def_pos2: 0, def_pos3: 1
},
{
word: 'MESS', def: 'to make unclean', comp1: 'clean', comp1_rel: 1, comp2: 'broom', comp2_rel: 1, comp3: 'dynamite', comp3_rel: 0,
def_foil1: 'to hold 6 objects', def_foil2: 'to fall from great height', def_foil3: 'to name a newborn baby',
def_foil4: 'to burn accidentally', def_pos1: 1, def_pos2: 0, def_pos3: 2
}
];
var bk1_inst = {
type: 'html-button-response',
stimulus: '<p><strong>Section 1 of 9</strong></p>' +
'<p>In this section, you will learn definitions for a set of new words.</p>' +
'<p>For each word, read the word and definition. Then <b>type the word</b> in the text box provided.</p>' +
'<p>(Note that capitalization doesn\'t matter: if you see "TROOFLE" and type "troofle", that\'s fine.)</p>' +
'<p>*</p>' +
'<p>Then you will be presented with a real word (e.g., "bird") and asked to decide whether</p>' +
'<p>this word is or is not related in meaning to the new word.</p>' +
'<p>Related words can be synonyms, antonyms, or otherwise</p>' +
'<p>similar in meaning. Try to be as accurate in these responses as possible.</p>',
choices: ['I\'ve read the instructions, and I\'m ready to start']
}
timeline.push(bk1_inst);
var bk1 = { // this is block 1 - show word and definition, type word, respond "yes" or "no" to whether it's related.
timeline_variables: def_list,
randomize_order: true,
timeline: [
{
type: 'survey-text',
preamble: jsPsych.timelineVariable('word'),
questions: [
{ prompt: jsPsych.timelineVariable('def'), required: true, name: "typed_word" }
],
autocomplete: false,
data: {
word: jsPsych.timelineVariable('word'),
block: "bk1"
},
button_label: 'Submit',
// **Below is the end-of-event function that should record whether typed word matches presented word.
// **The code breaks when I get to this part of the trial.
on_finish: function (data) {
// Score the response as correct or incorrect.
var tm = false;
if (data.response.typed_word.toUpperCase() == data.word) {
tm = true;
}
data.typematch = tm;
}
// ** end of section
},
// **Below is the event where I would provide feedback if typed word didn't match presented word.
// **Only is displayed if typematch was set to false on last event.
{
type: 'html-keyboard-response',
stimulus: "That did not quite match - be careful to type the word correctly!",
trial_duration: function () {
var typed_word_match = jsPsych.data.getLastTrialData().values()[0].typematch;
if (typed_word_match) {
return 0; // feedback is not displayed
} else {
return feedback_dur; // feedback is displayed
}
}
},
// **End of section.
{
type: 'html-button-response',
stimulus: jsPsych.timelineVariable('comp1'),
prompt: '<p>Is this related in meaning to the word you just typed?</p>',
choices: ['No', 'Yes'],
on_finish: function (data) {
// Score the response as correct or incorrect.
if (data.response == jsPsych.timelineVariable('comp1_rel')) {
data.correct = true;
} else {
data.correct = false;
}
},
margin_vertical: '20px'
},
{
type: 'html-keyboard-response',
stimulus: function () {
var is_rel = ["not ", ""];
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if (last_trial_correct) {
return "<p>Correct!</p>"; // the parameter value has to be returned from the function
} else {
return "<p>Incorrect.</p>" + "<p><strong>" + jsPsych.timelineVariable('comp1') + "</strong> is " +
is_rel[jsPsych.timelineVariable('comp1_rel')] + "related in meaning to <strong>" +
jsPsych.timelineVariable('word') + "</strong></p>"; // the parameter value has to be returned from the function
}
},
trial_duration: feedback_dur
}
]
};
timeline.push(bk1)
var debrief1 = { // beginning of actual debrief - what was the experiment about?
type: 'html-button-response',
choices: ['Continue'],
stimulus: "<p>Thank you for participating!</p>" +
"<p>Now we\'ll explain what this study is about... </p>"
}
timeline.push(debrief1);
jsPsych.init({ // this is the code that actually runs the timeline we just built
timeline: timeline,
default_iti: iti
});
</script>
</html> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hi @patiencerosestevens, I'm not sure which version of the |
Beta Was this translation helpful? Give feedback.
Hi @patiencerosestevens, I'm not sure which version of the
survey-text
plugin you're using because you're using files from the jsPsych psychophysics fork. Do you happen to know what jsPsych version those files are based on? I'm wondering if your version of thesurvey-text
plugin doesn't include theautocomplete
parameter. Perhaps you could add a link to your files or to a live version of your experiment?