<commit_before>
= form_tag questionable.answers_create_multiple_path, method: :post, class: 'questions-form' do
  - assignments.each do |a|
    .question-block{:id => a.question.title.to_url}
      - q = a.question

      .question-and-note
        .question= q.title
        .note= q.note if q.note

      - selected_answers = a.answers_for_user(current_user)
      - selected_option_ids = selected_answers.map(&:option_id)
      - field = "answers[#{a.id}][]"

      - if q.accepts_multiple_answers?
        / Some inputs can take multiple answers (namely multiselects and checkboxes)
        - if q.input_type == 'checkboxes'
          = hidden_field_tag field
          - q.options.each do |opt|
            %label.checkbox
              = opt.title
              = check_box_tag field, opt.id, selected_option_ids.include?(opt.id)
        - elsif q.input_type == 'multiselect'
          = select_tag field,
            options_from_collection_for_select(q.options, 'id', 'title', selected_option_ids), multiple: true

      - else
        .compact-input
          / Most inputs just take a single answer
          - if q.input_type == 'select' 
            = select_tag "answers[#{a.id}][]", 
              options_from_collection_for_select(q.options, 'id', 'title', selected_option_ids.first), prompt: 'Choose an option'
          - elsif q.input_type == 'radio' 
            - q.options.each do |opt|
              %label.radio
                = opt.title
                %input{type: :radio, name: field, value: opt.id, checked: selected_option_ids.first == opt.id}
                =# radio_button_tag "answers[#{a.id}][]", opt.id, selected_option_ids.first
          - elsif q.input_type == 'string'
            = text_field_tag field, selected_answers.first.try(:message)
          - elsif q.input_type == 'date'
            =# select_date nil, field, order: [:month, :day, :year]
            =# date_select (Date.today - 20.years), field, order: [:month, :day, :year]

            - date = selected_answers.first.try(:message).blank? ? nil : selected_answers.first.message.to_date

            .date-fields
              = select_month date, {prompt: date.blank?}, name: "#{field}[month]", class: 'select-month'
              = select_day   date, {prompt: date.blank?}, name: "#{field}[day]", class: 'select-day'
              = select_year  date, 
                {prompt: date.blank?, start_year: (Date.today-13.years).year, end_year: (Date.today-70.years).year}, 
                name: "#{field}[year]", class: 'select-year'

  .form-actions
    - label = local_assigns.has_key?(:submit_label) ? submit_label : 'Save'
    = submit_tag label, class: 'btn'<commit_msg>do not apply compact input to radio buttons<commit_after>
= form_tag questionable.answers_create_multiple_path, method: :post, class: 'questions-form' do
  - assignments.each do |a|
    .question-block{:id => a.question.title.to_url}
      - q = a.question

      .question-and-note
        .question= q.title
        .note= q.note if q.note

      - selected_answers = a.answers_for_user(current_user)
      - selected_option_ids = selected_answers.map(&:option_id)
      - field = "answers[#{a.id}][]"

      - if q.accepts_multiple_answers?
        / Some inputs can take multiple answers (namely multiselects and checkboxes)
        - if q.input_type == 'checkboxes'
          = hidden_field_tag field
          - q.options.each do |opt|
            %label.checkbox
              = opt.title
              = check_box_tag field, opt.id, selected_option_ids.include?(opt.id)
        - elsif q.input_type == 'multiselect'
          = select_tag field,
            options_from_collection_for_select(q.options, 'id', 'title', selected_option_ids), multiple: true

      - else
        / Most inputs just take a single answer
        - if q.input_type == 'radio' 
          - q.options.each do |opt|
            %label.radio
              = opt.title
              %input{type: :radio, name: field, value: opt.id, checked: selected_option_ids.first == opt.id}
              =# radio_button_tag "answers[#{a.id}][]", opt.id, selected_option_ids.first
        - else
          .compact-input
            - if q.input_type == 'select' 
              = select_tag "answers[#{a.id}][]", 
                options_from_collection_for_select(q.options, 'id', 'title', selected_option_ids.first), prompt: 'Choose an option'
            - elsif q.input_type == 'string'
              = text_field_tag field, selected_answers.first.try(:message)
            - elsif q.input_type == 'date'
              =# select_date nil, field, order: [:month, :day, :year]
              =# date_select (Date.today - 20.years), field, order: [:month, :day, :year]

              - date = selected_answers.first.try(:message).blank? ? nil : selected_answers.first.message.to_date

              .date-fields
                = select_month date, {prompt: date.blank?}, name: "#{field}[month]", class: 'select-month'
                = select_day   date, {prompt: date.blank?}, name: "#{field}[day]", class: 'select-day'
                = select_year  date, 
                  {prompt: date.blank?, start_year: (Date.today-13.years).year, end_year: (Date.today-70.years).year}, 
                  name: "#{field}[year]", class: 'select-year'

  .form-actions
    - label = local_assigns.has_key?(:submit_label) ? submit_label : 'Save'
    = submit_tag label, class: 'btn'
{'fraction_non_alphanumeric': 0.13297676134267797, 'fraction_numerical': 0.0022132054592401327, 'mean_word_length': 2.2649006622516556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3395127', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1673, 'n_words': 355}