From 007eb0138595dd6bff600ac7036207b3d98bb3fb Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Thu, 2 Feb 2012 11:39:26 +0100 Subject: [PATCH] Display section of a group in the submission view only if it is a "section groups only" assignment. --- app/models/grouping.rb | 13 ++++++------- .../_submissions_table_sorting_links.html.erb | 2 ++ .../submissions_table_row/_table_row.html.erb | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/models/grouping.rb b/app/models/grouping.rb index d1ad226267..a449507f4e 100644 --- a/app/models/grouping.rb +++ b/app/models/grouping.rb @@ -558,14 +558,13 @@ def all_assigned_criteria(ta_array) end return result.map{|a| a.criterion}.uniq end - - # Get the section for this group. Since all students must be in the same section to - # be in the same group, return the section name for the first student with a section. + + # Get the section for this group. If assignment restricts member of a groupe + # to a section, all students are in the same section. Therefore, return only + # the inviters section def section - self.students.each do |student| - if student.has_section? - return student.section.name - end + if !self.inviter.nil? and self.inviter.has_section? + return self.inviter.section.name end return '-' end diff --git a/app/views/submissions/_submissions_table_sorting_links.html.erb b/app/views/submissions/_submissions_table_sorting_links.html.erb index a0cb05e7d3..12381f4dae 100644 --- a/app/views/submissions/_submissions_table_sorting_links.html.erb +++ b/app/views/submissions/_submissions_table_sorting_links.html.erb @@ -66,6 +66,7 @@ :sort_by => 'total_mark', :desc => (sort_by == 'total_mark' && desc.blank?) %> + <% if assignment.section_groups_only %> <%="ap_sorting_by_desc" if (sort_by == 'section' && !desc.blank?)%>"> <%= link_to I18n.t("browse_submissions.section"), @@ -76,6 +77,7 @@ :sort_by => 'section', :desc => (sort_by == 'section' && desc.blank?) %> + <% end %> <%= I18n.t("browse_submissions.can_begin_grading") %> diff --git a/app/views/submissions/submissions_table_row/_table_row.html.erb b/app/views/submissions/submissions_table_row/_table_row.html.erb index c8a9631dd2..0f42f5c2e5 100644 --- a/app/views/submissions/submissions_table_row/_table_row.html.erb +++ b/app/views/submissions/submissions_table_row/_table_row.html.erb @@ -128,9 +128,14 @@ <% end %> <% end %> + + <%# We don't need to display the section of the group unless it is a section group + assignment %> + <% if assignment.section_groups_only %> <%= h(grouping.section) %> + <% end %> <% if Time.now >= assignment.submission_rule.calculate_grouping_collection_time(grouping) %> <%= image_tag('icons/tick.png') %>