diff --git a/app/controllers/submitted_content_controller.rb b/app/controllers/submitted_content_controller.rb
index b11252b808b..bea8a24c96c 100644
--- a/app/controllers/submitted_content_controller.rb
+++ b/app/controllers/submitted_content_controller.rb
@@ -32,8 +32,11 @@ def edit
# hence use team count for the check
SignUpSheet.signup_team(@assignment.id, @participant.user_id, nil) if @participant.team.nil?
# @can_submit is the flag indicating if the user can submit or not in current stage
- @can_submit = !params.key?(:view)
+ @can_submit = false
@stage = @assignment.current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))
+ if @stage == "submission"
+ @can_submit = true
+ end
end
# view is called when @assignment.submission_allowed(topic_id) is false
diff --git a/app/models/assignment.rb b/app/models/assignment.rb
index 8f9bed41aab..4c1f6580e97 100755
--- a/app/models/assignment.rb
+++ b/app/models/assignment.rb
@@ -189,8 +189,8 @@ def path
# Check whether review, metareview, etc.. is allowed
# The permissions of TopicDueDate is the same as AssignmentDueDate.
# Here, column is usually something like 'review_allowed_id'
- def check_condition(column, topic_id = nil)
- next_due_date = DueDate.get_next_due_date(id, topic_id)
+ def check_condition(column, topic_id = nil, deadline_type_id)
+ next_due_date = DueDate.get_next_due_date(id, topic_id, deadline_type_id)
return false if next_due_date.nil?
right_id = next_due_date.send column
@@ -200,22 +200,22 @@ def check_condition(column, topic_id = nil)
# Determine if the next due date from now allows for submissions
def submission_allowed(topic_id = nil)
- check_condition('submission_allowed_id', topic_id)
+ check_condition('submission_allowed_id', topic_id, 1)
end
# Determine if the next due date from now allows to take the quizzes
def quiz_allowed(topic_id = nil)
- check_condition('quiz_allowed_id', topic_id)
+ check_condition('quiz_allowed_id', topic_id, 11)
end
# Determine if the next due date from now allows for reviews
def can_review(topic_id = nil)
- check_condition('review_allowed_id', topic_id)
+ check_condition('review_allowed_id', topic_id, 2)
end
# Determine if the next due date from now allows for metareviews
def metareview_allowed(topic_id = nil)
- check_condition('review_of_review_allowed_id', topic_id)
+ check_condition('review_of_review_allowed_id', topic_id, 5)
end
# Deletes all instances created as part of assignment and finally destroys itself.
diff --git a/app/models/due_date.rb b/app/models/due_date.rb
index 94b07c9137a..e7ee32dec9a 100644
--- a/app/models/due_date.rb
+++ b/app/models/due_date.rb
@@ -88,7 +88,7 @@ def self.done_in_assignment_round(assignment_id, response)
round
end
- def self.get_next_due_date(assignment_id, topic_id = nil)
+ def self.get_next_due_date(assignment_id, topic_id = nil, deadline_type_id = 0)
if Assignment.find(assignment_id).staggered_deadline?
next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at >= ?', topic_id, Time.zone.now])
# if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.
@@ -113,7 +113,11 @@ def self.get_next_due_date(assignment_id, topic_id = nil)
end
end
else
- next_due_date = AssignmentDueDate.find_by(['parent_id = ? && due_at >= ?', assignment_id, Time.zone.now])
+ if deadline_type_id == 0
+ next_due_date = AssignmentDueDate.find_by(['parent_id = ? && due_at >= ? ', assignment_id, Time.zone.now])
+ else
+ next_due_date = AssignmentDueDate.find_by(['parent_id = ? && deadline_type_id = ? && due_at >= ? ', assignment_id, deadline_type_id, Time.zone.now])
+ end
end
next_due_date
end
diff --git a/app/views/submitted_content/_hyperlink.html.erb b/app/views/submitted_content/_hyperlink.html.erb
index 6b6117f5c34..6b1cade25a6 100644
--- a/app/views/submitted_content/_hyperlink.html.erb
+++ b/app/views/submitted_content/_hyperlink.html.erb
@@ -1,5 +1,5 @@
<%= form_for :hyperlinks, url: '/submitted_content/remove_hyperlink' do |f| %>
- <% unless stage == "Finished" %>
+ <% if stage != "Finished" && @can_submit%>
<% team_id = TeamsUser.team_id(participant.parent_id, participant.user_id) %>
<% display_to_author = Team.exists?(team_id) && Team.find(team_id).user?(@current_user)%>
diff --git a/app/views/submitted_content/_submitted_files.html.erb b/app/views/submitted_content/_submitted_files.html.erb
index dbf2d09f1c6..eb64b756b25 100644
--- a/app/views/submitted_content/_submitted_files.html.erb
+++ b/app/views/submitted_content/_submitted_files.html.erb
@@ -22,7 +22,7 @@
<% if files.length > 0 || stage != "Finished" %>
- <% if same_team_flag && stage != "Finished" %>
+ <% if same_team_flag && stage != "Finished" && @can_submit%>