0 votes
in SoSci Survey (English) by s083756 (530 points)

I would like to have 9 respondents for one brand, 17 respondents for another brand, etc. and each one of them in a different segment (each segment defined by an array). I would like to weed out all respondents that choose a brand after the amount of respondents for the brand is fulfilled. To do this, I created a question SC03 with 2 = brand one, 3 = brand two, etc. I am getting an error message every time I go throgh the questionnaire. How could I fix the code in order to fulfill my purposes? Thank you!

  $test = value('SC03');


	
$cdvlimits = array(
  2 => 9,
  3 => 17,
  4 => 12,
  5 => 6,
  6 => 5,
  7 => 6,
  8 => 15,
  9 => 65
);

$blimits = array(
  11 => 12,
  12 => 30,
  13 => 20,
  14 => 17,
  15 => 7,
  16 => 19,
  17 => 90
);

$climits = array(
  19 => 8,
  20 => 22,
  21 => 13,
  22 => 12,
  23 => 27,
  24 => 8,
  25 => 8,
  26 => 11,
  27 => 11
);

$nQnr = statistic('count', 'SC03', $test);

$cdvnMax = $cdvlimits[$test];
$bnMax = $blimits[$test];
$cnMax = $climits[$test];


if ($nQnr >= $cdvnMax) {
 goToPage('end');
}

if ($nQnr >= $bnMax) {
 goToPage('end');
}

if ($nQnr >= $cnMax) {
 goToPage('end');
}

1 Answer

0 votes
by SoSci Survey (328k points)

I am getting an error message every time I go throgh the questionnaire.

Please add this error message. This will make it a lot easiert to get started with solving the issue. Thank you.

My guess is that a non-exiting index is reported. This is bacuse you ask for example for entry "7" in all three Arrays, but there is only one Array that has the index "7". What you can do is to check if the key exists at all.

...

$nQnr = statistic('count', 'SC03', $test);

if (isset($cdvlimits[$test]) && $nQnr >= $cdvlimits[$test]) {
  goToPage("end");
}
if (isset($blimits[$test]) && $nQnr >= $blimits[$test]) {
  goToPage("end");
}
if (isset($climits[$test]) && $nQnr >= $climits[$test]) {
  goToPage("end");
}
by s083756 (530 points)
Thank you for your reply! it works now. The Error message I was getting was: Undefined offset: 11 (this number would change depending on the chosen answer).

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

...