h1 = @exercise_collection

= row(label: 'exercise_collections.name', value: @exercise_collection.name)
= row(label: 'exercise_collections.updated_at', value: @exercise_collection.updated_at)
= row(label: 'exercise_collections.exercises', value: @exercise_collection.exercises.count)
= row(label: 'exercise_collections.users_and_programming_groups', value: Submission.from(@exercise_collection.exercises.joins(:submissions).group(:contributor_id, :contributor_type).select(:contributor_id, :contributor_type)).count)
= row(label: 'exercise_collections.solutions', value: Submission.from(@exercise_collection.exercises.joins(:submissions).group(:contributor_id, :contributor_type, :id).select(:contributor_id, :contributor_type)).count)
= row(label: 'exercise_collections.submissions', value: @exercise_collection.exercises.joins(:submissions).count)
/ further metrics:
/   number of contributors that attempted at least one exercise @exercise_collection.exercises.joins(:submissions).group("submissions.contributor_id", "submissions.contributor_type").count.count
/   number of solutions:                                  @exercise_collection.exercises.joins(:submissions).group("submissions.contributor_id", "submissions.contributor_type").group("id").count.count
/ further filters:
/     Only before specific date: date = DateTime.parse("2015-01-01 00:00:00.000000") ;  @exercise_collection.exercises.joins(:submissions).where(["submissions.created_at > ?", date]).group("submissions.contributor_id", "submissions.contributor_type").count.count
/     Only with specific cause: @exercise_collection.exercises.joins(:submissions).where("submissions.cause" == 'assess').count

= row(label: 'exercises.statistics.average_worktime', value: @exercise_collection.average_working_time.round(3).to_s + 's')

#graph
  #data.d-none(data-working-times=ActiveSupport::JSON.encode(@exercise_collection.collection_statistics) data-average-working-time=@exercise_collection.average_working_time)
  #legend
    - {time: t('exercises.statistics.average_worktime'),
        min: 'min. anomaly threshold',
        avg: 'average time',
        max: 'max. anomaly threshold'}.each_pair do |klass, label|
      .legend-entry
        div(class="box #{klass}")
        .box-label = label

h4.mt-4 = t('activerecord.attributes.exercise_collections.exercises')
.table-responsive#exercise-list
  table.table class="#{@exercise_collection.items.present? ? 'sortable' : ''}"
    thead
      tr
        th = '#'
        th = t('activerecord.attributes.exercise.title')
        th = t('activerecord.attributes.exercise.number_of_users_and_programming_groups')
        th = t('activerecord.attributes.exercise.distinct_final_submissions')
        th = t('activerecord.attributes.exercise.finishing_rate')
        th = t('activerecord.attributes.exercise.average_score_percentage')
        th = t('shared.actions')
    tbody
      - @exercise_collection.items.sort_by{|item| item.position}.each do |exercise_collection_item|
        - exercise = exercise_collection_item.exercise
        tr
          td = exercise_collection_item.position
          td = link_to_if(policy(exercise).show?, exercise.title, exercise)
          td = exercise.contributors.size
          td = exercise.submissions.send(:final).distinct.count(:contributor_id)
          td = exercise.finishers_percentage
          td = exercise.average_percentage
          td = link_to(t('shared.statistics'), statistics_exercise_path(exercise), 'data-turbolinks' => "false") if policy(exercise).statistics?
