Welcome, Guest
Username: Password: Remember me

TOPIC: Choosing value from multiple option question

Choosing value from multiple option question 2 years 8 months ago #71390

  • badronald
  • badronald's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 48
  • Karma: 0
Here is my dilemma. I have about 50 multiple choice questions, which two the participant sees are based on a condition in the token table. {I originally wanted the participant to pick 2 answers from 1 question, but I also need a third randomized choice from the same list (also saved to a short text) )

I want to then write the answer they choose from each one to short text questions so I can call up the answer as text in questions in the next couple of pages. It works fine for 1 question, but not for this many. I thought it was working, and now it seems to be broken. I have tried setting up the var q1ID as a comma list, || list

Here is my script:

<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

var q1ID = ( 7916 | 8063 | 8067 | 8070 | 8073 | 8076 | 8079 | 13220 | 13236 | 13258 | 13295 | 13313 | 13359 | 13384 | 13401 13432 | 13455 | 13472 | 14139 | 13491 | 13512 | 13539 | 13554 | 13567 | 13590 | 13603 | 13616 | 13633 | 13644 | 13655 | 13666 | 13692 | 13679 );
var qHidden = 8502;

$('#question'+qHidden+'').hide();

var q1Answers = new Array();

// Build an array of q1 answers checked
$('#question'+q1ID+' input.checkbox').click(function(){
var ansIDArr = $(this).attr('id').split('X'+q1ID+'');
var ansCode = ansIDArr[1];
if($(this).attr('checked') == true) {
q1Answers.push(ansCode);
}
});

// Interrupt next/submit function
$('#movenextbtn, #movesubmitbtn').click(function(){

$('#question'+qHidden+' input.text').val(q1Answers);

return true;
});

});
</script><script type="text/javascript" charset="utf-8">

$(document).ready(function() {

var q1ID = ( 7916 | 8063 | 8067 | 8070 | 8073 | 8076 | 8079 | 13220 | 13236 | 13258 | 13295 | 13313 | 13359 | 13384 | 13401 13432 | 13455 | 13472 | 14139 | 13491 | 13512 | 13539 | 13554 | 13567 | 13590 | 13603 | 13616 | 13633 | 13644 | 13655 | 13666 | 13692 | 13679 );

var qHidden = 8502;

// Hide the hidden question
$('#question'+qHidden+'').hide();

var q1Answers = new Array();

// Build an array of q1 answers checked
$('#question'+q1ID+' input.checkbox').click(function(){
var ansText = $(this).siblings('label').text();
if($(this).attr('checked') == true) {
q1Answers.push(ansText);
}
});

// Interrupt next/submit function
$('#movenextbtn, #movesubmitbtn').click(function(){

// Load the hidden question with the Q1 answers
$('#question'+qHidden+' input.text').val(q1Answers);

return true;
});

});
</script>
The administrator has disabled public write access.

Re: Choosing value from multiple option question 2 years 8 months ago #71416

  • badronald
  • badronald's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 48
  • Karma: 0
Edit: I am using 1.91. Would this be any easier using version 1.92?
The administrator has disabled public write access.

Re: Choosing value from multiple option question 2 years 8 months ago #71424

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
badronald-

I'd be happy to answer the question about 1.92, but I'm having trouble following what you're trying to do:

(1) Can you provide examples of how you are using the token table to generate the conditions needed to decide which two of 50 questions to show? Those conditions would translate to "relevance". I can happen automatically if you've already set the conditions, but might be easier to enter directly.
(2) When using the answer later in the survey, are you trying to capture the value shown, or the internally coded value? Looks like you want the value shown (e.g. the equivalent of {INSERTANS:SGQA}, or in 1.92 parlance, qcode.shown
(3) How do you want to capture the answers? Sounds like you have three answers and you want three variables so that you can separately show each of the chosen selections, but that isn't clear from the JavaScript (which puts the array of answers into the hidden question).

Say your 50 questions are called q1_1 through q1_50, you could create an Equation question (called ansList) using this question-text:
join('~', if(q1_1.NAOK=='Y',q1_1.shown,''), if(q1_2.NAOK=='Y',q1_2.shown,''), ..., if(q1_50.NAOK=='Y',q1_50.shown,''))

That would create a tilde-delimited list of the checked values, so the list would have three elements in it.

Then, you would create 3 more Equations to capture the offset of the tilde (tilde1, tilde2, tilde3), and 3 more to capture the values for each, called ans1, ans2, ans3. Tilde1-3 would be:
strpos(ansList,'~',0)
strpos(ansList,'~',tilde1)
strpos(ansList,'~',tilde2)
substr(ansList,0,tilde1-1)
substr(ansList,tilde1,tilde2-tilde1)
substr(ansList,tilde2)

Finally, you could then refer to those answers in later questions like this (where this is a ranking question and you can use {ans1} to {ans3} as the answer choices for the ranking question:

{FIRSTNAME}, you said your answers were {ans1}, {ans2}, and {ans3}. Please rank order them by priority.

/Tom
Last Edit: 2 years 8 months ago by TMSWhite. Reason: bad links
The administrator has disabled public write access.

Re: Choosing value from multiple option question 2 years 8 months ago #71428

  • badronald
  • badronald's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 48
  • Karma: 0
I am assigning a value in attribute_1, then using that as a condition to show/hide each question based on the value of the attribute.
I have just installed 1.92 and I have not had much time to look at the Expression Manager yet but I am excited to try it out.
I have spent days trying to make this work.

Basically, depending on which 2 questions they see, (out of a possible list of about 50) I need to save the answer they pick from each list to populate as text into the next few pages.

Here is a link to my survey:

strangereaction.com/jenn/limesurvey/index.php
The administrator has disabled public write access.

Re: Choosing value from multiple option question 2 years 8 months ago #71429

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
badronald-

Can you say more about what you're trying to do. There may be other ways to tackle this issue. Given that the survey is about clinical priorities, does that mean you have 50 possible clinical priorities, but you want each clinician to rank only 2 of them, so you're ensuring that you have at least 3 clinicians per question (for example, to get good inter-rater reliability). What sort of follow-up questions are you asking. I'm thinking there might be a way to take advantage of array_filters for this, depending upon what you're trying to accomplish.

Can you email me a token to try the survey, or send me a private message with it?

/Tom
The administrator has disabled public write access.

Re: Choosing value from multiple option question 2 years 8 months ago #71432

  • badronald
  • badronald's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 48
  • Karma: 0
First of all, thank you, I really appreciate your time and assistance. What I am actually trying to do is the following. I have a list of doctors who belong to one of 30 departments. Each department has it's own list of sub departments. Each doctor needs to choose 2 of these sub-departments to review (answer a series of questions about) and also be assigned a random (third) sub-department to review. All of these questions are the same no matter what sub-departments are the same.
The problem I am having is that there are 30 possible lists that can be used from which a sub-department can be chosen. The choice needs to be saved ( I was thinking into a short text field) so that I can pipe it into the follow-up questions on the following pages so they will remember what department they chose.
I will PM you a link to the survey along with some tokens.
The administrator has disabled public write access.

Re: Choosing value from multiple option question 2 years 8 months ago #71586

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
I think the best solution to this is using conditions and adding an according number of questions. Of course the survey will be huge, but you can copy whole groups at the latest Limesurvey 1.91 version and when using conditions all should work fine.

As for randomly choosing a department: You can use some Javascript to generate a random number between 1 and 30 and write a matching text string into a hidden question and then use SGQA placehlders to show that text string at a following question like "Please rate department 'XYZ'".

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.269 seconds
Donation Image