Skip to content
Snippets Groups Projects
Commit 02b1959f authored by Ben Adida's avatar Ben Adida
Browse files

add per question random order

parent f5b021e3
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
<h4>
{#if $T.admin_p}[
{#if $T.question$index > 0}<a href="javascript:question_move_up({$T.question$index});">^</a>]&nbsp;[{#/if}
<a onclick="return confirm('Are you sure you want to remove this question?');" href="javascript:question_remove({$T.question$index})">x</a>] [<a href="javascript:question_edit({$T.question$index})">edit</a>] {#/if}{$T.question$index + 1}. {$T.question.question} ({$T.question.choice_type}, select between {$T.question.min} and {#if $T.question.max != null}{$T.question.max}{#else}unlimited{#/if} answers, result type {$T.question.result_type}.)</h4>
<a onclick="return confirm('Are you sure you want to remove this question?');" href="javascript:question_remove({$T.question$index})">x</a>] [<a href="javascript:question_edit({$T.question$index})">edit</a>] {#/if}{$T.question$index + 1}. {$T.question.question} ({$T.question.choice_type}, select between {$T.question.min} and {#if $T.question.max != null}{$T.question.max}{#else}unlimited{#/if} answers, result type {$T.question.result_type}{#if $T.question.randomize_answer_order}, random answer order{#/if}.)</h4>
<ul>
{#foreach $T.question.answers as answer}
<li> {$T.answer}
......@@ -55,6 +55,13 @@ Result Type:&nbsp;
<option>relative</option>
</select>
&nbsp;&nbsp;
&nbsp;&nbsp;
Random Answer Order:&nbsp;
<select name="randomize_answer_order">
<option selected value="0">no</option>
<option value="1">yes</option>
</select>
</p>
<table id="answer_table_{$T.question$index}">
......@@ -115,6 +122,15 @@ Result Type:&nbsp;
<option>relative</option>
</select>
&nbsp;&nbsp;
&nbsp;&nbsp;
Random Answer Order:&nbsp;
<select name="randomize_answer_order">
<option selected value="0">no</option>
<option value="1">yes</option>
</select>
</p>
</p>
<table id="answer_table" style="width:100%;">
......
......@@ -39,7 +39,7 @@
if (form.max.value != "")
max = parseInt(form.max.value);
var new_q = {'question' : form.question.value, 'min': parseInt(form.min.value), 'max': max, 'short_name': form.question.value, 'answers': [], 'answer_urls': [], 'choice_type': form.choice_type.value, 'tally_type': 'homomorphic', 'result_type': form.result_type.value};
var new_q = {'question' : form.question.value, 'min': parseInt(form.min.value), 'max': max, 'short_name': form.question.value, 'answers': [], 'answer_urls': [], 'choice_type': form.choice_type.value, 'tally_type': 'homomorphic', 'result_type': form.result_type.value, 'randomize_answer_order': form.randomize_answer_order.value == "1"};
var i = 0;
while(true) {
i += 1;
......@@ -86,6 +86,7 @@
form[0].max.value = q_data.max;
form[0].question.value = q_data.question;
form[0].result_type.value = q_data.result_type;
form[0].randomize_answer_order.value = q_data.randomize_answer_order ? "1" : "0";
// add the answers
var answer_table = $('#answer_table_' + q_num);
......
......@@ -190,8 +190,8 @@ BOOTH.setup_election = function(raw_json, election_metadata) {
// initialize array so it is the identity permutation
$(ordering).each(function(j, answer) {ordering[j]=j;});
// if we want reordering, then we shuffle the array
if (election_metadata && election_metadata.randomize_answer_order) {
// if we want reordering, at election or question level, then we shuffle the array
if ((election_metadata && election_metadata.randomize_answer_order) || question.randomize_answer_order) {
shuffleArray(ordering);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment