mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
added form id in querySelector to plugin-survey-multi-choice
This commit is contained in:
parent
bd3ed55239
commit
df65ce0967
@ -120,10 +120,12 @@ type Info = typeof info;
|
|||||||
class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
|
class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
|
||||||
static info = info;
|
static info = info;
|
||||||
|
|
||||||
constructor(private jsPsych: JsPsych) {}
|
constructor(private jsPsych: JsPsych) { }
|
||||||
|
|
||||||
trial(display_element: HTMLElement, trial: TrialType<Info>) {
|
trial(display_element: HTMLElement, trial: TrialType<Info>) {
|
||||||
var plugin_id_name = "jspsych-survey-multi-choice";
|
|
||||||
|
const plugin_id_name = "jspsych-survey-multi-choice";
|
||||||
|
const trial_form_id = `${plugin_id_name}_form`;
|
||||||
|
|
||||||
var html = "";
|
var html = "";
|
||||||
|
|
||||||
@ -148,9 +150,9 @@ class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
|
|||||||
|
|
||||||
// form element
|
// form element
|
||||||
if (trial.autocomplete) {
|
if (trial.autocomplete) {
|
||||||
html += '<form id="jspsych-survey-multi-choice-form">';
|
html += `<form id="${trial_form_id}">`;
|
||||||
} else {
|
} else {
|
||||||
html += '<form id="jspsych-survey-multi-choice-form" autocomplete="off">';
|
html += `<form id="${trial_form_id}" autocomplete="off">`;
|
||||||
}
|
}
|
||||||
// generate question order. this is randomized here as opposed to randomizing the order of trial.questions
|
// generate question order. this is randomized here as opposed to randomizing the order of trial.questions
|
||||||
// so that the data are always associated with the same question regardless of order
|
// so that the data are always associated with the same question regardless of order
|
||||||
@ -233,7 +235,7 @@ class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
|
|||||||
// render
|
// render
|
||||||
display_element.innerHTML = html;
|
display_element.innerHTML = html;
|
||||||
|
|
||||||
document.querySelector("form").addEventListener("submit", (event) => {
|
document.querySelector(`form#${trial_form_id}`).addEventListener("submit", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// measure response time
|
// measure response time
|
||||||
var endTime = performance.now();
|
var endTime = performance.now();
|
||||||
|
Loading…
Reference in New Issue
Block a user