Skip to content

Commit

Permalink
Finish implementation of section column in Submissions page.
Browse files Browse the repository at this point in the history
  • Loading branch information
hansonywu authored and lakeskysea committed Feb 6, 2012
1 parent e198359 commit a89e715
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/controllers/submissions_controller.rb
Expand Up @@ -79,6 +79,11 @@ class SubmissionsController < ApplicationController
},
'grace_credits_used' => lambda { |a,b|
return a.grace_period_deduction_sum <=> b.grace_period_deduction_sum
},
'section' => lambda { |a,b|
return -1 if !a.section
return 1 if !b.section
return a.section <=> b.section
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/helpers/pagination_helper.rb
Expand Up @@ -70,6 +70,7 @@ def get_filtered_items(hash, filter, sort_by, object_hash)
case sort_by
when "group_name" then to_include = [:group]
when "repo_name" then to_include = [:group]
when "section" then to_include = [:group]
when "revision_timestamp" then to_include = [:current_submission_used]
when "marking_state" then to_include = [{:current_submission_used => :result}]
when "total_mark" then to_include = [{:current_submission_used => :result}]
Expand Down
9 changes: 5 additions & 4 deletions app/models/grouping.rb
Expand Up @@ -559,14 +559,15 @@ def all_assigned_criteria(ta_array)
return result.map{|a| a.criterion}.uniq
end

def grouping_section
section = nil
# 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.
def section
self.students.each do |student|
if student.has_section?
section = student.section.name
return student.section.name
end
end
return section
return nil
end

private
Expand Down
11 changes: 9 additions & 2 deletions app/views/submissions/_submissions_table_sorting_links.html.erb
Expand Up @@ -66,8 +66,15 @@
:sort_by => 'total_mark',
:desc => (sort_by == 'total_mark' && desc.blank?) %>
</th>
<th>
<%= I18n.t("browse_submissions.section") %>
<th class="<%="ap_sorting_by" if (sort_by == 'section')%>
<%="ap_sorting_by_desc" if (sort_by == 'section' && !desc.blank?)%>">
<%= link_to I18n.t("browse_submissions.section"),
:id => assignment.id,
:filter => filter,
:page => page,
:per_page => per_page,
:sort_by => 'section',
:desc => (sort_by == 'section' && desc.blank?) %>
</th>
<th>
<%= I18n.t("browse_submissions.can_begin_grading") %>
Expand Down
Expand Up @@ -129,7 +129,7 @@
<% end %>
</td>
<td>
<%= h(grouping.grouping_section) %>
<%= h(grouping.section) %>
</td>
<td>
<% if Time.now >= assignment.submission_rule.calculate_grouping_collection_time(grouping) %>
Expand Down

0 comments on commit a89e715

Please sign in to comment.