Skip to content

Commit

Permalink
handle the case where there are no groups
Browse files Browse the repository at this point in the history
  • Loading branch information
bmesuere committed Nov 12, 2023
1 parent 08e138b commit c342f82
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/helpers/renderers/feedback_table_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,23 @@ def tab_content(t, tab_i)
@diff_type = determine_tab_diff_type(t)
show_hide_correct = show_hide_correct_switch t
show_diff_type = show_diff_type_switch t
groups_correct = t[:groups].count { |g| g[:accepted] }
groups_total = t[:groups].count
groups_correct = t[:groups]&.count { |g| g[:accepted] } || 0
groups_total = t[:groups]&.count || 0
expand_all = groups_correct == groups_total

@builder.div(class: 'feedback-table-options sticky') do
# summary of tests
@builder.div(class: 'tab-summary') do
@builder.span(class: 'tab-summary-text') do
@builder.text! "#{groups_correct}/#{groups_total} #{I18n.t('submissions.show.correct_group').downcase}:"
end
@builder.div(class: 'tab-summary-icons') do
t[:groups]&.each_with_index do |g, i|
@builder.div(class: g[:accepted] ? 'correct' : 'wrong') do
@builder.a(href: "#tab-#{tab_i + 1}-group-#{i + 1}", title: "##{i + 1}") do
@builder.i(class: "mdi mdi-12 #{g[:accepted] ? 'mdi-check' : 'mdi-close'}") {}
if groups_total > 0
@builder.span(class: 'tab-summary-text') do
@builder.text! "#{groups_correct}/#{groups_total} #{I18n.t('submissions.show.correct_group').downcase}:"
end
@builder.div(class: 'tab-summary-icons') do
t[:groups]&.each_with_index do |g, i|
@builder.div(class: g[:accepted] ? 'correct' : 'wrong') do
@builder.a(href: "#tab-#{tab_i + 1}-group-#{i + 1}", title: "##{i + 1}") do
@builder.i(class: "mdi mdi-12 #{g[:accepted] ? 'mdi-check' : 'mdi-close'}") {}
end
end
end
end
Expand Down

0 comments on commit c342f82

Please sign in to comment.