<% element_checked = False %>
% for choice_id, _ in choices:
    <%choice_id = choice_id %>
    %if choice_id in value:
        <% element_checked = True %>
    %endif
%endfor
<section id="choicetextinput_${id}" class="choicetextinput">
<form class="choicetextgroup capa_inputtype" id="inputtype_${id}">
    <div class="script_placeholder" data-src="/static/js/capa/choicetextinput.js"/>
    <div class="indicator_container">
    % if input_type == 'checkbox' or not element_checked:
        % if status == 'unsubmitted':
        <span class="unanswered" style="display:inline-block;" id="status_${id}"></span>
        % elif status == 'correct':
        <span class="correct" id="status_${id}"></span>
        % elif status == 'incorrect':
        <span class="incorrect" id="status_${id}"></span>
        % elif status == 'incomplete':
        <span class="incorrect" id="status_${id}"></span>
        % endif
    % endif
    </div>

    <fieldset>
        % for choice_id, choice_description in choices:
        <%choice_id= choice_id %>
        <section id="forinput${choice_id}"
            % if input_type == 'radio' and choice_id in value :
            <%
                if status == 'correct':
                    correctness = 'correct'
                elif status == 'incorrect':
                    correctness = 'incorrect'
                else:
                    correctness = None
            %>
            % if correctness:
                class="choicetextgroup_${correctness}"
            % endif
            % endif
            >
            <input class="ctinput" type="${input_type}" name="choiceinput_${id}" id="${choice_id}" value="${choice_id}"

            % if choice_id in value:
            checked="true"
            % endif
            />

            % for content_node in choice_description:
                % if content_node['type'] == 'text':
                    <span class="mock_label">
                         ${content_node['contents']}
                     </span>
                % else:
                    <% my_id = content_node.get('contents','') %>
                    <% my_val = value.get(my_id,'') %>
                    <input class="ctinput" type="text" name="${content_node['contents']}" id="${content_node['contents']}" value="${my_val|h}"/>
                %endif
                <span class="mock_label">
                    ${content_node['tail_text']}
                </span>

            % endfor
            <p id="answer_${choice_id}" class="answer"></p>
                </section>

        % endfor
        <span id="answer_${id}"></span>
    </fieldset>
        <input class= "choicetextvalue" type="hidden"  name="input_${id}{}" id="input_${id}" value="${value|h}" />
    % if show_correctness == "never" and (value or status not in ['unsubmitted']):
    <div class="capa_alert">${submitted_message}</div>
    %endif
</form>
</section>
