Hello all,
First of all, I would like to thank you for your all support as an online Soscisurvey team.
I have a questionnaire which tests the participant's language knowledge (if they know Rnglish, German, or etc.).
I want participants to rank the (13 given) languages in the questionnaire. My questionnaire is multilingual btw. This was the original php code for this issue:
if (value('LS01_01') == 2) { replace('%Lang1%', 'Turkish'); } if (value('LS01_02') == 2) { replace('%Lang2%', 'English'); } if (value('LS01_03') == 2) { replace('%Lang3%', 'Arabic'); } if (value('LS01_04') == 2) { replace('%Lang4%', 'Bulgarian'); } if (value('LS01_05') == 2) { replace('%Lang5%', 'Azerbaijani'); } if (value('LS01_06') == 2) { replace('%Lang6%', 'Turkmen'); } if (value('LS01_07') == 2) { replace('%Lang7%', 'German'); } if (value('LS01_08') == 2) { replace('%Lang8%', 'Albanian'); } if (value('LS01_09') == 2) { replace('%Lang9%', 'Greek'); } if (value('LS01_10') == 2) { replace('%Lang10%', 'Persian'); } if (value('LS01_11') == 2) { replace('%Lang11%', 'French'); } if (value('LS01_12') == 2) { replace('%Lang12%', 'Spanish'); } if (value('LS01_13') == 2) { replace('%Lang13%', 'Chinese'); } if (value('LS01_14') == 2) { replace('%OtherLang1%', 'LS01_14a', 'response'); } if (value('LS01_15') == 2) { replace('%OtherLang2%', 'LS01_15a', 'response'); } if (value('LS01_16') == 2) { replace('%OtherLang3%', 'LS01_16a', 'response'); } $itemliste = getItems('LS01', 'is', 2); if (empty($itemliste)) { goToPage('PLS16'); } question('LS02', $itemliste);
So now, I have different coding for the ranking part like this: which works perfect.
for ($i=1; $i<=13;$i++) {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%Lang'.$i.'%', getItemtext('LS01', $i));}} if (value('LS01_14') == 2) { replace('%OtherLang1%', 'LS01_14a', 'response'); } if (value('LS01_15') == 2) { replace('%OtherLang2%', 'LS01_15a', 'response'); } if (value('LS01_16') == 2) { replace('%OtherLang3%', 'LS01_16a', 'response'); } $itemliste = getItems('LS01', 'is', 2); if (empty($itemliste)) { goToPage('PLS16'); } question('LS02', $itemliste);
For the further page, I ask the participant about their abilities in the languages they already chose. (These languages are ability language1, ability language2 .....3, ....4 etc.)
I made the coding like this for ability language 1 orignally like this:
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'); } } if (value('LS01_03') == 2) { $language = value('LS02_03'); if ($language == 1) { replace('%AbilityLanguage1%', 'Arapça'); } } if (value('LS01_04') == 2) { $language = value('LS02_04'); if ($language == 1) { replace('%AbilityLanguage1%', 'Bulgarca'); } } if (value('LS01_05') == 2) { $language = value('LS02_05'); if ($language == 1) { replace('%AbilityLanguage1%', 'Azerice'); } } if (value('LS01_06') == 2) { $language = value('LS02_06'); if ($language == 1) { replace('%AbilityLanguage1%', 'Türkmence'); } } if (value('LS01_07') == 2) { $language = value('LS02_07'); if ($language == 1) { replace('%AbilityLanguage1%', 'Almanca'); } } if (value('LS01_08') == 2) { $language = value('LS02_08'); if ($language == 1) { replace('%AbilityLanguage1%', 'Arnavutça'); } } if (value('LS01_09') == 2) { $language = value('LS02_09'); if ($language == 1) { replace('%AbilityLanguage1%', 'Yunanca'); } } if (value('LS01_10') == 2) { $language = value('LS02_10'); if ($language == 1) { replace('%AbilityLanguage1%', 'Farsça'); } } if (value('LS01_11') == 2) { $language = value('LS02_11'); if ($language == 1) { replace('%AbilityLanguage1%', 'Fransızca'); } } if (value('LS01_12') == 2) { $language = value('LS02_12'); if ($language == 1) { replace('%AbilityLanguage1%', 'İspanyolca'); } } if (value('LS01_13') == 2) { $language = value('LS02_13'); if ($language == 1) { replace('%AbilityLanguage1%', 'Çince'); } } if (value('LS01_14') == 2) { $language = value('LS02_14'); if ($language == 1) { replace('%AbilityLanguage1%', 'LS01_14a', 'response'); } } if (value('LS01_15') == 2) { $language = value('LS02_15'); if ($language == 1) { replace('%AbilityLanguage1%', 'LS01_15a', 'response'); } } if (value('LS01_16') == 2) { $language = value('LS02_16'); if ($language == 1) { replace('%AbilityLanguage1%', 'LS01_16a', 'response'); } }
I changed it like this de here`
for ($i=1; $i<=13;$i++) {if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}} {if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}}{if (value(id('LS01', $i)) == 2) {replace('%AbilityLanguage'.$i.'%', getItemtext('LS01', $i));}} if (value('LS01_14') == 2) { $language = value('LS02_14'); if ($language == 1) { replace('%AbilityLanguage1%', 'LS01_14a', 'response'); } } if (value('LS01_15') == 2) { $language = value('LS02_15'); if ($language == 1) { replace('%AbilityLanguage1%', 'LS01_15a', 'response'); } } if (value('LS01_16') == 2) { $language = value('LS02_16'); if ($language == 1) { replace('%AbilityLanguage1%', 'LS01_16a', 'response'); } }
To be honest, I copied this 13 times (as I have 13 different languages) and I don't know how to create LOOP for that :( to avoid copying.
Can I use the same coding(that I used for ability language1) for ability language2?
Hope, I will solve the problem soon with your help,
Once again many thanks,