Welcome, Guest
Username: Password: Remember me

TOPIC: Tayloring with 229 options (country list)

Tayloring with 229 options (country list) 10 months 3 weeks ago #100208

  • jonsen
  • jonsen's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 73
  • Thank you received: 6
  • Karma: 1
Hi Limers!

I would like to adress people vom different countries differently. To do that, I made three questions.

- cntry: In which country were you born?
- cntry_adj: (No question text)
- cntry_dem: (No question text)

The answer options look like this, while all three questions share the same answer codes:
(code/cntry/cntry_adj/cntry_dem)

af/Afghanistan/Afghan/Afghans
...
fr/France/French/Frenchmen
...
zw/Zimbabwe/Zimbabwean/Zimbabweans

Now I would like for cntry_adj and cntry_dem to be set automatically, based on the choice in cntry. I thought I would be able to do this by setting the default value, but I just found out that the default can only be set manually (on the "list"-type questions) and not by using {cntry} (aka. {cntry.code} ).

I could instead make the text-display questions cntry_adj_chosen and cntry_dem_chosen where I cascade like this:

{if(cntry == 'af',
'Afghan',
if(cntry == 'al',
'Albanian',
if(cntry == 'dz',
'Algerian',
...

and

{if(cntry == 'af',
'Afghans',
if(cntry == 'al',
'Albanians',
if(cntry == 'dz',
'Algerians',
...

I could then use the adjectivals and demonyms as {cntry_adj_chosen.question} and {cntry_dem_chosen.question}. But that would be a very dirty and not even quick solution. Can anyone suggest me something better? I though I had figured this out sometimes in the past, but now I'm just stuck on this again...

Thanks for reading!

Best
jonsen
The administrator has disabled public write access.

Tayloring with 229 options (country list) 10 months 2 weeks ago #100458

  • jonsen
  • jonsen's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 73
  • Thank you received: 6
  • Karma: 1
Thanks to everyone who has read this... I will use the above solution now.

Still, I would be very interesed in an alternative, maybe for the next time.

Best
Jonsen
The administrator has disabled public write access.

Tayloring with 229 options (country list) 10 months 2 weeks ago #100464

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6256
  • Thank you received: 799
  • Karma: 239
Hi,

Personnaly, i use this solution:
Adding an equation question type with:
{(Q2=Q1.NAOK)}

Then Q2 answer is set to same answer than Q1 but on the page after this one.

Denis
Last Edit: 10 months 2 weeks ago by DenisChenu.
The administrator has disabled public write access.

Tayloring with 229 options (country list) 10 months 2 weeks ago #100467

  • jonsen
  • jonsen's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 73
  • Thank you received: 6
  • Karma: 1
Thanks for the reply, Denis... I'm not sure if I understand you correctly. Because I don't want to have Q2=Q1... I want Q2 to be "Afghan" if Q1 is "Afghanistan", what I don't see in your solution. But it's okay, I think there is no other way right now.

The function needed for this would be something like...

{that.cntry_adj.code(cntry).shown} => {that.cntry_adj.code('af').shown} => "Afghan"

...which, to my knowledge, doesn't exist right now.

Best
Jonsen
Last Edit: 10 months 2 weeks ago by jonsen. Reason: added .shown
The administrator has disabled public write access.

Tayloring with 229 options (country list) 10 months 1 week ago #100584

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6256
  • Thank you received: 799
  • Karma: 239
Hi,

With == : you made a test.

With = : you assign a answer to a question.

Here, you assign same answer in Q2 than Q1.
The if user answered 'af' at Q1 (answer code), the answer code of Q2 is SET to 'af' too.

In Q1: 'af' mean 'Afghanistan' (answer text)
In Q2 : 'af' mean 'Afghan' (answer text)

etc ...

You can only assign a answer in PHP, then only for next page (you can do it in an equation type hidden, or try in the group description ).

Denis
The administrator has disabled public write access.
The following user(s) said Thank You: jonsen

Tayloring with 229 options (country list) 10 months 1 week ago #100589

  • jonsen
  • jonsen's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 73
  • Thank you received: 6
  • Karma: 1
Thank you, Denis!

My solution solves the case in which the result is needed on the same page. For all other purposes, your solution is the best way to go!

Best
Jonsen
The administrator has disabled public write access.

Tayloring with 229 options (country list) 10 months 1 week ago #100591

  • jonsen
  • jonsen's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 73
  • Thank you received: 6
  • Karma: 1
DenisChenu wrote:
Personnaly, i use this solution:
Adding an equation question type with:
{(Q2=Q1.NAOK)}

Then Q2 answer is set to same answer than Q1 but on the page after this one.

Just for easier understanding:

With {Q2 = Q1.NAOK}, the Q2 answer CODE is set to same answer CODE as Q1. This enables one to use {Q1.shown} and {Q2.shown} with corresponding texts:

{Q1} == 'af' and {Q1.shown} == 'Afghanistan'
{Q2} == 'af' and {Q2.shown} == 'Afghan'
Last Edit: 10 months 1 week ago by jonsen. Reason: forgot .NAOK
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.201 seconds
Donation Image