Page 1 of 1

Rotation of the Statements

Posted: March 16th, 2013, 6:01 am
by Bharadwaj
We are doing a CAPI Survey, in that we have few statements and those needs to be rotated during the survey. How can i rotate them example

Q1 statement 1
q2 statement 2
q3 statement 3
q4 statement 4
q5 statement 5

When we do interview with 1st person, randomly we have to start with any one statement, it need not be from q1. Please let me know if any easy way are there.

Regards

Bharadwaj

Re: Rotation of the Statements

Posted: March 17th, 2013, 10:59 am
by Gregory Martin

Re: Rotation of the Statements

Posted: March 18th, 2013, 4:20 pm
by Bharadwaj
Dear Grogery

Thanks for your response.

I have tried this function but when i am trying to run this getting "CSPro Application has stopped working" message.

I have written the logic as per my requirement, please see whether it is correct or wrong.


PROC GLOBAL
numeric numQuestions = 5;
array questionOrder(5);

array alpha fieldNames(5) = "Q1","Q2","Q3","Q4","Q5";
alpha fieldName;

function gotoQuestion(questionNumber)
fieldName = fieldNames(questionNumber);
move to fieldName;
end;

function nextQuestion()

fieldName = getsymbol();

// see where we are in the list
numeric i;

do i = 1 while 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 = 1 while questionOrder(j) <> i
enddo;

if j = numQuestions then
move to q6; // we are done with the rotating questions

else
gotoQuestion(questionOrder(j + 1));

endif;

end;

function startQuestions()

numeric i,j;

do i = 1 while i <= numQuestions

questionOrder(i) = random(1,numQuestions);

// see if this question has already been inserted
do j = ( i - 1 ) while j > 0 by (-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;

enddo;

gotoQuestion(questionOrder(1));

end;


PROC ROTATION_FF

preproc

seed(systime());

PROC ROTATION_ID

startQuestions();

PROC Q1

nextQuestion();

PROC Q2

nextQuestion();

PROC Q3

nextQuestion();

PROC Q4

nextQuestion();

PROC Q5

nextQuestion();

Re: Rotation of the Statements

Posted: March 30th, 2013, 8:38 pm
by Gregory Martin
Can you post your application here? My sample application works without crashing, so I need to take a look at the modifications that you made.

Re: Rotation of the Statements

Posted: April 18th, 2013, 6:32 am
by Bharadwaj
Dear Gregory

i have mailed the Rotation program to your mail ID. Please check and let me know if any errors i have made. Thanks

Regards

Bharadwaj

Re: Rotation of the Statements

Posted: April 18th, 2013, 10:24 am
by Gregory Martin
If you restore the .dcf extension to your dictionary file, the programs work. See attached.

Re: Rotation of the Statements

Posted: May 29th, 2013, 9:20 am
by Bharadwaj
Thank you very much Gregory for resolving this problem.

Regards

Bharadwaj

Re: Rotation of the Statements

Posted: March 29th, 2015, 12:36 pm
by Tuan
Dear Gregory

I refer to this long time ago topic, the program runs well for random rotation, but for my case, some times I do not want it randomly rotate but just go from 1st to last position. (just go from Q1,Q2,Q3,Q4,Q5). Any help appreciated. I am attaching whole syntax just in case..

""

{Application 'ROTATION' logic file generated by CSPro}
PROC GLOBAL
numeric numQuestions = 5;
array questionOrder(5);

array alpha fieldNames(5) = "Q1","Q2","Q3","Q4","Q5";
alpha fieldName;

function gotoQuestion(questionNumber)
fieldName = fieldNames(questionNumber);
move to fieldName;
end;

function nextQuestion()

fieldName = getsymbol();

// see where we are in the list
numeric i;

do i = 1 while 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 = 1 while questionOrder(j) <> i
enddo;

if j = numQuestions then
move to q6; // we are done with the rotating questions

else
gotoQuestion(questionOrder(j + 1));

endif;

end;

function startQuestions()

numeric i,j;

do i = 1 while i <= numQuestions

questionOrder(i) = random(1,numQuestions);



// see if this question has already been inserted
do j = ( i - 1 ) while j > 0 by (-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;

enddo;

gotoQuestion(questionOrder(1));

end;


PROC ROTATION_FF

preproc

seed(systime());

PROC ROTATION_ID

startQuestions();

PROC Q1

nextQuestion();

PROC Q2

nextQuestion();

PROC Q3

nextQuestion();

PROC Q4

nextQuestion();

PROC Q5

nextQuestion();



""
Tuan