0 votes
in SoSci Survey (English) by s104186 (150 points)

I have tried to use the above coding, but an error keeps popping up.

I think there is still a misunderstanding of what I am looking for. I would like the end presentation of my survey as shown

So every respondents get a random "yes" "no" and then input their price choice in the radio button based on the 'determinants'. The yes and no would be random and so would the price options. This random page would be displayed 5 times for the respondent to make the choices 5 times based on the determinants that are different and price options that are different.

Would you still advice me to follow the procedure mentioned above?

related to an answer for: questionnaire within questionnaire

1 Answer

0 votes
by SoSci Survey (328k points)

Your codes should read like this:

111
112
121
122
211
212
221
222

Just as example for 8 combinations of 2 binary factors.

So every respondents get a random "yes" "no" and then input their price choice in the radio button based on the 'determinants'.

If someone has 111, then it would be no, no, no. The code 221 would result in yes, yes, no.

How many such combinations do you have per questionnaire? And how are they combined?

by s104186 (150 points)
My questionnaire would have 5 pages each page would have a table exactly as shown in the first question but with random yes and no in the table. so each page would have 2 sets of 8 combinations as you have shown above and also 2 random price options selected from 9 different price points.

The yes and no is to be displayed randomly and the prices will also have to be random.
by SoSci Survey (328k points)
I am confused of the "5" pages and "8" combinations?!

If you like to display 5 compare-tables, then tell the random generator to draw 10 item. Then you have 10 variables, and can use one for every column with yes and no's.
by s104186 (150 points)
Thanks! I wasnt able to figure it out your way, so i created tables in the "List of questions" and used PHP to display different combinations at random using random() and switch...case statements.

Right now the roadblock is for the pricing.  have 64 unique combination questions that I have created as an horizontal selection type question. If i use random() it generates the questions at random however sometimes the same question is used on other pages within the questionnaire so, every-time it repeats itself the previous answer gets overwritten. I would like to know if there is a way that i can code in PHP to display these questions randomly and without repetition?
by SoSci Survey (328k points)
Well, I strongly recommend NOT to word with random(). Just for the problems that you describe. You can either put combinations (112) into a random generator or question IDs (AB01) - anything will be more suitable than the random() function.
by s104186 (150 points)
I have finally figured out what all the coding meant in your previous random generator examples and successfully implemented them, thanks to you guys.

However, I get an error - "There are not enough parameters for the function replace(). 2 parameters are essential for proper processing. Please refer to the user manual for further details."

My coding is as shown

$code=value('PR01');
$factor1 = $code;
if ($factor1 == 1) {
  replace('%1%', question('P201'));
} elseif ($factor1 == 2) {
  replace('%2%', question('P202'));
}

How do I fix this?
by SoSci Survey (328k points)
If you would like to display different questions, you will not need placeholders and replace() at all. This is when you use the question IDs in your random generator.

If you stick to the factors (121 etc.), then put "yes" and "no" into the placeholders.

$code=value('PR01');
$factor1 = $code{0};
if ($factor1 == 1) {
  replace('%fac1%', 'no');
} elseif ($factor1 == 2) {
  replace('%fac1%', 'yes');
}

The first line of your table would then contain something like <td>%fac1%</td>
by s104186 (150 points)
Hello,
Ive been coding with the random generator
my codes in the random generator are of the following format:
11111111
11111112
11111122
11111222

and so on..

in the PHP coding, as advised before, when i code as:

$var = value('VC01');
$factor1 = $var{0};
$factor2 = $var{1};
$factor3 = $var{2};
$factor4 = $var{3};
$factor5 = $var{4};
$factor6 = $var{5};
$factor7 = $var{6};
$factor8 = $var{7};
if ($factor1 == 1) {
  replace('%text1%', 'No');
} else {
  replace('%text1%', 'Yes');;
}
if ($factor2 == 1) {
  replace('%text1%', 'No');
} else {
  replace('%text1%', 'Yes');;
and so on..

the First error that pops up is that "$factor2 = $var{1};" is "Uninitialized string offset".
Secondly, I have used html coding in the PHP to create a table to hold the random values selected by the random generator. However, it only shows all "yes" or all "no" and no combination as the values i have inputted in the random generator.

I'd appreciate your help again.:)
by SoSci Survey (328k points)
Please change the first line as follows:

$var = value('VC01', 'label');

You need your "content" of the draw, not the internal code (1, 2, 3...)

And then please use different placeholders, in the example code above, it's two times %text1%, but should be "%text2%" in the second IF.
by s104186 (150 points)
I have coded as below:
$var = value('VC01', 'label');
$factor1 = $var;
$factor2 = $var;
$factor3 = $var;
$factor4 = $var;
$factor5 = $var;
$factor6 = $var;
$factor7 = $var;
$factor8 = $var;
if ($factor1 == 1) {
  replace('%text1%', 'No');
} else {
  replace('%text1%', 'Yes');
}
if ($factor2 == 1) {
  replace('%text2%', 'No');
} else {
  replace('%text2%', 'Yes');
}
if ($factor3 == 1) {
  replace('%text3%', 'No');
} else {
  replace('%text3%', 'Yes');
}
The first problem is fixed. however, the second problem still stands, it only shows all "yes" or all "no" and no combination.
by SoSci Survey (328k points)
So, I hope you used the different placeholders %text1% in the output HTML as well? What does the debug information say: https://www.soscisurvey.de/help/doku.php/en:create:debugging ?
by s104186 (150 points)
This is what it says in the debug information:

The random generator VC01 drew these codes: 11221222
value("VC01") = ""
The following placeholders have been prepared:
%text1% = (text) Yes
%text2% = (text) Yes
%text3% = (text) Yes
%text4% = (text) Yes
%text5% = (text) Yes
%text6% = (text) Yes
%text7% = (text) Yes
%text8% = (text) Yes
by SoSci Survey (328k points)
Okay, you removed the {0} etc. in your code. This will be essential to re-add.

$var = value('VC01', 'label');
$factor1 = $var{0};
$factor2 = $var{1};
// etc...
by s104186 (150 points)
when I re-add {0}, it shows the error as "Uninitialized string offset"

and the debug information as:
The random generator VC01 drew these codes: 21122122
value("VC01") = ""
The following placeholders have been prepared:
%text1% = (text) Yes
%text2% = (text) Yes
%text3% = (text) Yes
%text4% = (text) Yes
%text5% = (text) Yes
%text6% = (text) Yes
%text7% = (text) Yes
%text8% = (text) Yes
by SoSci Survey (328k points)
Okay, this here is wrong:

value("VC01") = ""

Are you sure, you have places the question VC01 above the PHP code?

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

...