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

PHP Code

quotaOKR = [ 1 == 195 ];

quotaIND = [ 1 == 195 ];

$OKR = value('ZS022');
$IND = value('ZS06');

$casesOKR = statistic('count', 'ZS022', $OKRGroup);
$maxPerOKR = $quotaOKR[$OKRGroup];

$casesIND = statistic('count', 'ZS06', $INDGroup);
$maxPerIND = $quotaIND[$INDGroup];

if (($casesOKR >= $maxPerOKR)|| ($casesIND >= $maxPerIND)) {
redirect('https://survey.maximiles.com/quotasfull?p=89490_f1bc75ab&m=%reference%');
};

if ((caseTime('begin') < 420)) {
redirect('https://survey.maximiles.com/complete?p=89490_b096552f&m=%reference%');
}

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

001 namespace s2survey\questionnaire\environment;
002
003 quotaOKR = [ 004 1 => 195 005 ];
006

Können Sie mir helfen was die Ursache für den Error ist?

Vorab herzlichen Dank
Error

1 Answer

0 votes
by SoSci Survey (327k points)

Die Fehlermeldung beschwert sich über diese Zeile:

quotaOKR = [ 004 1 => 195 005 ];

Jetzt einmal abgesehen davon, dass auch ein doppeltes Gleichheitszeichen in der Definition eines Arrays wenig sinnvoll ist

quotaOKR = [ 1 == 195 ];

... was steht denn tatsächlich in Ihrem Code? Sie können den Code hier beim Formulieren einer Frage markieren und dann {} kilicken, damit er unverändert als Code gepostet wird.

by s210296 (270 points)
Hi

I changed to quotaOKR = [
  1 => 195
];
 
But I still get folloing error:

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

001 namespace s2survey\questionnaire\environment;
002
003 quotaOKR = [
004   1 => 195
005 ];
006


CODE is:

quotaOKR = [
  1 => 195
];

quotaIND = [
  1 => 195
];


$OKR = value('ZS022');
$IND = value('ZS06');

$casesOKR   = statistic('count', 'ZS022', $OKRGroup);
$maxPerOKR    = $quotaOKR[$OKRGroup];

$casesIND   = statistic('count', 'ZS06', $INDGroup);
$maxPerIND    = $quotaIND[$INDGroup];

if (($casesOKR >= $maxPerOKR) || ($casesIND >= $maxPerIND)) {
  redirect('https://survey.maximiles.com/quotasfull?p=89490_f1bc75ab&m=%reference%');
};

if ((caseTime('begin') < 420)) {
  redirect('https://survey.maximiles.com/complete?p=89490_b096552f&m=%reference%');
}
by SoSci Survey (327k points)
Okay, we're making progress. Next think: You always need a dollar sign before any variable name:

$quotaOKR = [
  1 => 195
];
by s210296 (270 points)
Thx. I changed it, the issue right now is that I get the redirect  in any cases. Even that i have =>....

Do you know where I can see the quota numbers?

Look forward to hearing from you
by SoSci Survey (327k points)
First, comment out the redirect, like this:

if (($casesOKR >= $maxPerOKR) || ($casesIND >= $maxPerIND)) {
  // redirect('https://survey.maximiles.com/quotasfull?p=89490_f1bc75ab&m=%reference%');
  html('<p>Redirect</p>');
  pageStop();
};

Then add some debug()s

$casesOKR   = statistic('count', 'ZS022', $OKRGroup);
debug($casesOKR);

Then start in the debug mode and see what the debug information tells you.
by s210296 (270 points)
edited by s210296
Now I get:
There is an error in the PHP code:
Questionnaire Error: The PHP variable $maxPerOKR has been used but the variable is yet undefined (the variable has no value).

PHP code

013 $IND = value('ZS06');
014
015
016 if (($casesOKR >= $maxPerOKR) || ($casesIND >= $maxPerIND))
017 {
018   
019   html('<p>Redirect</p>');
Questionnaire Error: The PHP variable $casesOKR has been used but the variable is yet undefined (the variable has no value).

PHP code

013 $IND = value('ZS06');
014
015
016 if (($casesOKR >= $maxPerOKR) || ($casesIND >= $maxPerIND))
017 {
018   
019   html('<p>Redirect</p>');


Beside this I have to code an logic to the quota:

$quotaIND = [
  1 >= 195
];

like If somebody select $OKR = value('ZS02') == 1 && $IND = value('ZS06');
then count it to $casesOKR  

Can I write down sth like this: )
 If (($OKR = value('ZS02') == 1 && $IND = value('ZS06'){
 statistic('count', 'ZS02', $OKRGroup)}

Thx in advance
by SoSci Survey (327k points)
It is defined in the original code from above. Just to be sure: You put all PHP code on that page into one "PHP code" block, right? Could you please post the latest content of that block.

> like If somebody select $OKR = value('ZS02') == 1 && $IND = value('ZS06');

What exactly you you mean with
  $OKR = value('ZS02') == 1
by s210296 (270 points)
Let just fix it one quota. If this works, we can put the other quoate, too

PHP code


$quotaIND = [
  1 >= 195
];

$IND = value('ZS06');


$casesIND   = statistic('count', 'ZS06', $INDGroup);
debug($casesIND);


if ($casesIND >= $maxPerIND)
{
  // redirect('https://survey.maximiles.com/quotasfull?p=89490_f1bc75ab&m=%reference%');
  html('<p>Redirect</p>');
  pageStop();
};

$maxPerIND = $quotaIND [$IND];


if ($casesIND >= $maxPerIND)
{
  // redirect('https://survey.maximiles.com/quotasfull?p=89490_f1bc75ab&m=%reference%');
  html('<p>Redirect</p>');
  pageStop();
};

Error
There is an error in the PHP code:
Questionnaire Error: The PHP variable $INDGroup has been used but the variable is yet undefined (the variable has no value).

PHP code

007 $IND = value('ZS06');
008
009
010 $casesIND   = statistic('count', 'ZS06', $INDGroup);
011 debug($casesIND);
012
013
Questionnaire Error: The PHP variable $maxPerIND has been used but the variable is yet undefined (the variable has no value).

PHP code

011 debug($casesIND);
012
013
014 if ($casesIND >= $maxPerIND)
015 {
016   
017   html('<p>Redirect</p>');

Looking forward to your help
by s210296 (270 points)
I could now fix it. Anyhow, thx for your help

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

...