Randomise / flip statement rows of a bipolar likert scale matrix question left->right/right->left | XM Community
Skip to main content

Hi All
I've setup a test survey as needed to work out how to setup a bipolar question that showed the statements in a random order AND randomly flipped the statements (whole or individual ones within the matrix) left to right and right to left
The randomisation functionality doesn't seem to work as I thought it would. When you choose 'Randomly Reverse choices' or 'randomly flip choices'. It seems to move the statement rows as a whole, up or down the list.
What I am trying to do is this:
2 statements in a matrix question (in the below example the _ represents the likert scale dissatisfied to satisfied):
 
statement1a:______:statement1b
statement2a:______:statement2b

When the survey is running, I want to see the randomisation function do this:

statement1a:______:statement1b
statement2a:______:statement2b

or
statement2a:______:statement2b
statement1a:______:statement1b

or
statement1b:______:statement1a
statement2a:______:statement2b

or
statement2b:______:statement2a
statement1a:______:statement1b

(there are probably a few other combinations but hopefully you get the idea)
Notice how xa and xb end points get swapped randomly aswell as the order of the statements. It's like reversing the scale but xa will always be coded the low end of the likert sclae and xb will always be coded the high end of the likert sclae

Can this be done or... how can this be done?

I found a conversation about using Jquery to revserse the table but then how to invoke this randomly might cause issues and also how this would look on a mobile I'm not sure. https://community.qualtrics.com/XMcommunity/discussion/5032/how-can-i-reverse-the-order-of-a-matrix-table-scale-on-an-accordian-mobile-layout/p2

I did also try to use individual questions as then the choices do get flipped as expected. But then how would you randomly show the multiple questions <> and I'm not sure if you could make it look bipolar, ie. have a statement at each end of the choices. It sounds like with some javascript it might be possible to place the statement(s) at either end but no doubt very complex as it would have to split it in two and reposition whilst handling mobile and desktop screen sizes... so that's probably not an option.

Any ideas on this would be great.

Thanks

Rod Pestell

You won't be able to do this with one question.
You can can create two sets A...B and B...A. Randomize the statements within them and at the block level, randomize to show only one question.


Rod_Pestell,
You can do this with one bipolar matrix question. Randomize the statements (rows) and use JS to randomly select some rows and reverse the cells in those rows.
A bipolar matrix question is not mobile friendly, but it can be made mobile friendly with JS (see mfBipolarMatrix).


Hi All,
Thanks for the tips and guidance. TomG I might reach out to you if I can get approval to purchase your functions. Whilst I keep this survey in non-mobile mode...I found that you could easily reverse the direction of the table (ie swap the statements from left to right) by using the 'direction: rtl' term in the css code. :)
So I got as far as creating a copy of the block containing my question and then putting the two blocks in a randomiser block in the survey flow. I then used some Jquery code to change the direction of the table which works to some degree but then I needed to align the text the opposite way. However for some reason I can adjust the AnswerLeft class but not the AnswerRight class.
My code is below. I've tried a number of things but so far haven't worked it out. Can anyone advise?

Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
// QuestionBody isn't altered if you don't have .SKin in front
// see: https://community.qualtrics.com/XMcommunity/discussion/2747/need-a-code-to-modify-the-padding-for-question-body

jQuery(".Skin .QuestionBody").css({"direction": 'rtl'});
jQuery(".Skin .AnswerLeft").css({"text-align": 'right'}); //

//jQuery(".AnswerRight").css({"text-align": 'right!important'});  //Query(".Skin .Matrix .Bipolar th.AnswerRight").css({"text-align": 'left!important'}); //
});

image.pngAlso there is one problem with direction:rtl in that the (B7) and (A7) parts of the statement have for some reason move / swapped position to after the 'I prefer wording. Nothing else have changed. Is this a quirk of brackets ??
Thanks
Rod Pestell


https://community.qualtrics.com/XMcommunity/discussion/comment/52639#Comment_52639I thought you wanted to randomize on a row basis instead of a question basis? Anyway, using RTL is creative, but two questions makes the data a bit messy. Those two reasons are why I recommended randomly flipping some rows with JS.
Your JS doesn't work because you can't set !important in jQuery.css().


Hi TomG

I thought you wanted to randomize on a row basis instead of a question basis?

Yes I was aiming for this but decided to just invert the whole question (which took me down the route of using two blocks with a randomiser block) but as I've now got it working in JS code I could just use one question and use an incremental counter to run the code. I could use a quota counter to do that and whenever it's an even number then invert it. I'll give that a go and see where we get to. My only worry is that what if a person doesn't finish the survey - will the counter still increase once the survey does get closed (by the system)? Perhaps I should use something else?

Thanks for letting me know about the css and !important issue - I didn't realise that. That saved me a bit of time so I went back to google and found a couple of solutions. The nicest / simplest one seems to use attr(
jQuery(".Skin .AnswerRight").attr("style", "text-align: left !important");
source: https://stackoverflow.com/questions/2655925/how-to-apply-important-using-css
(about half way down)

There were a number of more complex solutions and a number of people saying it wold change all styles but as I'm jQuerying the specific .AnswerRIght class and this question is the only one on the page, I don't think it would be an issue, would it?
The post I found was rather old so I'm hoping that this attr( method will be ok. To check, I've got Edge, Android (tablet / phone but suspect it won't look at good), Chrome and Firefox but not Safari so I hope that it will still work as expected.
Any thoughts most welcome
Thanks
Rod Pestell



Rod_Pestell,
Use this. Other than mobile, I think it should be all you need.


Just had a brain wave! I don't need to use a quota, I can just use the randomizer block in the survey flow and create an embedded field and this is then updated in one of the blocks to either 'default' or reversed. Then I'll just use that in the one question with an If logic statement. aha!
Thanks
Rod Pestell


Thanks for that Tom - that now gives me two options to go to the table with. Thank you.
Let me DM you about the mobile function.
Thanks
Rod Pestell


HI All,
I've just come across an issue with the bipolarLeftRightRandomize.js code in that when the page is redrawn (for instance there was an unanswered questions) the routine runs again meaning it randomises the left / right position of the answers. This might confuse the responder. I'm just wondering if there is a way to make this run once and keep the positioning as is.
https://gist.github.com/marketinview/50356345b379ecc6f09b3b29b6074444
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .ChoiceRow").each(function() {
if(Math.random() < 0.5) {
var row = jQuery(this);
row.children().each(function() { row.prepend(jQuery(this)); });
row.find("th").first().removeClass("AnswerLeft").addClass("AnswerRight");
row.find("th").last().removeClass("AnswerRight").addClass("AnswerLeft");
}
});
});
for the time being I've removed the math.random function and used the randomiser in the survey flow (setting a variable to either 'default' or 'reversed' which then at least controls whether all statements should be flipped left to right or left alone. I would still like to work out a way to flip them. The only way I can think is by building the randomiser in the survey flow to cater for the 16 or so statements I am using but that's probably rather a clunk way. Does anyone have a better way?

Thanks

Rod Pestell

This is my code so far with a screenshot of my survey flow.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

var Q_Order = Qualtrics.SurveyEngine.getEmbeddedData("Segment_Q_Order")
if ( Q_Order == "Reversed") {

jQuery("#"+this.questionId+" .ChoiceRow").each(function() {
// if you want to change individual rows you can put in something like if(Math.random() < 0.5) {...
// the draw back is that when the screen is redrawn due to an unswered question it can change again
var row = jQuery(this);
row.children().each(function(i) { row.prepend(jQuery(this)); });
row.find("th").first().removeClass("AnswerLeft").addClass("AnswerRight");
row.find("th").last().removeClass("AnswerRight").addClass("AnswerLeft");

});

}

});
image.png


Rod,
I would still use JS and Math.Random to randomize the first time, then save the randomization data in an embedded field. Use that saved randomization data if it is populated.


Leave a Reply