/** * jspsych-survey-slider * a jspsych plugin for free response survey questions * * Josh de Leeuw * * documentation: docs.jspsych.org * */ jsPsych.plugins['survey-slider'] = (function() { var plugin = {}; plugin.info = { name: 'survey-slider', description: '', parameters: { } } plugin.trial = function(display_element, trial) { trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble; trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; // if any trial variables are functions // this evaluates the function and replaces // it with the output of the function trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial); // show preamble text var html = '
'; // add questions for (var i = 0; i < trial.questions.length; i++) { html += ' '; } // add submit button html += ''; display_element.innerHTML = html; display_element.querySelector('#jspsych-survey-slider-next').addEventListener('click', function() { // measure response time var endTime = (new Date()).getTime(); var response_time = endTime - startTime; // create object to hold responses var question_data = {}; var matches = display_element.querySelectorAll('div.jspsych-survey-slider-question'); for(var index=0; index