0 votes
in SoSci Survey (English) by s136449 (140 points)

I am trying to write PHP code so that only items ranked in the top ten will be asked further questions. I only want those questions presented, so I did not do else, just if. I have 27 original options and want only those that are ranked in the top 10 listed on the next page. When I test the questionnaire, I get the following message on the page where I should only see 10 questions "Items of the following question have been used repeatedly on this page. This inevitably results in data loss! If you need the same question more than once, please create a copy of this question." The following items are duplicates.....

Here is a snippet of the code I am trying to use.

if (value('IN02_01') <= 10) {
question('IN06_01');
}
if (value('IN02_02') <= 10) {
question('IN06_02');
}
if (value('IN02_03') <= 10) {
question('IN06_03');
}
if (value('IN02_04') <= 10) {
question('IN06_04');
}
if (value('IN02_05') <= 10) {
question('IN06_05');
}
if (value('IN02_06') <= 10) {
question('IN06_06');
}
if (value('IN02_07') <= 10) {
question('IN06_07');
}
if (value('IN02_08') <= 10) {
question('IN06_08');
}
if (value('IN02_09') <= 10) {
question('IN06_09');
}
if (value('IN02_10') <= 10) {
question('IN06_10');
}
if (value('IN02_11') <= 10) {
question('IN06_11');
}

Thank you, I appreciate your help.

Best

1 Answer

0 votes
by SoSci Survey (305k points)

The question() function expects a question ID (four-character ID) and does not know what to do, if you give it an item ID.

One option would be to specify the item separately:

if (value('IN02_01') <= 10) {
    question('IN06', 1);
}

That, however, will embed the question several times. Therefore, it's more elegant to create an array with those items that you would like to present - roughly following the manual Use Selected Items in Another Question.

Try something like this:

$items = getItems('IN02', '<=', 10);
question('IN06', $items);

Actually, I am not perfectly sure how that code will handle items that were not ranked at all. Because a -1 (missing answer) is also smaller than 10. If they appear in the followup question, we may have to use a little FOR loop instead of getItems().

by s136449 (140 points)
Thank you. I must be PHP challenged because I was not able to get it to work. But you did inspire me to recreate the question in a way that would make it possible to use the built-in filter functions. Thank you!!!
by SoSci Survey (305k points)
If you cannot convince the code to cooperate, just post a new question!

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...