Skip to content

Commit dd628fa

Browse files
committed
handle copy from first mark edge cases a bit more gracefully
Sometimes the first mark has a single answer in multi option, largely because an import script has got it wrong, and rather than fail to copy this across try and do the right thing.
1 parent bc234fb commit dd628fa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crowdsourcer/templates/crowdsourcer/authority_audit_questions.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,15 @@ <h3 class="h5 text-muted mb-3 mb-lg-4">Audited response</h3>
222222
});
223223

224224
if(first_mark_responses.multi_option){
225-
audit_responses.querySelectorAll('[name$="multi_option"]').forEach(function(checkbox){
226-
checkbox.checked = ( first_mark_responses.multi_option.indexOf(checkbox.value) > -1 );
227-
});
225+
// occassionally the type of response has changed or an automated import has put the answer in
226+
// the wrong place so try to handle this gracefully
227+
if (audit_responses.querySelectorAll('[name$="multi_option"]').length > 0) {
228+
audit_responses.querySelectorAll('[name$="multi_option"]').forEach(function(checkbox){
229+
checkbox.checked = ( first_mark_responses.multi_option.indexOf(checkbox.value) > -1 );
230+
});
231+
} else if (audit_responses.querySelector('[name$="option"]').length > 0 && first_mark_responses.multi_option.length == 1) {
232+
audit_responses.querySelector('[name$="option"]').value = first_mark_responses.multi_option[0];
233+
}
228234
} else {
229235
audit_responses.querySelector('[name$="option"]').value = first_mark_responses.option;
230236
}

0 commit comments

Comments
 (0)