In AskiaScript, the questions collection object contains a collection of questions. It is, in effect, an array of questions. You can access
Survey.Questions properties, andCurrentQuestions.You can also create your own collection of questions using the Range() function.
In this topic:
You can access the entire collection of questions through the Survey.Questions properties and the questions available within the page using CurrentQuestions. You can also create your own collection of questions using the Range() function.
Creates a collection of questions which contains all questions from the firstQuestion to the lastQuestion.
Returns the Questions Collection.
Collection with only one question
Dim questions = Range(q1)
questions.Count '=> 1, {q1}
Regular questions within the range
Dim questions = QuestionArray(q1, q5)
questions.Count '=> 5, {q1; q2; q3; q4; q5}
Table loop questions within the range
' qTableLoop is a question inside a question table tableLoop with 3 iterations
Dim questions = Range(qBeforeLoop, qAfterLoop)
questions.Count '=> 6, {
' qBeforeLoop;
' tableLoop;
' qTableLoop.Iteration(1);
' qTableLoop.Iteration(2);
' qTableLoop.Iteration(3);
' qAfterLoop}
Loop with preliminary selection within the range
' qLoopInPreli is a question inside the loop `loopPreli` with preliminary selection
' `loopPreli.Value` is equal to {1;2;3}
Dim questions = Range(qBeforeLoopPreli, qAfterLoopPreli)
questions.Count '=> 6, {
' qBeforeLoopPreli;
' loopPreli;
' qLoopInPreli.Iteration(1);
' qLoopInPreli.Iteration(2);
' qLoopInPreli.Iteration(3);
' qAfterLoopPreli
' }
Loop with iteration count entry within the range
' qLoopInIterCount is a question inside the loop `loopIterCount` with iteration count entry
' `loopIterCount.Value` is equal to {1;2;3} (the user has enter 3)
Dim questions = Range(qBeforeLoopIterCount, qAfterLoopIterCount)
questions.Count '=> 6, {
' qBeforeLoopIterCount;
' loopIterCount;
' qLoopInIterCount.Iteration(1);
' qLoopInIterCount.Iteration(2);
' qLoopInIterCount.Iteration(3);
' qAfterLoopIterCount
' }
Loop with selection at each iteration within the range
' qLoopInSelIter is a question inside the loop `loopSelIter` with selection at each iteration
' `loopSetlIter.Value` is equal to {1;2;3} (the user enter 1, then 2, then 3)
Dim questions = Range(qBeforeLoopSelfIter, qAfterLoopSelIter)
questions.Count '=> 9, {
' qBeforeLoopSelIter;
' loopSelIter;
' qLoopInPreli.Iteration(1);
' qLoopInPreli.Iteration(2);
' qLoopInPreli.Iteration(3);
' qAfterLoopPreli
' }
Question accessor: returns the question at the specified index. This accessor property is used without the dot or period (.), like an array accessor.
Returns a Question.
Dim questions = Range(q1, q10) questions[1] ' => <Question::1#q1> questions[2] ' => <Question::2#q2>
Returns the number of items within the collection.
Returns a Number.
Dim questions = Range(q1, q5) questions.Count ' => 5
Returns the list of errors that occurred during the interview, associated with the questions.
Returns an Array of Errors.
See also: Error
CurrentQuestions.Errors.Count ' => 3
CurrentQuestions.Errors[1].Key ' => "expected_answer"
CurrentQuestions.Errors[1].Message ' => "A response is expected for question 'q1'"
{% If CurrentQuestions.Errors.Count Then %}
<ul class="questions-errors">
{% Dim errIter
For errIter = 1 To CurrentQuestions.Errors.Count
%}
<li>{%= CurrentQuestions.Errors[errITer].Message %}</li>
{% Next %}
</ul>
{% EndIf %}
Produces:
<ul class="questions-errors">
<li>Rank 2 is missing for question `Ranking`</li>
<li>Rank 3 has been given more than once for question `Ranking`</li>
</ul>
Indicates whether there is data in all questions (skipped or not skipped). Returns True if at least one question has no data.
Returns a Boolean
' q1.Value is {1}
' q2.Value is "some text"
' q3.Value is 12
Dim questions = Range(q1, q3)
questions.HasNoData ' => False
' q4.Value is DK ' q5.Value is "hello" ' q6.Value is 12 Dim questions = Range(q4, q6) questions.HasNoData ' => True
Indicates if the answers of the questions are valid for open, numeric and closed questions. This method checks if a value is present, and if that value is compatible with the following criteria:
DK settings for all question types;Returns a Boolean.
' q1.Value is {1}
' q2.Value is "some text"
' q3.Value is 12
Dim questions = Range(q1, q3)
questions.HasValidData ' => True
' q4.Value is {1;2}
' q5.Value is DK ("Don't know is not allowed")
' q6.Value is 12
Dim questions = Range(q4, q6)
questions.HasValidData ' => False
Returns the question shortcut (the name of the variable).
Returns a Array of String.
Demographics.ChildQuestions.Shortcut ' => {"gender";"age";"profession"}
Equivalent to the routing action do not ask.
Skips the questions and does not keep their data; returns the questions for the call chain.
Returns a Collection of Questions.
If age < 18 Then Dim adultQuestions = Range(q10, q20) adultQuestions.Skip() EndIf
Equivalent to the routing action make question invisible.
Skips the questions and keeps their data; returns the questions for the call chain.
Returns a Collection of Questions.
If age < 18 Then Dim adultQuestions = Range(q10, q20) adultQuestions.SkipAndKeepData() EndIf
Return the list of all the questions with the tag provided as string or the list of tags provided as array of string.
Returns a Collection of Questions.
Survey.Questions.FilterByTag("chapter") => 'Return the list of all questions with a tag chapter
Survey.Questions.FilterByTag({"browsable"; "chapter"}) => 'Return the list of all questions with a tag browsable or chapter
Return the list of all the questions with missing answers for mandatory questions.
Returns a Collection of Questions.
Survey.Questions.FilterUnAnswered() => 'Return the list of all questions with missing answers for mandatory questions.
Return the question with the exact shortcut.
Returns a Question.
Survey.Questions.FindByShortcut("gender") => 'Return the gender question.
Returns a string which represents the questions collection (expressed in JSON format).
Returns a String.
' Output in a single line (it's break here for the readability)
dim questions = Range(q1, q2)
questions.ToString()
' => [{
"shortcut":"gender",
"shortCaption":"Respondent gender",
"longCaption":"Are you?",
"type":"single"
},{
"shortcut":"age",
"shortCaption":"Respondent age",
"longCaption":"How old are you?",
"type":"numeric"
}]
Always return "questions".
Returns a String.
CurrentQuestions.TypeOf() ' => "questions"