Skip to content

Commit

Permalink
updating display order more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Lerner committed Jan 18, 2024
1 parent 18554c6 commit 6ec0539
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def edit
end

def edit_weights
@ordered_assignments = @course.assignments.order(due_date: :asc, available: :asc, name: :asc, created_at: :asc)
@ordered_assignments = @course.assignments_sorted.reverse_order
end

def update_weights
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def show

if current_user_prof_for?(@course)
@abnormals = @course.abnormal_subs
@assns = @course.assignments_sorted
@assns = @course.assignments_sorted.to_a
@unpublished = @course.unpublished_grades
@missing_grading = @course.missing_grading.group_by(&:assignment)
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def first_professor
end

def assignments_sorted
self.assignments.to_a.sort_by(&:due_date)
self.assignments.order(:due_date, :available, :name, :created_at)
end

def all_partners
Expand Down Expand Up @@ -306,7 +306,7 @@ def missing_grading
def abnormal_subs
abnormals = {}
people = self.users_with_drop_info.where("registrations.dropped_date IS ?", nil).to_a
assns = self.assignments_sorted
assns = self.assignments_sorted.to_a
all_subs = Assignment.submissions_for(people, assns).group_by(&:assignment_id)
used_subs = UsedSub.where(assignment_id: assns.map(&:id)).group_by(&:assignment_id)
assns.each do |a|
Expand Down
2 changes: 1 addition & 1 deletion app/views/assignments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
</script>

<% else %>
<%= render "assignments/table", assignments: @course.assignments,
<%= render "assignments/table", assignments: @course.assignments_sorted.reverse_order,
for_user: current_user, show_all: false, show_weight: true %>
<%= render "assignments/grade_stats",
for_user: current_user, stats:
Expand Down
4 changes: 2 additions & 2 deletions app/views/courses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

<div class="row">
<div class="col-md-6">
<%= render "assignments/table", assignments: @course.assignments,
<%= render "assignments/table", assignments: @course.assignments_sorted.reverse_order,
for_user: current_user, show_all: show_all %>
<%= render "lateness_summary", assignments: @course.assignments,
<%= render "lateness_summary", assignments: @course.assignments_sorted.reverse_order,
for_user: current_user, show_all: show_all %>
<% if show_all %>
<%= render "abnormal_summary", abnormals: @abnormals %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/main/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="row">
<div class="col-md-7">
<%= render "assignments/table",
assignments: course.assignments,
assignments: course.assignments_sorted.reverse_order,
for_user: current_user, show_all: current_user.course_professor?(course) %>
</div>

Expand Down

0 comments on commit 6ec0539

Please sign in to comment.