Hello. I'd like to know how to anchor a subquestion in a multiple choice question using randomization. Attached is a test survey containing 2 examples of this scenario:
Test question #1: contains 4 subquestions
Test question #2: contains 5 subquestions, including an exclusive option ("None of the above"), which is automatically anchored; in this question, I'd like to anchor "Other" above "None of the above" in the list
Question 1, something like this in the script field:
Code:
// Sub-question code to be fixed at the bottom
var fixedCode = '4';
// Move the sub-question
$('#question{QID} .answers-list >ul:eq(0)').append($('#question{QID} li[id^="javatbd"][id$="X{QID}'+fixedCode+'"]'));
Question 2, something like this in the script field:
Code:
// Sub-question code to be fixed at second-bottom
var fixedCode = '4';
// Move the sub-question
$('#question{QID} li[id^="javatbd"]:last').before($('#question{QID} li[id^="javatbd"][id$="X{QID}'+fixedCode+'"]'));
How do I access the script field to add code to a question? I imported the attached test survey, and I see the script in "Question overview" mode, but when I switch to "Question editor," the script is replaced with the "Help" entry field.
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Sub-question code to be fixed at the bottom
var fixedCode = '4';
// Move the sub-question
$('#question{QID} .answers-list >ul:eq(0)').append($('#question{QID} li[id^="javatbd"][id$="X{QID}'+fixedCode+'"]'));
});
</script>
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Sub-question code to be fixed at second-bottom
var fixedCode = '4';
// Move the sub-question
$('#question{QID} li[id^="javatbd"]:last').before($('#question{QID} li[id^="javatbd"][id$="X{QID}'+fixedCode+'"]'));
});
</script>