div.btn-group
  - if current_course_user
    - submissions = assessment.submissions.select { |s| s.creator == current_user }
    - attempting_submission = submissions.find(&:attempting?)
    - submitted_submission = submissions.find { |s| !s.attempting? }
    - if attempting_submission
      = link_to(t('.resume'), edit_course_assessment_submission_path(current_course,
          assessment, attempting_submission), class: ['btn', 'btn-info'])
    - elsif submitted_submission
      = link_to(t('.view'), edit_course_assessment_submission_path(current_course,
          assessment, submitted_submission), class: ['btn', 'btn-info'])
    - elsif can?(:attempt, assessment)
      = link_to t('.attempt'), course_assessment_submissions_path(current_course, assessment),
                class: ['btn','btn-info'], method: :post
  - else
    = link_to(t('.attempt'), '#', class: ['btn', 'btn-info', 'disabled'])

  - if can?(:manage, assessment)
    = link_to(course_assessment_submissions_path(current_course, assessment),
              class: ['btn', 'btn-default']) do
      span.visible-xs-block = fa_icon 'book'
      span.hidden-xs = t('.submissions')

div.btn-group
  - if current_course_user
    / If submissions are preloaded, find through the array. Otherwise, execute a SQL query.
    / Remove N+1 Queries on this partial.
    - submissions = assessment.submissions.loaded? ? \
          assessment.submissions.select { |s| s.creator == current_user } : \
          assessment.submissions.where(creator: current_user)

    - attempting_submission = submissions.find(&:attempting?)
    - submitted_submission = submissions.find { |s| !s.attempting? }
    - if attempting_submission
      = link_to(t('.resume'), edit_course_assessment_submission_path(current_course,
          assessment, attempting_submission), class: ['btn', 'btn-info'])
    - elsif submitted_submission
      = link_to(t('.view'), edit_course_assessment_submission_path(current_course,
          assessment, submitted_submission), class: ['btn', 'btn-info'])
    - elsif can?(:attempt, assessment)
      = link_to t('.attempt'), course_assessment_submissions_path(current_course, assessment),
                class: ['btn','btn-info'], method: :post
  - else
    = link_to(t('.attempt'), '#', class: ['btn', 'btn-info', 'disabled'])

  - if can?(:manage, assessment)
    = link_to(course_assessment_submissions_path(current_course, assessment),
              class: ['btn', 'btn-default']) do
      span.visible-xs-block = fa_icon 'book'
      span.hidden-xs = t('.submissions')

Fix N+1 query when submissions are not preloaded for assessments.
Fix N+1 query when submissions are not preloaded for assessments.

Coursemology/coursemology2,cysjonathan/coursemology2,Coursemology/coursemology2,Coursemology/coursemology2,Coursemology/coursemology2,cysjonathan/coursemology2,cysjonathan/coursemology2,Coursemology/coursemology2,Coursemology/coursemology2,Coursemology/coursemology2