Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Choice List Table for a Lottery Task - Experimental Economics

More
1 month 1 week ago #273567 by c.otieno
Please help us help you and fill where relevant:
LimeSurvey version: [6.15.19]
Own server or LimeSurvey Cloud: Cloud
Survey theme/template: Inherit [fruity_twentythree]
==================
Hi Team Limesurvey,
I'd like to create a choice list table (see attached screenshot), where participants can choose between two options. The closest topics I've come to from previous forums are those related to conjoint tables or discrete choice experiments, but they haven't offered much guidance as in my case participants have to choose an option in every row. The idea I have is to use an Array question, but I don't know how I can present it as exactly as in the screenshot.

I'd also like to programme the choice list such that participants can only switch once from one option to the other (e.g AAAABBBBBB or BBBBBAAAA) and not multiple times (e.g., AAABBBAAB). That is, if they choose A in a couple of rows and switch to B, they cannot switch back to A again in the subsequent rows, and vice versa (I hope it makes sense :)). 

Any tips would be really appreciated.

Thanks in advance.

Best,
Christine

Please Log in to join the conversation.

More
1 month 1 week ago - 1 month 1 week ago #273572 by Joffm
Hi,
well these posts about conjoint and other stuff you found are not at all related to your idea.
What you show is a simple array.

But I do not know what for you use the pie chart. Is it static - just an image?

Well, I can offer this design with a roughly created pie
 

That's rather simple with this script and css
Code:
<script type="text/javascript" charset="utf-8">  
    $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Insert header text
    var insertedText = "<b>Which option do you prefer?</b>";
    $('table.subquestion-list thead tr:last td:first', thisQuestion).addClass('inserted-header').append(insertedText);
 
    // Move element(s)
    $('.question-title-container', thisQuestion).append($('.question-valid-container', thisQuestion));
  });
</script>


Code:
<style type="text/css">@media only screen and (min-width: 480px) {
 
  #question{QID} .question-title-container {
    width:35%;
  }
    #question{QID} .answer-container {
      width: 65%;
    }
 
    #question{QID} .question-valid-container {
      padding-left: 0;
    }
  }
/*   Teilfragentexte linksbündig */
  .ls-answers tbody .answertext { 
    text-align: left; 
  }
</style>


The main question is about the switching.
Here I'd try to use a question validation expression.
You only have to count how many times an answer option is different from the previous answer option.
Like (this is a first idea, has to be improved a bit)
question validation equation:
sum(intval(Q1_2!=Q1_1),intval(Q1_3!=Q1_2),intval(Q1_4!=Q1_3),intval(Q1_5!=Q1_4),....,intval(Q1_16!=Q1_15))==1

I remember that this questions was asked some time ago.
Let's see if we can find it.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 month 1 week ago by Joffm.

Please Log in to join the conversation.

More
1 month 1 week ago #273576 by c.otieno
Hi Joffm,
Thanks for replying :)

The pie chart is just an image and doesn't change. It's use may be too deep to explain here, but it serves as Option B, while the monetary amounts as Option A.

Thanks for the script. However, I'm not sure if my account is allowed to use Javascript (see screenshot attached) or perhaps am on the wrong interface. I'm quite green to programming. Is the script field (in the screenshot) where I'm supposed to paste the Javascript?
I pasted the second code in the css class. I hope that is correct.

Thanks for the effort in sourcing records on similar questions.

Looking forward to what you find.

Best,
Christine

Please Log in to join the conversation.

More
1 month 1 week ago #273577 by Joffm
Hi, Christine

so that's fine.

Is the script field (in the screenshot) where I'm supposed to paste the Javascript?

Yes, but without the "surrounding" lines
Only this
Code:
 // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Insert header text
    var insertedText = "<b>Which option do you prefer?</b>";
    $('table.subquestion-list thead tr:last td:first', thisQuestion).addClass('inserted-header').append(insertedText);
 
    // Move element(s)
    $('.question-title-container', thisQuestion).append($('.question-valid-container', thisQuestion));

I pasted the second code in the css class. I hope that is correct.

No, here you'd enter "css classes" which you definde in your custom.css.
Such small css snippets you enter in the question text (in source code mode) (that's the second icon in the uper left corner of the editor - with the tooltip "source")
 
Now, because you use the question code for the css you'd better enter the script here as well.
Both shown parts (script and css), one after the other.

Like this.
 
You see the first line where the image is inserted.
The rest is the script and the css.


Here a sample.
 

File Attachment:

File Name: limesurvey...7591.lss
File Size:32.87 KB

Remarks:
  1. Of course you don't need this "badge" representation in the subquestion text.
  2. The validation now fires after all subquestions are answered. Otherwise it would show always errors after the first switch ( an empty subquestion also is different from the previous). Meaning the validation would be more complex.
  3. Now the validation is for these ten subquestions. You have to adapt to your real amount.
  4. In the css the relation "image - array" is set to 35% - 65%. Adapt to your needs 

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
1 month 1 week ago #273601 by c.otieno
Hi Joffm,
Thanks for the clarification. Unfortunately I'm still unable to paste or type anything in the script field. A message pops indicating 'Editing is disabled' :(
I guess my account doesn't have such permissions. Could there be any other way around it?

I've however managed to enforce a single switch using the question validation equation in a related question in my survey, and it's working :)

Thanks.

Best,
Christine
 

Please Log in to join the conversation.

More
1 month 1 week ago #273603 by Joffm
HI, in your first post you wrote that your LimeSurvey installation is hosted at the LimeSurvey GmbH (meaning the "Cloud version").
Is it possible that this is not your own account but the account of the university, the company?
Then it might be rather possible that you do not have the rights to use javascript.

But you should mention such things.

Now you should send the lss export of your survey.
And as this image simply is something like a clarification you also can insert it into the question text.

You see the whole script doeesn't do anything else than to move the question text from the top to the left.

Unfortunately I'm still unable to paste or type anything in the script field

You see, I wrote that I prefer to enter this in the question text (in source code mode)
A simple test, whether you can use javascript is to enter
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
alert("Hello, javascript speaking");
});
</script>

If it pops up, fine, if not, you have probably no rights.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
1 month 1 week ago #273605 by c.otieno
Hi Joffm,
Apologies for the confusion. I'm using an account of the university hosted at the Uni's academic cloud survey service. And for some reason I thought own server sort of means own account, that's why I indicated cloud version. Now I know. 

I can simply insert the image in the text as the script doesn't do much. .

I've done the javascript test and nothing pops up, I bet I don't have the rights.

Thanks again.
 

Please Log in to join the conversation.

More
1 month 1 week ago #273611 by c.otieno
Hi Joffm,
I've attached the lss file now (it contains 2 other related questions).

I have inserted the picture(s) in the text and seems fine.

However, for the table (array), I'd like to know if there's a way to have the columns labelled as in the first screenshot I shared. The current labeling may be confusing for participants.

I'd appreciate any tips.

Thanks always.

Best,
Christine

 

Please Log in to join the conversation.

More
1 month 1 week ago #273612 by Joffm
To insert the text into the upper left cell you need javascript.
Anyway, you can place the text by css.
 
But what is confusing?
There is a lot of space. So you can rename the headers to "I prefer Option A", "I prefer Option B". or whatever you want.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose