/** * jspsych-survey-text * a jspsych plugin for free response survey questions * * Josh de Leeuw * * documentation: https://github.com/jodeleeuw/jsPsych/wiki/jspsych-survey-text * */ (function($) { jsPsych['survey-text'] = (function() { var plugin = {}; plugin.create = function(params) { params = jsPsych.pluginAPI.enforceArray(params, ['data']); var trials = []; for (var i = 0; i < params.questions.length; i++) { trials.push({ questions: params.questions[i] }); } return trials; }; plugin.trial = function(display_element, trial) { // if any trial variables are functions // this evaluates the function and replaces // it with the output of the function trial = jsPsych.pluginAPI.normalizeTrialVariables(trial); // add likert scale questions for (var i = 0; i < trial.questions.length; i++) { // create div display_element.append($('
', { "id": 'jspsych-survey-text-' + i, "class": 'jspsych-survey-text-question' })); // add question text $("#jspsych-survey-text-" + i).append('

' + trial.questions[i] + '

'); // add text box $("#jspsych-survey-text-" + i).append(''); } // add submit button display_element.append($('