Disable sorttable on tables without rows

Otherwise, the first element of the table body is being fetched which might result in an error for empty tables.

Fixes CODEOCEAN-JZ
This commit is contained in:
Sebastian Serth
2023-03-14 18:27:38 +01:00
parent 1c5eb09138
commit a99da79550
11 changed files with 12 additions and 12 deletions

View File

@@ -61,8 +61,9 @@ h1 = @exercise
- if !policy(@exercise).detailed_statistics?
- submissions = submissions.final
- if submissions.any?
- users = symbol.to_s.classify.constantize.where(id: submissions.joins(symbol).group(:user_id).select(:user_id).distinct)
.table-responsive
table.table.table-striped.sortable
table.table.table-striped class="#{users.present? ? 'sortable' : ''}"
thead
tr
th.header = t('.user')
@@ -71,7 +72,6 @@ h1 = @exercise
th.header = t('.runs') if policy(@exercise).detailed_statistics?
th.header = t('.worktime') if policy(@exercise).detailed_statistics?
tbody
- users = symbol.to_s.classify.constantize.where(id: submissions.joins(symbol).group(:user_id).select(:user_id).distinct)
- users.each do |user|
- if user_statistics[user.class.name][user.id] then us = user_statistics[user.class.name][user.id] else us = {"maximum_score" => nil, "runs" => nil}
- label = "#{user.displayname}"