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

0 votes

Dear SoSci Support,

Two years ago I programmed a questionnaire flow in which multiple questions with multiple items are evaluated in a loop. However, with recent changes in PHP permissions at your end my flow no longer works.

Here's how the setup looked like:

I would define an array of questions:

$Qests= array('I103', 'I104', 'I105', 'I106', 'I107');

And than loop through each question and each item of the question like this:

foreach($Qests as $curQuest){ $wrong=0; foreach(${$curQuest} as $curItem){ if (value($curItem) == 1){ $wrong=$wrong+1; }; }; };

Now this no longer works, as I am not permitted to use ${$curQuest} to loop through the list of items. I get an error:

Warning: The PHP keyword ${ is not allowed within PHP code.

Warning: The PHP code contains functions or PHP elements that you are
not permitted to use in the questionnaire. If you think that the
constructs in question are safe to use, please contact the

Could you please let me know how to implement the loop using the new PHP syntax permission rules?

Thank you so much!

Best wishes,

in SoSci Survey (English) by s046461 (125 points)

1 Answer

+1 vote

I assume, you had defined arrays with the names $I103 etc. in your PHP code as well? Otherwise, the above code will not work at all.

But the best thing is: You don't actually need the arrays. The function getItems() in combination with id() will provide you with the necessary information.

$Qests= array('I103', 'I104', 'I105', 'I106', 'I107');
foreach ($Qests as $curQuest) {
  foreach (getItems($curQuest, 'all') as $curItem) {
    if (value(id($curQuest, $curItem)) == 1) {
      $wrong = $wrong + 1;

Please also note that the variable $wrong is set to zero for every quetion in your code. This is probably not what was intended. I assume, it was meant to be placed before the first foreach.

by SoSci Survey (63.5k points)
Thank you very much, that is exactly what I needed!