To assist with application building efficiency, we created a feature for use in formbuilder that allows you to add questions via a command bar interface. You can now quickly add questions to your form without having to use your mouse!
How to Use
To open the command bar when in form builder, you can use the following shortcuts:
For Mac: ⌘ + ;
For Windows: Control + ;
Once the command bar is open, you can enter a command and press <Enter> to execute it. Currently there are two command types: Add a New Question and Jump to Question.
Add a Question
To Add a New Question, there are three parts to the input:
This refers to the various question types used in CommCare (i.e. Text, Integer, Date, etc.).
This command will allow you to dictate where the question is placed in the form. There are currently 4 commands:
Before: Used to put a question before another one
After: Used to put a question after another one
In: Used to place a choice in a Multiple Choice or Checkbox question or inside a Group based question (Groups, Repeats or Question list)
First In: Used to place a choice in a Multiple Choice or Checkbox question or inside a Group based question (Groups, Repeats or Question list)
If you do not specify a position the new question will be added after the currently selected question.
Question ID (optional)
This is the question you would like to place the question type near, relevant to the position you input in the second step.
The currently selected question will be used if you do not specify a Question ID.
This section will always start with #.
When entered in the command bar, the format will look like:
<Question Type> <position> #form/<question_id>
Jump to Question
For the Jump to Question command, there is one part to the input: the question path. When entered in the command bar, the format will look like:
Example: Add a New Question
We have a registration form in an application tracking the outcome of a woman’s pregnancy. We want to get information regarding the mother’s age, but forgot to add a question asking it. Let’s do that now.
Using the shortcut (Control + ; for Windows or ⌘ + ; for Mac) will open a command bar at the top of the question tree:
Selecting the bar that states “Enter Command” will open a drop-down window with the various question types you can add to a form:
(Note: This field should be auto-selected after using the shortcut)
Since we want to ask about the mother’s age, we will want to add an integer question. We’ll also want to place the question after the ‘Village Name’ question (question_id = village_name). So, we’ll want to enter the following into the command bar:
Integer after #form/village_name
Once we input this text and hit enter, an Integer based question will be added to formbuilder. Since we used the after position, it will appear after the question, “Village Name”
After adding the question, you should automatically have the new question selected so that you can continue using your keyboard to fill out the Display Text.
Each command will auto-fill so you can use your arrow keys to move up and down the list to select the appropriate question type, position or #form/<question> that you want to select.
Hitting <Tab> will auto-complete the current argument and move the cursor so you can start typing the next argument.
When entering a command, it is not necessary to type out each argument entirely. For example, to add a new label after the current question one can simply type Ctrl+; to open the command bar, then L so Label is the top/selected option in the auto-complete list, then <Enter> to execute the command.
In and First In are used for multiple choice, checkbox or group based questions.
When using Jump to Question it is not necessary to type the exact question path. Instead you can type # followed by part of the question ID or path. For example: Ctrl+; #age <Enter>