Randomization

Please note that Survey’s built-in randomization is not compatible with the advanced randomization codes provided in this tutorial. To enable advanced randomization for your multiple choice question, import the library as described in the Getting started section.

Once you have completed the main steps, you will need to modify the parameters in the provided template snippet to apply the changes.

Variable
Example

question_code The code of the multiple choice question you want to configure

multiple_choice({
    question_code: "Q1"
});

schema This variable represents an open text field where answer codes will be stored. It is only required if you plan to use this question to filter or randomize in the same order. Remove it if not needed. πŸ’‘ Use a descriptive name for the schema that indicates it is associated with a specific question code, such as Q1_SCHEMA or Q1xSCHEMA ℹ️ The open text should be placed in the same page of the multiple choice.

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA"
});

randomize

Here we define settings for randomization. If not needed, just remove this entire block code and skip this tutorial πŸ‘

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    randomize: {
        
    }
});

randomize -> filter_schema This variable allows you to randomize answer options in the same order as a previous question by using its schema. ℹ️ If you choose to use this feature, you can skip the rest of the configurations described below this row.

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    randomize: {
        filter_schema: "Q0xSCHEMA",
    }
});

randomize -> answer_groups This variable represents a list of answer codes that you want to group together for randomization. The answer codes should be wrapped inside brackets [] and separated by commas. ℹ️ Any remaining answer codes that are not included in a group will be treated as anchors.

/* Using one group */
multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    randomize: {
        answer_groups: [
            [1, 2]
        ]
    }
});

/* Using multiple groups */
multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    randomize: {
        answer_groups: [
            [1, 2], // group 1
            [3, 4]  // group 2
        ]
    }
});

randomize -> randomize_groups This variable determines whether or not answer groups should be randomized after the elements inside them have been randomized.

If set to true, both the elements within the groups and the groups themselves will be randomized.

If set to false, only the elements within the groups will be randomized.

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    randomize: {
        answer_groups: [[1, 2]],
        randomize_groups: false
    }
});

Last updated

Was this helpful?