var jsPsychMaxdiff = (function (jspsych) {
'use strict';
const info = {
name: "maxdiff",
parameters: {
/** Array containing the alternatives to be presented in the maxdiff table. */
alternatives: {
type: jspsych.ParameterType.STRING,
pretty_name: "Alternatives",
array: true,
default: undefined,
},
/** Array containing the labels to display for left and right response columns. */
labels: {
type: jspsych.ParameterType.STRING,
array: true,
pretty_name: "Labels",
default: undefined,
},
/** If true, the order of the alternatives will be randomized. */
randomize_alternative_order: {
type: jspsych.ParameterType.BOOL,
pretty_name: "Randomize Alternative Order",
default: false,
},
/** String to display at top of the page. */
preamble: {
type: jspsych.ParameterType.HTML_STRING,
pretty_name: "Preamble",
default: "",
},
/** Label of the button to submit response. */
button_label: {
type: jspsych.ParameterType.STRING,
pretty_name: "Button Label",
default: "Continue",
},
/** Makes answering the alternative required. */
required: {
type: jspsych.ParameterType.BOOL,
pretty_name: "Required",
default: false,
},
},
};
/**
* **maxdiff**
*
* jsPsych plugin for maxdiff/conjoint analysis designs
*
* @author Angus Hughes
* @see {@link https://www.jspsych.org/plugins/jspsych-maxdiff/ maxdiff plugin documentation on jspsych.org}
*/
class MaxdiffPlugin {
constructor(jsPsych) {
this.jsPsych = jsPsych;
}
trial(display_element, trial) {
var html = "";
// inject CSS for trial
html += '";
// show preamble text
if (trial.preamble !== null) {
html +=
'