<commit_before><p>
  <b>Author:</b>
  <%=h @poll.author %>
</p>

<p>
  <b>Title:</b>
  <%=h @poll.title %>
</p>

<p>
  <b>Created at:</b>
  <%=h @poll.created_at %>
</p>

<p>
  <b>Description:</b>
  <%=h @poll.description %>
</p>

<%
  if params[:action] == 'index'
    form_url = participants_path
  elsif params[:action] == 'edit' or params[:action] == 'update'
    form_url = participant_path
  end
%>

<% form_for @participant, :url => form_url do |f| %>
  <%= f.error_messages %>
  <%=
    # prepare radio buttons and print mapping to choice_ids
    # can't do this inline, fields_for has to be the outer loop
    radio_buttons = []
    choice_mappings = ''
    f.fields_for :entries do |ef|
      radio_buttons << @poll.options.map do |option_key, _|
        ef.radio_button :answer, option_key
      end
      choice_mappings << ef.hidden_field(:choice_id) + "\n"
    end
    choice_mappings
  %>

  <table>

    <%# table header %>
    <tr>
      <th>Name</th>
      <% @choices.each do |choice| %>
        <th><%=h choice.title %></th>
      <% end %>
    </tr>

    <% @participants.each do |participant| %>
      <% unless participant == @participant %>

        <%# show participants %>
        <tr>
          <td><%=h participant.name %></td>
          <%# TODO: handle event, when there are gaps %>
          <% participant.entries.each do |entry| %>
            <td><%=h @poll.options[entry.answer] %></td>
          <% end %>
          <td>
            <%= link_to 'Edit', edit_participant_path(@poll, participant) %>
            <%= link_to 'Destroy', participant_path(@poll, participant), :confirm => 'Are you sure?', :method => :delete %>
          </td>
        </tr>

      <% else %>

        <%# edit participant %>
        <% @poll.options.each_with_index do |option, i| %>
          <% option_key, option_name = option %>
          <tr>
            <% if i == 0 %>
              <td rowspan="<%=h @poll.options.count %>">
                <%= f.text_field :name %><br />
                <%= f.submit %>
                <% if params[:action] == 'edit' %><commit_msg>small bugfix in participant _form edit<commit_after><p>
  <b>Author:</b>
  <%=h @poll.author %>
</p>

<p>
  <b>Title:</b>
  <%=h @poll.title %>
</p>

<p>
  <b>Created at:</b>
  <%=h @poll.created_at %>
</p>

<p>
  <b>Description:</b>
  <%=h @poll.description %>
</p>

<%
  if params[:action] == 'index'
    form_url = participants_path
  elsif params[:action] == 'edit' or params[:action] == 'update'
    form_url = participant_path
  end
%>

<% form_for @participant, :url => form_url do |f| %>
  <%= f.error_messages %>
  <%=
    # prepare radio buttons and print mapping to choice_ids
    # can't do this inline, fields_for has to be the outer loop
    radio_buttons = []
    choice_mappings = ''
    f.fields_for :entries do |ef|
      radio_buttons << @poll.options.map do |option_key, _|
        ef.radio_button :answer, option_key
      end
      choice_mappings << ef.hidden_field(:choice_id) + "\n"
    end
    choice_mappings
  %>

  <table>

    <%# table header %>
    <tr>
      <th>Name</th>
      <% @choices.each do |choice| %>
        <th><%=h choice.title %></th>
      <% end %>
    </tr>

    <% @participants.each do |participant| %>
      <% unless participant == @participant %>

        <%# show participants %>
        <tr>
          <td><%=h participant.name %></td>
          <%# TODO: handle event, when there are gaps %>
          <% participant.entries.each do |entry| %>
            <td><%=h @poll.options[entry.answer] %></td>
          <% end %>
          <td>
            <%= link_to 'Edit', edit_participant_path(@poll, participant) %>
            <%= link_to 'Destroy', participant_path(@poll, participant), :confirm => 'Are you sure?', :method => :delete %>
          </td>
        </tr>

      <% else %>

        <%# edit participant %>
        <% @poll.options.each_with_index do |option, i| %>
          <% option_key, option_name = option %>
          <tr>
            <% if i == 0 %>
              <td rowspan="<%=h @poll.options.count %>">
                <%= f.text_field :name %><br />
                <%= f.submit %>
                <% if params[:action] == 'edit' or params[:action] == 'update' %>
{'fraction_non_alphanumeric': 0.18256967406707605, 'fraction_numerical': 0.0004723665564478035, 'mean_word_length': 2.1842105263157894, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2348768', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1396, 'n_words': 328}