How do you randomize answer choices on CrowdFlower?

1.3k Views Asked by At

We're using CrowdFlower in tandem with Amazon Mechanical Turk. Our questions have the same set of answers to choose from, so we'd like to randomize the order in which they appear, in order to keep users alert and hopefully dissuade them from cheating.

We want to be able to insert a script into the CML (CrowdFlower Markup Language) Documentation that could be applied to all the questions. We think inserting some JavaScript would be the right way to go. Any tips would be welcome.

2

There are 2 best solutions below

4
Chris Van Pelt On

You can achieve this with a small snippet of javascript. All you'll need to do is add a class="rando" attribute to the cml:radios or cml:checkboxes tag that you want to randomize, and place the following code in the javascript portion of the advanced editor (this assumes you have fewer than 10 choices in your cml:radios or cml:checkboxes tag):

$$('.cml_field.rando input').sort(function(a,b) {
   return Math.round(Math.random()*10) - 1 
}).each(function(o) { 
   o.getParent('.cml_row').inject(o.getParent('.cml_field')) 
})
0
mrgordon On

You can also use the random Liquid filter:

{% capture my_value %}{{ 3 | random }}{% endcapture %}
{% case my_value %}
{% when "1" %}
  One
{% when "2" %}
  Two
{% when "0" %}
  Zero
{% endcase %}