- Posts: 5033
- Thank you received: 1257
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Capturing randomization order
- jelo
- Offline
- Platinum Member
Less
More
6 years 7 months ago #158835
by jelo
Equation question vs. short text question? Workarounds vs. plugins?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Capturing randomization order
Better in comparison to what?markusfluer wrote: To capture the sequence it would be better
Equation question vs. short text question? Workarounds vs. plugins?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- elenas
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
3 years 10 months ago #201250
by elenas
Replied by elenas on topic Capturing randomization order
I want to record the array answer order. How can I modify this script?
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Identify some stuff
var qHiddenID = {QID}; // The hidden question ID
var qHidden = $('#question'+qHiddenID); // The hidden question
var q1 = $('div.list-radio:eq(0)'); // First radio question on the page
var q1ID = $(q1).attr('id').split('question')[1]; // The first radio question ID
var gID = $('input.text', qHidden).attr('id').split('X')[1]; // The group ID
// Hide this question
$(qHidden).hide();
// Build an array of the Q1 answers
var answersArr = new Array();
$('input.radio', q1).each(function(i){
var answerID = $(this).attr('id').split('X'+gID+'X'+q1ID)[1];
answersArr.push(answerID);
});
// Load the array into the hidden question
$('input.text', qHidden).val(answersArr);
});
</script>
Thanks
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Identify some stuff
var qHiddenID = {QID}; // The hidden question ID
var qHidden = $('#question'+qHiddenID); // The hidden question
var q1 = $('div.list-radio:eq(0)'); // First radio question on the page
var q1ID = $(q1).attr('id').split('question')[1]; // The first radio question ID
var gID = $('input.text', qHidden).attr('id').split('X')[1]; // The group ID
// Hide this question
$(qHidden).hide();
// Build an array of the Q1 answers
var answersArr = new Array();
$('input.radio', q1).each(function(i){
var answerID = $(this).attr('id').split('X'+gID+'X'+q1ID)[1];
answersArr.push(answerID);
});
// Load the array into the hidden question
$('input.text', qHidden).val(answersArr);
});
</script>
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
3 years 10 months ago #201262
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Capturing randomization order
Try this (untested):
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify some stuff var qHiddenID = {QID}; // The hidden question ID var qHidden = $('#question'+qHiddenID); // The hidden question var q1 = $('div.list-radio:eq(0)'); // First radio question on the page var q1ID = $(q1).attr('id').split('question')[1]; // The first radio question ID var gID = $('input:text', qHidden).attr('id').split('X')[1]; // The group ID // Hide this question $(qHidden).hide(); // Build an array of the Q1 answers var answersArr = []; $('input:radio', q1).each(function(i){ var answerID = $(this).attr('id').split('X'+gID+'X'+q1ID)[1]; answersArr.push(answerID); }); // Load the array into the hidden question $('input:text', qHidden).val(answersArr); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- elenas
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
3 years 10 months ago - 3 years 10 months ago #201328
by elenas
Replied by elenas on topic Capturing randomization order
Last edit: 3 years 10 months ago by elenas.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
3 years 10 months ago #201442
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Capturing randomization order
What are you trying to capture? The answers (x-scale) are not randomized.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- elenas
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
3 years 10 months ago #201469
by elenas
Replied by elenas on topic Capturing randomization order
Hi!
I want to capture the order of sub-questions (Germany, Cina, USA, ...).
By editing your script I get this: "b-1,b-2,b-3,...,b-10,a-1,a-2,a-3,...,a-10,d-1,...,d-10,c-1,....c-10"
Is it possible to write it in this way "b,a,d,c" ?
Thanks
I want to capture the order of sub-questions (Germany, Cina, USA, ...).
By editing your script I get this: "b-1,b-2,b-3,...,b-10,a-1,a-2,a-3,...,a-10,d-1,...,d-10,c-1,....c-10"
Is it possible to write it in this way "b,a,d,c" ?
Thanks
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify some stuff var qHiddenID = {QID}; // The hidden question ID var qHidden = $('#question'+qHiddenID); // The hidden question var q1 = $('div.array-10-pt:eq(0)'); // First array question on the page var q1ID = $(q1).attr('id').split('question')[1]; // The first array question ID var gID = $('input:text', qHidden).attr('id').split('X')[1]; // The group ID // Hide this question $(qHidden).hide(); // Build an array of the Q1 answers var answersArr = []; $('input:radio', q1).each(function(i){ var answerID = $(this).attr('id').split('X'+gID+'X'+q1ID)[1]; answersArr.push(answerID); }); // Load the array into the hidden question $('input:text', qHidden).val(answersArr); }); </script>
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
3 years 10 months ago - 3 years 10 months ago #201495
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Capturing randomization order
Try this:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify some stuff var qHiddenID = {QID}; // The hidden question ID var qHidden = $('#question'+qHiddenID); // The hidden question var q1 = $('table.subquestions-list:eq(0)').closest('div[id^="question"]'); // First array question on the page var q1ID = $(q1).attr('id').split('question')[1]; // The first array question ID var gID = $('input:text:eq(0)', qHidden).attr('id').split('X')[1]; // The group ID // Hide this question $(qHidden).hide(); // Build an array of the Q1 answers var answersArr = []; $('tr[id^="javatbd"]', q1).each(function(i){ var answerID = $(this).attr('id').split('X'+gID+'X'+q1ID)[1]; answersArr.push(answerID); }); // Load the array into the hidden question $('input:text', qHidden).val(answersArr).trigger('keyup'); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 3 years 10 months ago by tpartner.
The following user(s) said Thank You: elenas
The topic has been locked.
- elenas
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 0
3 years 10 months ago #201521
by elenas
Replied by elenas on topic Capturing randomization order
It works!
Thank you
Thank you
The topic has been locked.
- LookingforSolution
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 6 months ago - 3 years 6 months ago #205819
by LookingforSolution
Replied by LookingforSolution on topic Capturing randomization order
Hello,
I would like to randomize multi punch question items in blocks. I do have an exclusive option (always at the end) and a not open "other" option (at the second last position):
A--> Block 1
B--> Block 1
C--> Block 1
D--> Block 2
E--> Block 2
F--> Block 2
G--> Block 3
Other-->Block 3
Exclusive--> Block 3
For that reason, I created separate questions for every item-block (1st question with question text, others without) within the same question group and added the same randomization group name for all questions.
I used the follwing skripts:
1. For first question Block1 (items with question text):
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question{QID}').addClass('no-bottom');
});
</script>
2. for following question Block 2-3 (only items, no question text):
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question{QID}').addClass('no-question');
$('#question{QID}').addClass('no-bottom');
});
</script>
The problems are the following:
1. I want the questions always to be answered, but I can only put every question for itself as obligatory. This means one item of every question has to be selected, which does not always make sense.
2. If the exclusive option is selected ALL other items from all questions of this group should be grayed out. This right now only applies to items, which are in the same block.
Could you maybe help?
Thanks in advance!
I would like to randomize multi punch question items in blocks. I do have an exclusive option (always at the end) and a not open "other" option (at the second last position):
A--> Block 1
B--> Block 1
C--> Block 1
D--> Block 2
E--> Block 2
F--> Block 2
G--> Block 3
Other-->Block 3
Exclusive--> Block 3
For that reason, I created separate questions for every item-block (1st question with question text, others without) within the same question group and added the same randomization group name for all questions.
I used the follwing skripts:
1. For first question Block1 (items with question text):
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question{QID}').addClass('no-bottom');
});
</script>
2. for following question Block 2-3 (only items, no question text):
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#question{QID}').addClass('no-question');
$('#question{QID}').addClass('no-bottom');
});
</script>
The problems are the following:
1. I want the questions always to be answered, but I can only put every question for itself as obligatory. This means one item of every question has to be selected, which does not always make sense.
2. If the exclusive option is selected ALL other items from all questions of this group should be grayed out. This right now only applies to items, which are in the same block.
Could you maybe help?
Thanks in advance!
Last edit: 3 years 6 months ago by LookingforSolution.
The topic has been locked.