0 votes
in SoSci Survey (dt.) by s142736 (215 points)

Liebes Support-Team,

ich brauche bitte Hilfe bei der Verknüpfung von 2 Bedingungen (aus unterschiedlichen Fragen), die sich später auf die Beantwortung einer Folgefrage auswirken soll.
Ich habe schon alles mit PHP-Code versucht und komme leider nicht zum gewünschten Ergebnis und verzweifle langsam... Ich habe auch schon versucht bei den Einstellungen die Filter je Frage zu setzen, aber sie funktionieren nicht.

Frage C001 erhebt die Auswirkung der COVID-19 Krise auf die Arbeitssituation.
Sie enthält 4 Antwortmöglichkeiten.

Frage TS01 erhebt den aktuellen Trainee Status.

Sofern ein Proband bei der Frage C001 Antwort 1,2 oder 4 angibt UND bei der Frage TS01 Antwort 1 wählt soll in Folge die Frage Frage AA01 angezeigt werden. Wenn die Bedingung nicht erfüllt ist soll die Frage nicht erscheinen.

Anbei noch Screenshots zum leichteren Verständnis.

Bitte um Info, wie der PHP - Code lautet bzw. wo ich diesen einfügen muss.

Danke und beste Grüße!!!!

by SoSci Survey (308k points)
> Ich habe schon alles mit PHP-Code versucht und komme leider nicht zum gewünschten Ergebnis

Bitte ergänzen Sie Ihre Frage um den PHP-Code, soweit Sie gekommen sind.
by s142736 (215 points)
Anbei der PHP Code den ich versucht hatte:

if (
(value('C001') == 1) or
(value('C001') == 2) or
(value('C001') == 3)
and
(value('TS01 ') == 1)
) {
question('AA01'); Auswirkung1
}

Vielen Dank!

1 Answer

0 votes
by SoSci Survey (308k points)
edited by SoSci Survey

Der PHP-Code sieht schon gut aus - es fehlen m.E. nur noch zwei Klammern. Und zwar gilt beim Programmieren AND vor OR (so ähnlich wie beim Rechnen Punkt vor Strich).

Und lautet Ihrer Angabe müsste es 4 und nicht 3 heißen (aber das können Sie ja nach Bedarf anpassen).

if (
  ((value('C001') == 1) or (value('C001') == 2) or (value('C001') == 4))
  and
  (value('TS01 ') == 1)
) {
  question('AA01'); // Auswirkung1
}
by s142736 (215 points)
Super, vielen Dank für die Hilfe.
Leider dürfte es noch nicht ganz passen ;(

There is an error in the PHP code:
Questionnaire Error: Command or string (text) unfinished

A command, e.g. question() is missing a semicolon or
a string (text in quotation marks) is unclosed or
the string itself contains an apostrophe, e.g. html('Let's do it!'); – if the latter is the case, please type in a backslash (\) first.
Perhaps the opening and closing braces for the statement blocks are mismatched.
PHP code

005   and
006   (value('TS01 ') == 1)
007 ) {
008   question('AA01'); Auswirkung1
009 }
010 return 'ok';

008 und 009 ist rot eingefärbt. Woran kann das denn liegen?
by SoSci Survey (308k points)
Hinter dem question('AA01'); fehlten noch zwei Schrägstriche (alternativ kann man die Beschreibung der Frage "Auswirkung1" auch komplett weglassen). Ich habe es oben korrigiert.
by s142736 (215 points)
Danke für die rasche Hilfe!
Leider greift der Filter noch nicht so wie ich möchte, zumindest kommt die Fehlermeldung nicht mehr. Gibt es eine Möglichkeit für Support mittels Screensharing oder sonstiges um dem Fehler auf die Schliche zu kommen?
Ich habe jetzt schon alles soweit versucht und leider funktioniert es noch nicht wie gewünscht ... ;(
by SoSci Survey (308k points)
Bitte starten Sie im Debug-Modus, wählen Sie eine Konstellation, bei der es nicht korrekt funktioniert, und posten Sie hier, was Sie gewählt haben und (!) die Debug-Information.
by s142736 (215 points)
Anbei der Debug:

[Information]    Interview number 174 is to be continued
[Information]    Questionnaire base from project TraineeNet will be used
[Information]    Retention period on page 17 has been 2 seconds
[Processing]    Reading answers from page 16+17
[Information]    Answer to C012 = 2
[Information]    Condition in filter C012/1 is not met.
[Information]    100% of the questions have been answered so far
[Processing]    Create page 18 in questionnaire base
[Information]    In line with filter C012/F1, the element C013 is not displayed.
[Information]    No visible content on this page, continue with page 19
[Processing]    Create page 19 in questionnaire base
[Information]    value("C001") = 1
[Information]    value("TS01 ") = ""
[Content]    Create question AA01

Fehlermeldung: Questionnaire Error (page 19)
Variable TS01 is unknown to this project (see listing of variables). Therefore no result can be retrieved.

Gewählt wurde bei der Frage C001=1 und bei Frage TS01=1.

Sofern ich bei der C001=3 wähle erscheint leider auch die AA01, was ich ja nicht möchte.
[Processing]    Create page 19 in questionnaire base
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Content]    Create question AA01

Danke!
by SoSci Survey (308k points)
> [Information]    value("TS01 ") = ""

> Variable TS01 is unknown to this project (see listing of variables).

Das könnte dürfte daran liegen, dass da noch ein Leerzeichen enthalten ist. Ändern Sie bitte value('TS01 ') nach value('TS01') - ohne Leerzeichen. Ich notiere mit mal, dass SoSci Survey da eine ordentliche Fehlermeldung zeigen soll.

Könnten Sie bitte außerdem aus der "Variablen-Übersicht" kurz kopieren, was dort für TS01 steht? Danke.
by s142736 (215 points)
Hallo, danke für die Antwort an einem Sonntag ;)

Ich habe das Leerzeichen entfernt, der Debug sieht jetzt wie folgt aus:
[Information]    Interview number 179 is to be continued
[Information]    Questionnaire base from project TraineeNet will be used
[Information]    Retention period on page 17 has been 4 seconds
[Processing]    Reading answers from page 17
[Information]    Answer to C012 = 2
[Information]    Condition in filter C012/1 is not met.
[Information]    100% of the questions have been answered so far
[Processing]    Create page 18 in questionnaire base
[Information]    In line with filter C012/F1, the element C013 is not displayed.
[Information]    No visible content on this page, continue with page 19
[Processing]    Create page 19 in questionnaire base
[Information]    value("C001") = 1
[Information]    value("TS01") = 1
[Content]    Create question AA01
[Content]    Create question AA01

Leider wird die Frage jetzt auf der Page 19 doppelt generiert:
Questionnaire Error (page 19)
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: AA01_01, AA01_02.

Anbei die Variablen-Übersicht:

TS01:
Rubrik TS: Trainee Status
[TS01] !Auswahl

Trainee Status

"Bitte nenne uns deinen aktuellen Trainee Status:"

TS01 Trainee Status
1 = Ich bin zurzeit Trainee
2 = Ich bin ehemaliger Trainee
3 = Keines davon
-9 = nicht beantwortet


C001:
[C001] !Auswahl

Covid Arbeit

"Wie wirkt sich die COVID-19 Krise auf deine Arbeitssituation aus?"

C001 Covid Arbeit
1 = Ich arbeite zurzeit von zu Hause aus
2 = Ich arbeite zurzeit vom Büro aus
3 = Ich arbeite zurzeit nicht (befinde mich auf Arbeitssuche)
4 = Ich arbeite zurzeit nicht, befinde mich jedoch in einem aufrechten Dienstverhältnis (Urlaub / Zeitausgleich / Krankenstand)
-9 = nicht beantwortet

merci
by SoSci Survey (308k points)
> [Content]    Create question AA01
> [Content]    Create question AA01
> Leider wird die Frage jetzt auf der Page 19 doppelt generiert:

Vermutlich haben Sie die Frage noch auf die Seite gezogen - entfernen Sie sie von der Seite, sodass sie nur über question() aufgerufen wird.

Vgl. auch Top 3 hier: https://www.soscisurvey.de/help/doku.php/de:create:filter-solving#top_3
by s142736 (215 points)
Sehr gut, danke.

Es dürfte nun alles soweit funktionieren. Letzte Frage noch: Sofern ich den Fragebogen über den grünen/gelben play-button teste, wird ein Warning angezeigt:

Warning (page 20)
The variable AA01 has not been asked on a previous page during this interview. Therefore value() cannot determine any answer, yet.

Wenn ich allerdings die gleichen Optionen in der veröffentlichten Version teste kommt dieses Warning nicht und es sieht alles gut aus. Ist dieser Warnhinweis nur als Info zu verstehen, dass eine gewisse Frage nicht erschienen ist weil eine Condition nicht zugetroffen hat oder liegt noch ein Fehler vor?

Dazu der Debug:
[Information]    Interview number 238 is to be continued
[Information]    Questionnaire base from project TraineeNet will be used
[Information]    Retention period on page 18 has been 1 seconds
[Processing]    Reading answers from page 18
[Information]    Answer to C013_01 = ddd
[Information]    100% of the questions have been answered so far
[Processing]    Create page 19 in questionnaire base
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    No visible content on this page, continue with page 20
[Processing]    Create page 20 in questionnaire base
[Information]    value("AA01") = ???
[Information]    No visible content on this page, continue with page 21
[Processing]    Create page 21 in questionnaire base
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    No visible content on this page, continue with page 22
[Processing]    Create page 22 in questionnaire base
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    value("C001") = 3
[Information]    No visible content on this page, continue with page 23
[Processing]    Create page 23 in questionnaire base
[Content]    Create question D001

Der Warnhinweis steht übrigens auf der Seite wo die demografischen Angaben beginnen.

Besten Dank!
by SoSci Survey (308k points)
> The variable AA01 has not been asked on a previous page during this interview. Therefore value() cannot determine any answer, yet.

Das passiert, wenn auf Seite 19 nichts angezeigt wird. Dann wird AA01 nicht abgefragt - auf Seite 20 scheinen Sie aber die Antwort auf diese Frage in einem Filter zu verwenden.
by s142736 (215 points)
Ja, korrekt.
Die Bedingung für das Anzeigen der Seite 20 setzt voraus, dass die APN auf der Seite 19 die AA01 angezeigt bekommt und mit =1 antwortet. Hier die PHP-Codes:

Seite 19:
if (
  ((value('C001') == 1) or (value('C001') == 2) or (value('C001') == 4))
  and
  (value('TS01') == 1)
) {
  question('AA01'); // Auswirkung1
}

Seite 20:
if (
  ((value('AA01') == 1))
) {
  question('AA02'); // Auswirkung2
}

Sind jetzt noch Anpassungen notwendig?

Danke!
by SoSci Survey (308k points)
Sie können es so lassen, wie es ist - das gelbe Kästchen ist erstmal nur ein Hinweis für Sie, damit nichs übersehen wird.

Oder Sie können beim ersten Filter mit einem `goToPage()` noch dafür sorgen, dass die Seite 20 explizit übersprungen wird. Aber nur, wenn Sie Lust, haben noch etwas mehr mit PHP zu spielen ;)

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

...