0 votes
in SoSci Survey (English) by s382148 (110 points)

Project: Jui Mehta Master Thesis Questionnaire

I have a Random Generator question (ID: RG01) with 4 codes:
1 = Branded House
2 = House of Brands
3 = Endorsed Brands
4 = Hybrid Brands

I'm using it to randomly assign respondents to one of four experimental conditions. On the same page as RG01, I placed a PHP code element to branch based on the drawn value:

$grp = value('RG01');
if ($grp == 1) { goToPage('bhstart'); }
elseif ($grp == 2) { goToPage('hobstart'); }
elseif ($grp == 3) { goToPage('ebstart'); }
elseif ($grp == 4) { goToPage('hybstart'); }
pageStop();

This consistently produces the error: "Variable RG01 is unknown to this project (see listing of variables). Therefore no result can be retrieved."

This happens even when:
- Testing from a completely fresh incognito browser session
- Starting the pretest from page 1
- The PHP code sits on the exact same page as RG01, with pageStop() added
- RG01 is confirmed correctly registered in Variables Listing with the correct 4 codes
- There are no draw limits or restrictions under RG01's Management tab
- The PHP code has been manually retyped (not pasted) to rule out formatting issues

I've also tried splitting RG01 and the branching code onto two separate consecutive pages, with the same result.

What could cause value('RG01') to be unavailable even directly on RG01's own page? Is there a project-level setting I might be missing?

1 Answer

0 votes
by s109993 (13.4k points)

Try to put the random generator RG01 one page before the php code, not on the same page.

by SoSci Survey (378k points)
The random generator can be on the same page, but must be located above the PHP code.
by s382148 (110 points)
Thank you for your mail. I have tried everything. The Random Generator is above the php code. i also tried creating a new page after the random generator page and moved the php code to that new page from the old page, but it still didn't work out. Is there something else that I can try or do so that it works error free?
by SoSci Survey (378k points)
Please post the full debug information that the page displays: https://www.soscisurvey.de/help/doku.php/en:create:debugging

Possibly you told the random generator to draw more than 1 code per interview, which would cause different variable names.

Also, I would recommend *not* to work with goToPage(), as is makes thinks complicated. setPageOrder() is often a better option, and the best option is to use a PHP filter with show() or question() to just display the proper content.
by s382148 (110 points)
Thank you for your reply. Fortunately, I was able to identify the problem (I had the wrong name in the php code) and now the issue is resolved. Thank you for your assistance!

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

...