In CSPro there is no simple way to change the order that questions are asked in a data entry application, but it can be done with some logic. The following code is an example of how one can use logic to randomize the order that questions are asked. The code randomizes the order in which five questions, the field names of which are listed in the fieldNames array, are asked.
function gotoQuestion(questionNumber)
fieldName = fieldNames(questionNumber); moveto fieldName; end;
function nextQuestion()
fieldName = getsymbol();
// see where we are in the list numeric i;
do i = 1while fieldNames(i) <> fieldName enddo;
// now i points to what question number we're on // now find out where in the order it is numeric j;
do j = 1while questionOrder(j) <> i enddo;
if j = numQuestions then moveto ANOTHER_QUESTION; // we are done with the rotating questions else
gotoQuestion(questionOrder(j + 1));
endif;
end;
function startQuestions()
numeric i,j;
do i = 1while i <= numQuestions
questionOrder(i) = random(1,numQuestions);
// see if this question has already been inserted do j = ( i - 1 ) while j > 0by (-1) if questionOrder(j) = questionOrder(i) then// the new value is a repeat j = 0; // this will terminate the inner do loop i = i - 1; // this will force the outer do loop to repeat for this value endif; enddo;
I am trying to randomize order of some questions in CSPRO but this is not working. Please can you be more simplify with your codes, I keep receiving buch of errors. Is there anything I must ensure to run the code
I have 3 pair of questions, I want to randomize each pair. in a total I have 6. but each pair is randomized. for example I have Q3A, Q3B, Q4A, Q4B, Q5A, Q5B. when Q3A and Q3B must be randomized together, Q4A and Q4B must also be randomized together and the same goes to Q6A and Q6B.
Please any help will be really apppreciated. Our project is stalked because of this.
I've tried logic to randomize the questions like the example that
in operator controlled mode it works very well, in my case I want to use it in system control mode and that's where the errors come up.
Is there any way to use the aleotorizar logic in system control mode?
I think that you'll have problems with this in system controlled mode. CSPro does not make this task easy.
One other option, assuming that the response options for your questions are the same, is to have a repeating item in the dictionary that you will use to ask several questions. Then, you could modify the CAPI text randomly based on the occurrence of this item. You would also have to save to the data file the order that you asked the questions.
I do not understand very well what he mentions.
so far what I did is duplicate the variables twice to be able to randomize some questions, example
I have my variable P1, P2, P3. I create other variables with the names
ROTAR
P1_TMP1,
P2_TMP1,
P3_TMP1
P1_TMP2,
P2_TMP2,
P3_TMP2
My logic is for variable ROTAR =
PREPROC
if visualvalue ($) = NOTAPPL then
$ = Random (1,13);
ENDIF;
NOINPUT;
My logic for P1_TMP1 =
PREPROC
//******************RANDOM*************
IF ROTAR = 2 THEN SKIP P2_TMP1 ENDIF;
IF ROTAR = 3 THEN SKIP P3_TMP1 ENDIF;
According to the rotation that comes out, it makes the jump in the variables that are repeated TMP and then in the original variables p1, p2 p3 pull the responses of the variables
TMP
Gregory Martin wrote:I think that you'll have problems with this in system controlled mode. CSPro does not make this task easy.
One other option, assuming that the response options for your questions are the same, is to have a repeating item in the dictionary that you will use to ask several questions. Then, you could modify the CAPI text randomly based on the occurrence of this item. You would also have to save to the data file the order that you asked the questions.
Hi Gregory,
Is it possible for you to create an example of one question illustrating how to randomly display the CAPI text in system control mode? I have tried to create some logic that randomizes the CAPI text in question but I don't seem to get it right.
Hi Gregory,
I am trying to do something similar but I need to randomize the order of a group of forms, instead of questions. Should this also work?
thanks
Ines
I believe Greg's solution is meant for operator control mode. However, I would recommend system control for a CAPI application. I don't think there is a perfect solution for randomizing questions/forms.
If I was working on a project where this was a requirement, I would explore splitting the forms into multiple applications. Randomly launching different applications would be straightforward. However, there would be more design/logic overhead with multiple applications.