Commit fba80629 by Ehtesham

wrapping labels according to sample html

parent 6dccdbe3
...@@ -251,7 +251,9 @@ class LoncapaResponse(object): ...@@ -251,7 +251,9 @@ class LoncapaResponse(object):
- response_msg: a message displayed at the end of the Response - response_msg: a message displayed at the end of the Response
""" """
# render ourself as a <span> + our content # render ourself as a <span> + our content
tree = etree.Element('span') tree = etree.Element('section')
tree.set('class', 'wrapper-problem-response')
tree.set('tabindex', '-1')
# problem author can make this span display:inline # problem author can make this span display:inline
if self.xml.get('inline', ''): if self.xml.get('inline', ''):
......
<form class="choicegroup capa_inputtype" id="inputtype_${id}"> <form class="choicegroup capa_inputtype" id="${id}-form">
<fieldset role="${input_type}group" aria-label="${label}"> <fieldset role="${input_type}group" aria-label="${label}">
% if response_data['label']: % if response_data['label']:
<legend id="${id}-legend" class="response-fieldset-legend">${response_data['label']}</legend> <legend id="${id}-legend" class="response-fieldset-legend field-group-hd">${response_data['label']}</legend>
% endif % endif
% for choice_id, choice_description in choices: % for choice_id, choice_description in choices:
<label for="input_${id}_${choice_id}" <div class="field" aria-live="polite" aria-atomic="true">
## If the student has selected this choice...
% if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ):
<% <%
if status == 'correct': label_class = 'response-label field-label label-inline'
correctness = 'correct'
elif status == 'partially-correct':
correctness = 'partially-correct'
elif status == 'incorrect':
correctness = 'incorrect'
else:
correctness = None
%> %>
% if correctness and not show_correctness == 'never': <label id="${id}-{$choice_id}-label"
class="choicegroup_${correctness}" ## If the student has selected this choice...
% endif % if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ):
% endif <%
> if status == 'correct':
<input type="${input_type}" name="input_${id}${name_array_suffix}" id="input_${id}_${choice_id}" aria-role="radio" aria-describedby="answer_${id}" value="${choice_id}" correctness = 'correct'
## If the student selected this choice... elif status == 'partially-correct':
% if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ): correctness = 'partially-correct'
checked="true" elif status == 'incorrect':
% elif input_type != 'radio' and choice_id in value: correctness = 'incorrect'
checked="true" else:
% endif correctness = None
% if input_type != 'radio': %>
aria-multiselectable="true" % if correctness and not show_correctness == 'never':
% endif <% label_class += ' choicegroup_${correctness}' %>
% endif
% endif
class="${label_class}"
>
<input type="${input_type}" name="input_${id}${name_array_suffix}" id="input_${id}_${choice_id}" class="field-input input-${input_type}" aria-role="radio" aria-describedby="answer_${id}" value="${choice_id}"
## If the student selected this choice...
% if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ):
checked="true"
% elif input_type != 'radio' and choice_id in value:
checked="true"
% endif
% if input_type != 'radio':
aria-multiselectable="true"
% endif
/> ${choice_description} /> ${choice_description}
% if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ): % if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ):
% if status in ('correct', 'partially-correct', 'incorrect') and not show_correctness=='never': % if status in ('correct', 'partially-correct', 'incorrect') and not show_correctness=='never':
<span class="sr status">${choice_description|h} - ${status.display_name}</span> <span class="sr status" id="${id}-{$choice_id}-labeltext">${choice_description|h} - ${status.display_name}</span>
% endif % endif
% endif % endif
</label> </label>
</div>
% endfor % endfor
<span id="answer_${id}"></span> <span id="answer_${id}"></span>
</fieldset> </fieldset>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment