Array filter

To enable advanced array filtering code 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"
});

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

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    /* Other settings */
    array_filter: {
        
    }
});

array_filter -> filter This variable allows you to the take into account the answer options that were selected in the filter question code to apply the filter process

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    /* Other settings */
    array_filter: {
        filter: "Q0"
    }
});

array_filter -> filter_schema This variable gets the filter's schema that was placed in an open text field.

ℹ️ This is required in order to filter only answer codes that appeared in the filter question. Any remaining code outside filter schema will not be filtered.

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    /* Other settings */
    array_filter: {
        filter: "Q0",
        filter_schema: "Q0xSCHEMA"
    }
});

array_filter -> type Variable that defines the behavior of the filter process. If inclusive, the filter will keep only answer codes that were selected in filter question and are listed in filter's schema. If exclusive, the filter will remove only answer codes that were selected in filter question and are listed in filter's schema.

multiple_choice({
    question_code: "Q1",
    schema: "Q1xSCHEMA",
    /* Other settings */
    array_filter: {
        filter: "Q0",
        filter_schema: "Q0xSCHEMA",
        type: "inclusive"
    }
});

Last updated

Was this helpful?