Here's what I have for a multiple choice question type:
Code that allows me to select up to 3 (or any number) and disable selection of other answers.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Maximun answers
var maxAnswers = 3;
// Identify this question
var thisQuestion = $('#question{QID}');
function checkMax() {
$('input.checkbox', thisQuestion).prop('disabled', false);
if($('input.checkbox:checked', thisQuestion).length >= maxAnswers) {
$('input.checkbox', thisQuestion).not(':checked').prop('disabled', true);
}
}
// Initial checkbox states
checkMax();
// Listener on the checkboxes
$('input.checkbox', thisQuestion).change(function(e) {
checkMax();
});
// Remove any "disabled" properties before submitting
$('#movenextbtn, #movesubmitbtn').bind('click', function () {
$('input.checkbox', thisQuestion).prop('disabled', false);
});
});
</script>
I also have a code that will uncheck and disable selection of answer options if the exclusive answer is selected.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Identify this question
var thisQuestion = $('#question{QID}');
// Uncheck all excluded items
$('div.question-item:last input.checkbox', thisQuestion).on('change', function(e) {
if($(this).is(':checked')) {
$('input.checkbox', thisQuestion).not($(this)).each(function(i) {
$(this).prop('checked', false);
$(this).nextAll('input:hidden:eq(0)').attr('value', '');
});
}
});
});
</script>
Additionally, I have code that allows me to fix answers to the bottom of the list:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
keepPos('{SGQ}',['6|6','7|7']) // keepPos('{SGQ}',['code|position','code|position'])
});
</script>
I frequently use the partial randomization code along with the other codes, however this time I'm attempting to combine all three of them. No matter which way I arrange the codes, or combine them, it doesn't work properly. I believe the issue lies within the "// Remove any "disabled" properties before submitting" section. When the exclusive option is selected, it allows for one more answer to be selected before the answer options are disabled. I'm hoping that a programmer can help me solve this issue. I've attached a .lss as well.