<%page expression_filter="h"/>
<%! from openedx.core.djangolib.markup import HTML %>
<%
  def is_radio_input(choice_id):
    return input_type == 'radio' and ((isinstance(value, basestring) and (choice_id == value)) or (
      not isinstance(value, basestring) and choice_id in value
    ))
%>
<div class="choicegroup capa_inputtype" id="inputtype_${id}">
    <fieldset ${describedby_html}>
      % if response_data['label']:
        <legend id="${id}-legend" class="response-fieldset-legend field-group-hd">${response_data['label']}</legend>
      % endif
      % for description_id, description_text in response_data['descriptions'].items():
        <p class="question-description" id="${description_id}">${description_text}</p>
      % endfor
        % for choice_id, choice_label in choices:
          <div class="field">
            <%
              label_class = 'response-label field-label label-inline'
            %>

            <label id="${id}-${choice_id}-label"
                ## If the student has selected this choice...
                % if is_radio_input(choice_id):

                    % if status.classname and not show_correctness == 'never':
                        <% label_class += ' choicegroup_' + status.classname %>
                    % endif
                % endif
                class="${label_class}"
                ${describedby_html}
                >
                <input type="${input_type}" name="input_${id}${name_array_suffix}" id="input_${id}_${choice_id}" class="field-input input-${input_type}" value="${choice_id}"
                ## If the student selected this choice...
                % if is_radio_input(choice_id):
                checked="true"
                % elif input_type != 'radio' and choice_id in value:
                checked="true"
                % endif
                /> ${HTML(choice_label)}
                % if is_radio_input(choice_id):
                  % if not show_correctness == 'never' and status.classname != 'unanswered':
                    <%include file="status_span.html" args="status=status, status_id=id"/>
                  % endif
                % endif
            </label>
          </div>
        % endfor
        <span id="answer_${id}"></span>
    </fieldset>
    <div class="indicator-container">
        % if input_type == 'checkbox' or status.classname == 'unanswered':
          % if show_correctness != 'never':
            <%include file="status_span.html" args="status=status, status_id=id"/>
          % else:
            <%include file="status_span.html" args="status=status, status_id=id, hide_correctness=True"/>
          % endif
        % endif
    </div>
    % if show_correctness == "never" and (value or status not in ['unsubmitted']):
    <div class="capa_alert">${submitted_message}</div>
    %endif
    % if msg:
    <span class="message" aria-describedby="${id}-legend" tabindex="-1">${HTML(msg)}</span>
    % endif
</div>
