diff --git a/app/controllers/student_teams_controller.rb b/app/controllers/student_teams_controller.rb index 4763841b180..2dc1932bbfa 100644 --- a/app/controllers/student_teams_controller.rb +++ b/app/controllers/student_teams_controller.rb @@ -51,11 +51,11 @@ def view @send_invs = Invitation.where from_id: student.user.id, assignment_id: student.assignment.id @received_invs = Invitation.where to_id: student.user.id, assignment_id: student.assignment.id, reply_status: 'W' - @current_due_date = DueDateHelper.current_due_date(@student.assignment.due_dates) + @current_due_date = @student.assignment.current_due_date # this line generates a list of users on the waiting list for the topic of a student's team, @users_on_waiting_list = (SignUpTopic.find(@student.team.topic).users_on_waiting_list if student_team_requirements_met?) - @teammate_review_allowed = DueDateHelper.teammate_review_allowed(@student) + @teammate_review_allowed = @student.teammate_review_allowed end def create diff --git a/app/helpers/due_date_helper.rb b/app/helpers/due_date_helper.rb deleted file mode 100644 index a6546afc729..00000000000 --- a/app/helpers/due_date_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DueDateHelper - def current_due_date(due_dates) - due_dates.detect { |due_date| due_date.due_at > Time.now } - end - - def teammate_review_allowed(student) - # time when teammate review is allowed - due_date = current_due_date(student.assignment.due_dates) - student.assignment.find_current_stage == 'Finished' || - due_date && - (due_date.teammate_review_allowed_id == 3 || - due_date.teammate_review_allowed_id == 2) # late(2) or yes(3) - end -end diff --git a/app/models/assignment.rb b/app/models/assignment.rb index 8e90cea2449..208932df845 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -650,6 +650,10 @@ def get_following_assignment_due_dates(assignment_id, topic_id = nil) following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1] end + def current_due_date + due_dates.detect { |due_date| due_date.due_at > Time.now } + end + private # returns true if assignment has staggered deadline and topic_id is nil diff --git a/app/models/participant.rb b/app/models/participant.rb index 54df02d2e44..f64abe6e398 100644 --- a/app/models/participant.rb +++ b/app/models/participant.rb @@ -118,6 +118,15 @@ def authorization authorization end + def teammate_review_allowed + # time when teammate review is allowed + due_date = assignment.current_due_date + assignment.find_current_stage == 'Finished' || + due_date && + (due_date.teammate_review_allowed_id == 3 || + due_date.teammate_review_allowed_id == 2) # late(2) or yes(3) + end + # Sort a set of participants based on their user names. # Please make sure there is no duplicated participant in this input array. # There should be a more beautiful way to handle this, though. -Yang