Overview
This how-to will show you how to set specific answers in multiple selection questions.
Difference between SetAnswer() and dblSetSpecificAnswer()
When dealing with setting answers, there are two main functions for doing that.
1st one is SetAnswer():
This function get’s two parameters:
1st param’: Question index
2nd param’: Array of answer indexes to set
For example:
SetAnswer(3,1);
Will set answer 1 in question 3, whether it’s a single-choice question or a multiple-selection question.
SetAnswer(3,4,6,8);
Will set answer 4,6,8 in question 3 which should be a multiple selection question.
However, if the answer’s which are being set might change during run-time, if you would do this:
SetAnswer(3,4,6,8);
SetAnswer(3,1);
Intuitively you would expect answer 1,4,6,8 to be set – However, only answer 1 will be set, due to the fact that SetAnswer() function, is re-setting the answer’s to Not selected each timed it is being called.
Therefore, there is the function dblSetSpecificAnswer()
This function get’s 3 parameters:
1st param’: Question Index
2nd param’: Answer Index
3rd param’: ‘true’ for selecting, ‘false’ for un-selecting
For example:
dblSetSpecificAnswer(3,4,true);
Will set answer 4 in question 3.
dblSetSpecificAnswer(3,4,false);
Will de-select answer 4 in question 3 (if it was previously chosen).
dblSetSpecificAnswer(3,7,true);
dblSetSpecificAnswer(3,6,true);
Will select answer 7 & 6 in question 3 (Without re-setting previous selections like SetAnswer() does)
As you can see, this function is more useful when needing to modify answer selection without affecting previous selections.
That’s it!
Visit us at: http://www.dooblo.net
Comments
This page is very informative , but without a scripting example is useless. How do you use dblSetSpecificAnswer() in a script?
Please sign in to leave a comment.