Skip to content

Commit

Permalink
Feat: Review changes for current_due_date, teammate_review_allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikjadhav01 committed Mar 20, 2023
1 parent daf9491 commit f33a44e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/controllers/student_teams_controller.rb
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions app/helpers/due_date_helper.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/models/assignment.rb
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions app/models/participant.rb
Expand Up @@ -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
Expand Down

0 comments on commit f33a44e

Please sign in to comment.