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
Will set answer 1 in question 3, whether it’s a single-choice question or a multiple-selection question.
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:
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
Will set answer 4 in question 3.
Will de-select answer 4 in question 3 (if it was previously chosen).
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.
Visit us at: http://www.dooblo.net