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
Rotation of the Statements
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Rotation of the Statements
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();
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();
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Rotation of the Statements
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
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
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
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Rotation of the Statements
If you restore the .dcf extension to your dictionary file, the programs work. See attached.
- Attachments
-
- Rotation syntax.zip
- (2.65 KiB) Downloaded 545 times
Re: Rotation of the Statements
Thank you very much Gregory for resolving this problem.
Regards
Bharadwaj
Regards
Bharadwaj
Re: Rotation of the Statements
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
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