0 votes
in SoSci Survey (English) by s210296 (270 points)

I would like to include a plausibility check, namely

if value X and value Y are selected
then show an error message with the following text "......".
after the user has clicked on continue

Can anyone help me with this?

I would be very happy :-)

VG Verena

1 Answer

0 votes
by s109993 (12.0k points)
edited by s109993

Hi Verena, you can use a little php code and repeatpage() to program a plausibility check. You can find the information here: https://www.soscisurvey.de/help/doku.php/en:create:functions:repeatpage

If you have a problem with the php code, let me know.

Best regards

Edit:
try the following code- you have first to create the element 'error' as described in the link above. It is the error message which will be shown, if the two conditions are met,

if ((value('RV09_01')  == 4) and (value('RV09_01')  == 4)) {

repeatPage('error');

}

you can create the text element here:

Select "new textelement (Textbaustein) to get there.

by s210296 (270 points)
Hi, Thanks for your quick response.

Unfortunately I did not right PHP code.

I would like to implement following logic

If RV09_01 = 4 and RV09_02 = 4 ---> selected
then show an error message with the following text "......".
after the user has clicked on continue

Can you pls help me.
Looking forward to hearing form you


FYI

RV09_01 - work form home
RV09_02 - work in the office

1 = 0 %
2 = weniger als 50 %
3 = mehr als 50 %
4 = 100 %
-9 = nicht beantwortet
by s109993 (12.0k points)
I added the code in my first answer
by s210296 (270 points)
Hi, thx you very much for sending the code.
Unfortunately the code is not working

I have entered
if((value('RB01_01')==4) and (value('RB01_02')==4))
{
    repeatPage('error')
    
}

in PHP code element of the page

but I get following errors
 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

002
003 if((value('RB01_01')==4) and (value('RB01_02')==4))
004 {
005     repeatPage('error')
006     
007 }
008 return 'ok';

Can you help me?

Best Regards Verena
by s109993 (12.0k points)
sorry, there is a ; missing behind  repeatPage('error');

Also make sure that the code is place at the page AFTER the question and NOT at the same page as the question.

Also: "error" is not a text but the id of an text element which you have to create (not sure if you have done that, so I just mention it one more time - just in case :)
by s210296 (270 points)
edited by s210296
Now I have added ";" plus have added the code after the page

Now I get following error:
There is no text with the ID summe in this survey project.

Where can I add the text?

Can you help me with that?

Best Regards Verena
by s109993 (12.0k points)
I added an imgae where you can add the textelement. You of course have to add a text there as well.
by s210296 (270 points)
It works :-)
Many thx

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

...