<commit_before><%
  questionnaire ||= false
  with_header ||= false
  is_edit = ["edit", "update"].include?(params[:action]) && params[:controller] == "questions"

  form_url = nil

  if questionnaire
    form_url = is_edit ? questionnaire_question_path(questionnaire, question) : questionnaire_questions_path(questionnaire)
  end

%>

<% form_for question, :url => form_url, :builder => KPFormBuilder, :html => { :class => "question-form" } do |f| -%>

  <% if with_header %>
    <h2>Lägg till fråga</h2>
  <% end %>

  <%= f.validation_error_indicator -%>

  <% f.fields do %>
    <% f.row '', 'types-field-row' do -%>
      <label>Svarstyp på frågan:</label>

      <% f.field do -%>
        <% Question::QTYPES.keys.each do |type| %>
          <% val = h(Question::QTYPES[type.to_s]) -%>
          <%= f.single_radio_button :qtype, val %>
          <label for="kp-question-qtype_<%= val.downcase %>"><%= h(type) %></label>
        <% end -%>
      <% end -%>

    <% end -%>

    <%= f.text_field :question %>
    <%= f.text_field :choice_csv, :field_help => "Ange alternativen separerade med kommatecken", :row_hidden => (question.qtype != "QuestionMchoice") -%>
    <%= f.check_box :mandatory %>

  <% end %>

  <% f.buttons do -%>
    <%= f.hidden_field :template -%>
    <%= submit_tag(is_edit ? "Uppdatera" : "Lägg till") %>
  <% end -%>

<% end -%><commit_msg>Tillåt inte att ändra typ på frågor.<commit_after><%
  questionnaire ||= false
  with_header ||= false
  is_edit = ["edit", "update"].include?(params[:action]) && params[:controller] == "questions"

  form_url = nil

  if questionnaire
    form_url = is_edit ? questionnaire_question_path(questionnaire, question) : questionnaire_questions_path(questionnaire)
  end

%>

<% form_for question, :url => form_url, :builder => KPFormBuilder, :html => { :class => "question-form" } do |f| -%>

  <% if with_header %>
    <h2>Lägg till fråga</h2>
  <% end %>

  <%= f.validation_error_indicator -%>

  <% f.fields do %>
    <% unless is_edit -%>
      <% f.row '', 'types-field-row' do -%>
        <label>Svarstyp på frågan:</label>

        <% f.field do -%>
          <% Question::QTYPES.keys.each do |type| %>
            <% val = h(Question::QTYPES[type.to_s]) -%>
            <%= f.single_radio_button :qtype, val %>
            <label for="kp-question-qtype_<%= val.downcase %>"><%= h(type) %></label>
          <% end -%>
        <% end -%>

      <% end -%>
    <% end -%>

    <%= f.text_field :question %>
    <%= f.text_field :choice_csv, :field_help => "Ange alternativen separerade med kommatecken", :row_hidden => (question.qtype != "QuestionMchoice") -%>
    <%= f.check_box :mandatory %>

  <% end %>

  <% f.buttons do -%>
    <%= f.hidden_field :template -%>
    <%= submit_tag(is_edit ? "Uppdatera" : "Lägg till") %>
  <% end -%>

<% end -%>
{'fraction_non_alphanumeric': 0.19652974504249293, 'fraction_numerical': 0.00141643059490085, 'mean_word_length': 2.973277074542897, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 79, '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': '345269', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1014, 'n_words': 189}