0 votes
in SoSci Survey (English) by s112530 (180 points)
edited by SoSci Survey

Hello,

I have the following problem:

In question B010 the user is asked to rank items in a selection. At least one item needs to be ranked to create a "standard" case.

In question B011 I want to present the selection of the selected items in descending order of their selection.

This code is executed on the page displaying B011 (subsequent page to the one with B010):

$itemlist = getItems('B010', 'min', 1); // List of relevant items
arsort($itemlist);
if (count($itemliste)>0) {    
    question('B011', $itemlist);
}

Here is my question: How can I copy the labels of the selected items of question B010 (ranking question) into the according items of the following question B011?

Thank you

1 Answer

0 votes
by SoSci Survey (327k points)

How can I copy the labels of the selected items of question B010 (ranking question) into the according items of the following question B011?

You should not copy anything here at all. It is very important to have the same variables for the same items in both questions - otherwise data analysis will become hell.

If I read you code correctly, the sort order does not yet work. The function getItems() will not return you any values. Please try this one, using valueList():

$data = valueList('B010');
arsort($data);

$items = [];
foreach (array_keys($data) as $key) {
  $itemID = (int)ltrim(substr($varID, 5), "0");
  $items[] = $itemID;
}
question('B011', $items);

The items in B011 should be the same like those in B010, of course.

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

...