Editable summaries / overviews of open-ended questions
The aim is to edit the content of all the open-ended questions (not inside a loop), when the interview is finished in CATI or if you want to propose to the respondent to correct his/her data.
Please note that each modification will be applied on the source question.
So if you want to keep previous answers, we strongly recommend to duplicate your questions.
Did you know that when you prefix the shortcut of the question by using "_", you can change the content of the question source?
To help you to summarize the questions, we have created an example in the 📥attached QEX, with two closed questions and two open-ended questions.
Create a chapter and insert the following script:
Using a question shortcut
<div id="question"> !!Qopen1.shortcaption!! </div>
<textarea name="_Qopen1" class="inputopen" aria-label="Text area" >!!Qopen1.InputValue()!! </textarea>
<br/><br /><br />
<div id="question">!!Qopen2.shortcaption!! </div>
<textarea name="_Qopen2" class="inputopen" aria-label="Text area" >!!Qopen2.InputValue()!!</textarea>
<br/><br /><br />
As a result, you will have:
Using question tags
But when you have more than two questions it could be useful to use a generic script.
Here we will use tags to extract a set of questions .
We will iterate on all survey.questions with the tag "OpenSummary".
In our 📥 attached example, we have two questions with this tag ( ??Qopen1?? and ??Qopen2??), so 'arrQuestions.count ' = 2 .
Create a chapter and insert the following script . . .
!! Dim arrQuestions = Survey.Questions.FilterByTag("OpenSummary")
Dim str =""
Dim i
For i = 1 To arrQuestions.Count
If arrQuestions[i].HasNoData = False Then
str = str + "<div id='question'><br /><br />" + arrQuestions[i].shortcut +" - " + arrQuestions[i].shortcaption +"<br /><br /><textarea aria-label='Text area' class='inputopen' name='_"+ arrQuestions[i].shortcut +"'>" + arrQuestions[i].InputValue() + "</textarea></div><br /><br />"
EndIf
Next
return str !!
. . . and you will have
And why not also add some single closed questions into the summary?
Using question tags and question types
We will use the tags to extract a set of questions.
We will iterate on all survey.questions with the tag "Summary".
In our 📥 attached example, we have four questions with this tag (??Q1??, ??Qopen1??, ??Q2?? and ??Qopen2??), so 'arrQuestions.count ' = 4.
Create a chapter and insert the following script . . .
!! Dim arrQuestions = Survey.Questions.FilterByTag("Summary")
Dim i
Dim str=""
Dim strA=""
dim j
dim result=""
Dim isChecked = ""
For i = 1 To arrQuestions.Count
If (arrQuestions[i].HasNoData = False) then
If (arrQuestions[i].Type ="single") Then
strA= "<div id='question'>" + arrQuestions[i].shortcut +" - " + arrQuestions[i].shortcaption +" </br></br><table border='0' align='left'>"
result=""
For j=1 to arrQuestions[i].AvailableResponses.count
isChecked = On(arrQuestions[i].AvailableResponses[j].IsSelected,"checked=\"checked\"","")
result = result + "<tr ><td width='10%'><input type='radio' id='choice("+j+")' name='_"+ arrQuestions[i].shortcut +"' value='"+ arrQuestions[i].AvailableResponses[j].InputValue() + "' " + isChecked + " /><label for='choice("+j+")'>"+ arrQuestions[i].AvailableResponses[j].caption+"</label></td></tr>"
next
str= str + strA + result +"</table></div>"
else
str = str + "<div id='question'>" + arrQuestions[i].shortcut +": <textarea aria-label='Text area' class='inputopen' name='_"+ arrQuestions[i].shortcut+"'>" + arrQuestions[i].InputValue() + "</textarea></div><br /><br />"
endif
EndIf
Next
return str !!
. . . and you will have: