One interesting thing about interactive questionnaires is the possibility to insert answers as part of the question title or as answer options. Since there are multiple scenarios where an insert may be needed, some of the most commonly used ones are described below.
If you need help adding insertans in places not described in this tutorial, you can ask the IT team.
Create a simple choice question from which the value of the insertan will be taken. This question can have options that allow open text. An example is described below.
This should look like this
Create a new question in a new page after the previous one. It can be any type of question.
Open the Javascript editor, copy and paste the code described below.
function add_insertans(filter, selector) {
response.answers.forEach((answer) => {
var location = document.querySelector(selector);
if (answer.questionCode == filter) {
if (answer.value == "") {
location.textContent = answer.label;
} else {
location.textContent = answer.value;
}
}
});
}
Before saving the code you copied, you need to specify where the text will be added to. As part of the process, you need to identify the type of scenario where you want to add the dynamic text.
Adding an insert as part of the question title
This is the most common use case. The first thing you need to do is to open the question text editor.
A floating window will open, and there you will click on the <> button.
Copy and paste the following code. Make sure to change the id="custom-tag" to a tag with a descriptive name. Change the default text phrase to the text you want to appear in the raw data and finally click the Save button.
<p>
Your tags will be here:
<span id="custom-tag">
Default text
</span>
</p>
Remember to use a different identifier for each new INSERTANS