0 votes
in SoSci Survey (English) by s099039 (180 points)
edited by SoSci Survey

Dear all,

How can we write these placeholders in getitemtext() ?

I have 13 different language options so the first part starts like this:

for ($i=1; $i<=13;$i++) {if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage1%'.$i.'%', getItemtext('LS01', $i));}}

but I there is sth missing here and system gives error:/

if (value('LS01_01') == 2) {   $language = value('LS02_01');   if ($language == 1) {     replace('%AbilityLanguage1%', 'Türkçe');   } }  if (value('LS01_02') == 2) {   $language = value('LS02_02');   if ($language == 1) {     replace('%AbilityLanguage1%', 'İngilizce');   } }

This is my original coding and I want to write my questionnaire with getitemtext() by myself ?
Where can I find info about it? What is the logic behind this?

Thanks for your help,

1 Answer

0 votes
by SoSci Survey (328k points)

but I there is sth missing here and system gives error:/

An important note: Whenever the system gives you an error, please post that error. Usually, the errors are designed to give a clue of what the problem is :)

Regarding the problem, please check out this line:

'%AbilityLanguage1%'.$i.'%'

When $i has the value 5 (for example), this makes

%AbilityLanguage1%5%

One percentage too much. Therefore it should be

'%AbilityLanguage'.$i.'%'

Now, you prepare the placeholder %AbilityLanguage5% that you can use as item text.

by s099039 (180 points)
Thank you very much for your help. I really appreciate it.
Actually, these aren't the errors of the system maybe it is because of my lack of Php coding skills :))

I got it correct now like this:
for ($i=1; $i<=13;$i++) {if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}} and I have 13 language items more should I copy this command 13 times?? :/

In the original one the coding was like that:

if (value('LS01_01') == 2) {   $language = value('LS02_01');   if ($language == 1) {     replace('%AbilityLanguage1%', 'Türkçe');   } }  if (value('LS01_02') == 2) {   $language = value('LS02_02');   if ($language == 1) {     replace('%AbilityLanguage1%', 'İngilizce');   } }



here: I want to ask about -----if ($language == 1)--- meaning because I didn't put anything like that in my last coding now. Maybe I can miss some important data if I remove if ($language == 1) part :/
Can I kindly ask the technical details here? Thanks for your all help.
by SoSci Survey (328k points)
> should I copy this command 13 times?? :/

No, just create a FOR loop

for ($i=1; $i<=13; $i++) {
  replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));
}

The IF is not really necessary here, because it wont hurt to set all items. It's just important to (only) ask the right items/questions, later.
by s099039 (180 points)
Thank you for your help. Actually, It appears in the correct form but when I go to ability language 2, I got this notification:
For the placeholder %AbilityLanguage2% neither an input field by prepare_input() has been created nor any content by using replace().

When I fix abilitylanguage2 then I get the same notification for abilitylanguage1 though I didn't touch the codes in the ability language1 :/

sometimes for both of them I get the same notification again though I didn't touch coding part again:

https://www.soscisurvey.de/istanbul/index.php?i=VB6195Z3OYBR&rnd=PBPR
by SoSci Survey (328k points)
> When I fix abilitylanguage2  ....

What do you mean by "fix"? Did you use the FOR loop? It would simplyfy things if you (a) posted your whole PHP code (you are welcome to create a new question for that) and (b) format your PHP code in a readable way :)
by s099039 (180 points)
Thank you for your reply and I will create new question soon now :)

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

...