Script-Generated Question
Last updated
Last updated
This feature only available in Row Labeling project and disabled by default. Please reach out to support@datasaur.ai if your team needs this feature, and we'll assist you!
Script-Generated Questions is an advanced question type that allows dynamic question generation based on each row’s data. Using TypeScript, users can configure logic that determines which questions should appear for a given row. This flexibility makes it ideal for cases where static question sets are insufficient.
You need dynamic questions that change based on row data.
You want to automate question creation instead of manually defining them.
You require custom logic to determine which questions appear.
You need dropdown options that are generated based on the data in each row.
An identifier is a unique representation of a question. It serves as a reference to the question type, label, and configuration, allowing the script to access and manipulate the question during execution. Before generating questions dynamically, all possible question identifiers must be defined during project creation.
This is configured in the identifiers
part of the script.
Each identifier should have the following attributes:
id
— A unique, zero-indexed integer, signifying the relative order of the questions.
label
— A human-readable string that represents the question.
type
— The question type (i.e. text, multiple choice, date).
Currently, all question types are supported except Grouped Attributes and Script-Generated Questions, with some caveat.
See this for more details on each question type.
config.multiple
— Configuration that allows a question to have multiple answers.
The core function that determines which questions appear is getQuestionsForRow
. This function runs for each row in the dataset, evaluating its data and returning the appropriate questions.
Tip: You can view available row
and columns
attributes in the editor by pressing Ctrl / Cmd + Space.
Here’s how it will look once the project is created.
You can find a sample CSV, as well as the full script to recreate the project below.
We currently don’t support configuring Dropdown or Hierarchical dropdown question types in Script-Generated Questions.
We recommend using Multiple Choice or Single Choice question types, as these also allow users to select from a set of options.
Any Script-Generated Questions will not be saved to the library when the question set is saved.
When configuring the question set in Label Set Management, these questions will not appear in the question type dropdown.
Since question logic relies on a predefined order, it’s not currently possible to configure logic for questions that reference a script-generated one. This is because Script-Generated Questions are created dynamically during the project, which makes it difficult to set conditions for subsequent questions based on them.
What this means is that questions following a script-generated one can still have logic, but they can only reference other question types, not the script-generated question itself.