0 votes
in SoSci Survey (English) by s169796 (110 points)
closed by SoSci Survey

Good morning. I am trying to insert a repeat page code in case the question (WB02) is not answered correctly. The correct answer should be: 3. I have created an internal variable $rPG2, and have inserted this code at the top of page 3 (WB02 is listed at the end of page 2):

//  only checked if $repeatedPG2 is not yet set
if (!isset($rPG2)) {
  // check, if the answer is missing (code 3) in the selection WB02
  $failWB02 = (value('WB02') == 3);
  // check, if items in scale WB02 are unanswered
  $failWB02 = (count(getItems('WB02', 'missing')) > 0);
 
  if ($failWB02 || $failWB02) {
    // be aware that page 2 repeats/was repeated
    $rPG2 = true;
    registerVariable('rPG2');
    // show previous page again
    repeatPage('error_missing');
  }
}

Do you have any idea why the code is not working? Thank you very much in advance!

closed with the note: There has been no response to the question in the comment, so we assume that the issue is already solved.
by SoSci Survey (330k points)
What exactly does not work? What does the debug information say?
by s169796 (110 points)
The page did not repeat when I gave false responses. This is what the debug information says: Warning (page 3)
The variable WB02 has not been asked on a previous page during this interview. Therefore value() cannot determine any answer, yet.

But the question has already been asked in the previous page. Thanks in advance.
by SoSci Survey (330k points)
> The variable WB02 has not been asked on a previous page during this interview.

Did you also start the test on the page where WB02 was asked (or before)? What question type is that question of?

Also I see that your code does not make much sense here:

if ($failWB02 || $failWB02) {

You use the same variable name $failWB02 twice. As the variable is defined differently, above, you probably want to check another variable?

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

...