diff --git a/jspsych.js b/jspsych.js index 447a776b..e9164a6c 100755 --- a/jspsych.js +++ b/jspsych.js @@ -99,7 +99,7 @@ window.jsPsych = (function() { opts.display_element = document.querySelector('body'); } else { // make sure that the display element exists on the page - var display = document.querySelector('#'+opts.display_element); + var display = opts.display_element; if(display === null) { console.error('The display_element specified in jsPsych.init() does not exist in the DOM.'); } else { @@ -186,6 +186,7 @@ window.jsPsych = (function() { }; core.getDisplayElement = function() { + console.log("yo in getDisplayElement", DOM_target); return DOM_target; }; diff --git a/plugins/jspsych-survey-multi-choice.js b/plugins/jspsych-survey-multi-choice.js index 55d680e5..6cd51433 100644 --- a/plugins/jspsych-survey-multi-choice.js +++ b/plugins/jspsych-survey-multi-choice.js @@ -10,7 +10,6 @@ jsPsych.plugins['survey-multi-choice'] = (function() { - var plugin = {}; plugin.info = { @@ -52,9 +51,7 @@ jsPsych.plugins['survey-multi-choice'] = (function() { } } } - plugin.trial = function(display_element, trial) { - var plugin_id_name = "jspsych-survey-multi-choice"; var plugin_id_selector = '#' + plugin_id_name; var _join = function( /*args*/ ) { @@ -85,12 +82,13 @@ jsPsych.plugins['survey-multi-choice'] = (function() { // form element var trial_form_id = _join(plugin_id_name, "form"); - display_element.innerHTML += '
'; + console.log("trial_form_id", trial_form_id) + display_element.innerHTML += ''; var trial_form = display_element.querySelector("#" + trial_form_id); - + console.log("trial_form", trial_form) // show preamble text var preamble_id_name = _join(plugin_id_name, 'preamble'); - trial_form.innerHTML += '' + trial.questions[i] + '
'; @@ -111,66 +109,71 @@ jsPsych.plugins['survey-multi-choice'] = (function() { for (var j = 0; j < trial.options[i].length; j++) { var option_id_name = _join(plugin_id_name, "option", i, j), option_id_selector = '#' + option_id_name; - + // add radio button container display_element.querySelector(question_selector).innerHTML += ''; - + // add label and question text var option_label = ''; display_element.querySelector(option_id_selector).innerHTML += option_label; - + // create radio button var input_id_name = _join(plugin_id_name, 'response', i); display_element.querySelector(option_id_selector + " label").innerHTML = - '' + + '' + display_element.querySelector(option_id_selector + " label").innerHTML; } if (trial.required && trial.required[i]) { // add "question required" asterisk display_element.querySelector(question_selector + " p").innerHMTL += "*"; - + // add required property - display_element.querySelector(question_selector + " input:radio").required = true; + display_element.querySelector(question_selector + " input").required = true; } } - // add submit button trial_form.innerHTML += 'Submit Answers'; - trial_form.attachEventListener('submit', function(event) { - + trial_form.addEventListener('submit', function(event) { event.preventDefault(); - + var matches = display_element.querySelectorAll("div." + plugin_id_name + "-question"); + console.log("are you getting called") // measure response time var endTime = (new Date()).getTime(); var response_time = endTime - startTime; // create object to hold responses var question_data = {}; + //TODO this is having problems var matches = display_element.querySelectorAll("div." + plugin_id_name + "-question"); - for(var index=0; index