h1 = Submission.model_name.human(count: 2)

= render(layout: 'shared/form_filters') do |f|
  .form-group
    = f.label(:exercise_id_eq, t('activerecord.attributes.submission.exercise'), class: 'sr-only')
    = f.collection_select(:exercise_id_eq, Exercise.with_submissions, :id, :title, class: 'form-control', prompt: t('activerecord.attributes.submission.exercise'))
  .form-group
    = f.label(:cause_eq, t('activerecord.attributes.submission.cause'), class: 'sr-only')
    = f.select(:cause_eq, Submission.all.map(&:cause).uniq.sort, class: 'form-control', prompt: t('activerecord.attributes.submission.cause'))

.table-responsive
  table.table
    thead
      tr
        th = sort_link(@search, :exercise_id, t('activerecord.attributes.submission.exercise'))
        th = sort_link(@search, :user_id, t('activerecord.attributes.submission.user'))
        th = sort_link(@search, :cause, t('activerecord.attributes.submission.cause'))
        th = sort_link(@search, :score, t('activerecord.attributes.submission.score'))
        th = sort_link(@search, :created_at, t('shared.created_at'))
        th colspan=2 = t('shared.actions')
    tbody
      - @submissions.each do |submission|
        tr
          td = link_to(submission.exercise, submission.exercise)
          td = link_to(submission.user, submission.user)
          td = t("submissions.causes.#{submission.cause}")
          td = submission.score
          td = l(submission.created_at, format: :short)
          td = link_to(t('shared.show'), submission)
          td = link_to(t('shared.statistics'), statistics_submission_path(submission))

= render('shared/pagination', collection: @submissions)
