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

Hello, I received this strange message error reporting a mistake in the code that I do not have

I am wondering if you could help me.

Thanks in advance,
Best,
Laure.

by SoSci Survey (305k points)
It's quite hard to read in this miniature screenshot. Would you mind to edit your post, and just copy the error message and the PHP code? Thank you.

As far as I see, your PHP code does only define $round if a filter condition is met. If not, the error is probably triggered. But that's only a guess, as I cannot discern all of the code.
by s083051 (140 points)
Hello,

Thank you for your fast answer.
Here is the code:
if ((value('SD06_01') == 2) and (value('SD06_02') == 2)){
question('SD08');
question('SD07');
} else if (value('SD06_02') == 2)  {
question('SD08');
} else {
question('SD07');
}

if ((value('SD02_04') < 25) and (value('SD02_04') > 55)) {redirect(
'https://mingle.respondi.com/s/904217/ospe.php3?c_0002=0&return_tic=%tic%
');}
if ((value ('SD01') == 1) and ((25 < value('SD02_04')) and (value('SD02_04') < 36)))
{$round = urnDraw('womanyoung', 'IV03');}
if ((value ('SD01') == 2) and ((25 < value('SD02_04')) and (value('SD02_04') < 36)))
{$round = urnDraw('manyoung', 'IV03');}
if ((value ('SD01') == 3) and ((35 < value('SD02_04')) and (value('SD02_04') < 46)))
{$round = urnDraw('womanmiddle', 'IV03');}
if ((value ('SD01') == 4) and ((35 < value('SD02_04')) and (value('SD02_04') < 46)))
{$round = urnDraw('manmiddle', 'IV03');}
if ((value ('SD01') == 5) and ((45 < value('SD02_04')) and (value('SD02_04') < 56)))
{$round = urnDraw('womanold', 'IV03');}
if ((value ('SD01') == 6) and ((45 < value('SD02_04')) and (value('SD02_04') < 56)))
{$round = urnDraw('manold', 'IV03');}

if ($round > 2) {redirect(
'https://mingle.respondi.com/s/904217/ospe.php3?c_0002=2&return_tic=%tic%
');}
by s083051 (140 points)
sorry, here is the message error:
Beim Erstellen der Fragebogen-Seite ist ein Fehler aufgetreten. Es wäre sehr freundlich, wenn Sie den Projektleiter über das Problem informieren und die Fehlermeldung unten weiterleiten. Herzlichen Dank.
Im PHP-Code trat ein Fehler auf.

Fehler im Fragebogen: Die PHP-Variable $round wurde verwendet, in diesem PHP-Code aber noch nicht definiert (sie enthält noch keinen Wert).

PHP-Code

026 if ((value ('SD01') == 6) and ((45 < value('SD02_04')) and (value('SD02_04') < 56)))
027 {$round = urnDraw('manold', 'IV03');}
028
029 if ($round > 2) {{
030   redirect(
031 'https://mingle.respondi.com/s/904217/ospe.php3?c_0002=2&return_tic=%tic%
032 ');
by SoSci Survey (305k points)
edited by SoSci Survey
Hmm ... can you also post the debug information from the page with the filter, please: https://www.soscisurvey.de/help/doku.php/de:create:filter-solving#fehler_finden

To explain the issue, I'll need to know the values that SD01 and SD02_04 have, when the filter is run. Just to be sure: These questions are not on the same page as the filter, or are they?
by s083051 (140 points)
Hello, thank you for your quick answer. I am not sure if I understood properly:
But first I defined those variables (at the very beginning of the script, before the "hello":
if (getRoute() == 'start') {
$tic = readGET('return_tic');
put('IV02_01', $tic);
replace('%tic%', 'IV02_01', 'response');
}

Then, I want a filter regarding the age of the participants, so I wrote this:
if ((value('SD02_04') < 25) and (value('SD02_04') > 55)) {redirect(
'https://mingle.respondi.com/s/904217/ospe.php3?c_0002=0&return_tic=%tic%
');}
if ((value ('SD01') == 2) and ((25 < value('SD02_04')) and (value('SD02_04') < 36)))
{$round = urnDraw('womanyoung', 'IV03');}
if ((value ('SD01') == 1) and ((25 < value('SD02_04')) and (value('SD02_04') < 36)))
{$round = urnDraw('manyoung', 'IV03');}
if ((value ('SD01') == 2) and ((35 < value('SD02_04')) and (value('SD02_04') < 46)))
{$round = urnDraw('womanmiddle', 'IV03');}
if ((value ('SD01') == 1) and ((35 < value('SD02_04')) and (value('SD02_04') < 46)))
{$round = urnDraw('manmiddle', 'IV03');}
if ((value ('SD01') == 2) and ((45 < value('SD02_04')) and (value('SD02_04') < 56)))
{$round = urnDraw('womanold', 'IV03');}
if ((value ('SD01') == 1) and ((45 < value('SD02_04')) and (value('SD02_04') < 56)))
{$round = urnDraw('manold', 'IV03');}

if ($round > 25) {redirect(
'https://mingle.respondi.com/s/904217/ospe.php3?c_0002=2&return_tic=%tic%
');}

and if I try to for example enter a man, age: 60, I have the message error I sent to you before.

Is what you needed?

Thanks again for your help.
by s083051 (140 points)
Yes, SD01 is  a question regarding the gender and participants have to respond man or woman.
SO02_04 is the age that the participants have to enter. my script appears on a new page just after those questions.
by SoSci Survey (305k points)
edited by SoSci Survey
What I'd need to actually answer the question, are the values stored in SD01 and SD02_04, when the error occures. This is ehy I asked for the *debug information* (see link above).

What I find in the PHP code is a flaw that could possibly explain the issue: If the age (SD02_04) is 25, then none of the filters will respond. That means that no urnDraw() is triggered, and no value is stored in $round.

If you changed 25 < in line 3 to 25 <=, does the error message still occur?
by s083051 (140 points)
Thank you for your patience, here is the debug info:
https://www.soscisurvey.de/plb/?q=Pilot_LB&admin&debug&page=5&l=ger
by SoSci Survey (305k points)
No, that's the link that allows you (as project adminstrator, nobody else) to access the debug mode :)
by SoSci Survey (305k points)
Did you try the 25 thing above?
by s083051 (140 points)
Hello, sorry,
Yes, I changed the 25 in 24 (to include the 25), but still the message error appears.
regarding the debug info: here is what I have:
"Die Variable SD01 wurde im Laufe dieses Interviews auf keiner vorhergehenden Seite abgefragt. Daher kann die Funktion value() keinen Antwort-Wert ermitteln."

Appearing 6 times, and then the same message error as before.
by SoSci Survey (305k points)
Okay, then we shall first resolve the SD01 issue :)

Please check (a) if there's  a variable SD01, and (b) if that has been asked in the same interview on a previou page. If you test the filter, make sure to start where the questions are asked, not on the filter page.

To resolve this issue, please also follow this manual:
https://www.soscisurvey.de/help/doku.php/en:create:filter-solving
by s083051 (140 points)
Ok, so yes, I have a variable called SD01 (2 answers possible, 1 = man, 2 = woman), and running the debug starting at this page seems ok.
by SoSci Survey (305k points)
This means, everything is okay now? If not (the $round error still appears), please start at SD01, and then post the debug information from the filter page. Thanks.
by s083051 (140 points)
No it still doesn't work, the message error appears after the slide asking the age and gender:

This message appears:

Im PHP-Code trat ein Fehler auf.

Fehler im Fragebogen: Die PHP-Variable $round wurde verwendet, in diesem PHP-Code aber noch nicht definiert (sie enthält noch keinen Wert).

PHP-Code

026 if ((value ('SD01') == 1) and ((45 < value('SD02_04')) and (value('SD02_04') < 56)))
027 {$round = urnDraw('manold', 'IV03');}
028
029 if ($round > 25) {{
030   redirect(
031 'https://mingle.respondi.com/s/904217/ospe.php3?c_0002=2&return_tic=%tic%
032 ');
by SoSci Survey (305k points)
As I wrote (a few times by now), I'll need the debug information (just copy it from the page and post it here) to solve the issue.

> appears after the slide asking the age and gender:

We're talking about the next page, after you clicked "next", right? If it appears on the same page, you'll have to move your PHP code to the next page (it must be on the page *after* the questions SD01/SD02).
by s083051 (140 points)
Here is the debug information from the page with the questions (age and gender):
[Information]    Interview gestartet (neue Nummer 583)
[Information]    Der Fragebogen Pilot_LB im Projekt plb wird verwendet
[Verarbeitung]    Erstelle Fragebogen-Seite Nr. 4
[Inhalt]    Erstelle Frage SD01
[Inhalt]    Erstelle Frage SD02
[Inhalt]    Erstelle Frage SD03
[Inhalt]    Erstelle Frage SD04
[Inhalt]    Erstelle Frage SD05
[Inhalt]    Erstelle Frage SD06
[Inhalt]    Erstelle Frage SD09

And here is the debug information for the following page:

[Information]    Interview Nummer 583 wird fortgesetzt
[Information]    Der Fragebogen Pilot_LB im Projekt plb wird verwendet
[Verarbeitung]    Lese Antworten von Seite 4
[Information]    Die Verweildauer auf Seite 4 war 121 Sekunden
[Information]    Keine Antwort für SD01
[Information]    In der Frage SD01 fehlt eine erforderliche Antwort
[Information]    Keine Antwort für SD02_01
[Information]    Keine Antwort für SD02_02
[Information]    Keine Antwort für SD02_03
[Information]    Keine Antwort für SD02_04
[Information]    In der Frage SD02 fehlt eine erforderliche Antwort
[Information]    Keine Antwort für SD03
[Information]    In der Frage SD03 fehlt eine erforderliche Antwort
[Information]    Keine Antwort für SD04
[Information]    Keine Antwort für SD04_01
[Information]    In der Frage SD04 fehlt eine erforderliche Antwort
[Information]    Keine Antwort für SD05
[Information]    Keine Antwort für SD05_07
[Information]    In der Frage SD05 fehlt eine erforderliche Antwort
[Information]    Antwort auf SD06_01 = 1
[Information]    Keine Antwort für SD06_01a
[Information]    Antwort auf SD06_02 = 1
[Information]    Antwort auf SD06_03 = 1
[Information]    Keine Antwort für SD06_03a
[Information]    Antwort auf SD06_04 = 1
[Information]    Keine Antwort für SD06_04a
[Information]    Antwort auf SD06_05 = 1
[Information]    Keine Antwort für SD06_05a
[Information]    Antwort auf SD06 = 0
[Information]    In der Frage SD06 fehlt eine erforderliche Antwort
[Information]    Keine Antwort für SD09_01
[Information]    Keine Antwort für SD09_02
[Information]    In der Frage SD09 fehlt eine erforderliche Antwort
[Information]    Fragen bisher zu 0% vollständig beantwortet
[Verarbeitung]    Erstelle Fragebogen-Seite Nr. 5
[Information]    value("SD02_04") = ""
[Information]    value("SD02_04") = ""
[Information]    value("SD01") = -9
[Information]    value("SD01") = -9
[Information]    value("SD01") = -9
[Information]    value("SD01") = -9
[Information]    value("SD01") = -9
[Information]    value("SD01") = -9
[Information]    value("SD06_01") = 1
[Information]    value("SD06_02") = 1
[Inhalt]    Erstelle Frage SD07

Yes, the message error appears after I clicked next. the code is at the right place.

1 Answer

0 votes
by SoSci Survey (305k points)

Thanks for the debug information. According to this information, both, the question SD01 and the PHP code are located on page 4.

This won't work, because SoSci Survey will first create the question SD01, then run the PHP-filter (not finding an answer for SD01 so far), and then send this to the respondent. The response to SD01 is not available before page 5.

This is the most common error when creating filters, and easy to solve: Just drag the PHP code to page 5 (at the very beginning of page 5).

To explain the error message: As you have not any answer so far, the function value() gives you a void result or - as you have re-sent the (non-)answer - the errro code -9:

value("SD01") = -9

None of your IF filters will respond to SD01=-9, because they all expect either 1 or 2, which is fine, as you demand a response. This, in turn, means that the PHP variable $round will not be set in any of these IF filters. Therefore, SoSci Survey tells you that $round has not be defined.

by s083051 (140 points)
And, no, the PHP code was already in page 5, right after the page were are asked the gender and the age. I re-created a page, copy paste the code and deleted the previous page. I still have the message error.
by s058368 (110 points)
Lieber Herr Leiner,

ich arbeite in diesem Projekt mit und habe mich ebenfalls mit diesem Problem beschäftigt.

Es scheint so, dass diese Fehlermeldung nur dann auftaucht, wenn eine Person mit unzulässigem Alter den Fragebogen bearbeitet (Alter unter 25 oder über 56). Personen im richtigen Alter (bei denen jeweils die $count-Variablen und die Urnenziehung spezifiziert wurden) können sich normal durchklicken.

Könnte Ihnen diese Information weiterhelfen?

Viele Grüsse,
Brian Cardini
by SoSci Survey (305k points)
Ich hatte gehofft, dass ich die Ursache des Fehlers oben bereits ausführlich dargelegt hätte - inklusive zweitere Änderungen (PHP-Code auf die richtige Seite und korrekter Altersvergleich beim ersten IF), welche es beheben sollten.

Wenn das Problem noch nicht gelöst ist, würde ich Sie bitten, dass Sie eine neue Frage anlegen ("related question", hier wird's langsam unübersichtlich), dort den aktuell verwendeten PHP-Code posten und die Debug-Information der betroffenen Seite. Stellen Sie bitte auch sicher, dass der PHP-Code auf der Seite *nach* der Seite mit SD01 und SD02 steht.
by s058368 (110 points)
Wir haben mittlerweile die Lösung gefunden.

Wir mussten den Code für den Ausschluss von Personen mit einem bestimmten Alter (SD02_04 = Alter in Jahren) anpassen von:

if ((value('SD02_04') <= 24) and (value('SD02_04') >= 56)) {redirect(
'http://mingle.respondi.com/s/904217/ospe.php3?c_0002=0&return_tic=%tic%
');}

zu

if ((value('SD02_04') <= 24) or (value('SD02_04') >= 56)) {redirect(
'http://mingle.respondi.com/s/904217/ospe.php3?c_0002=0&return_tic=%tic%
');}

Viele Grüsse und besten Dank für die schnellen Rückmeldungen,
Brian Cardini

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

...