Skip to content

Commit

Permalink
Fixed bug in reviews for no submission
Browse files Browse the repository at this point in the history
  • Loading branch information
SaNPai23 committed Feb 24, 2020
1 parent 1999414 commit 24d750f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/controllers/response_controller.rb
Expand Up @@ -108,7 +108,8 @@ def new
# A new response has to be created when there hasn't been any reviews done for the current round,
# or when there has been a submission after the most recent review in this round.
@response = Response.where(map_id: @map.id, round: @current_round.to_i).order(updated_at: :desc).first
if @response.nil? || AssignmentTeam.find(@map.reviewee_id).most_recent_submission.updated_at > @response.updated_at
most_recent_submission_by_reviewee = AssignmentTeam.find(@map.reviewee_id).most_recent_submission
if @response.nil? || (most_recent_submission_by_reviewee and most_recent_submission_by_reviewee.updated_at > @response.updated_at)
@response = Response.create(map_id: @map.id, additional_comment: '', round: @current_round, is_submitted: 0)
end
questions = sort_questions(@questionnaire.questions)
Expand Down
16 changes: 8 additions & 8 deletions app/views/student_review/_responses.html.erb
Expand Up @@ -30,9 +30,9 @@
&nbsp; (author: <%= participant.fullname%>)
<%end%>
</td>
<% latest_submission = team.most_recent_submission %>
<td>&nbsp;</td>
<% if !map.response.empty? %>
<% if !map.response.empty? && latest_submission%>
<% array_not_empty = 0 %>
<% @sorted_responses = Array.new %>
<% @prev = Response.where(:map_id => map.id) %>
Expand Down Expand Up @@ -61,7 +61,7 @@
<%- # show the link as 'Edit' when latest review is done in current round -%>
<%- # show link as 'Update' when latest review is done in different round or there has been a new submission in current round -%>
<% if (last_response_round == current_round)%>
<% latest_submission = team.most_recent_submission %>
<td>
<% if (!@latest_response.is_submitted) %>
<%= link_to "Edit", {:controller => 'response', :action => 'edit', :id => @latest_response.id} %>
Expand All @@ -75,13 +75,13 @@
<% end %>
<td><%= " -- latest update at #{@latest_response.updated_at.strftime("%a, %b %d, %Y %I:%M:%S %p")}" %></td>
<%end%>
<% elsif @assignment.get_current_stage(topic_id) != "Complete" && @assignment.can_review(topic_id) %>
<% elsif @assignment.get_current_stage(topic_id) != "Complete" && @assignment.can_review(topic_id) && latest_submission%>
<td><%= link_to "Begin", {:controller => 'response', :action => 'new', :id => map.id} %></td>
<td>&nbsp;&nbsp;</td>
<% else %>
<td>Begin</td>
<td> (Work has not yet been submitted) for
<% review_no += 1 %></td>
<!-- <td>Begin</td>-->
<td> Work has not yet been submitted for Review No.
<%= review_no %></td>
<% end %>
<% review_no+=1 %>
Expand All @@ -97,7 +97,7 @@
<% if map.type.to_s != "MetareviewResponseMap" %>
<% if @sorted_responses !=nil %>
<table class="grades" style=" font-style: italic; margin-left: 90px;">
<% if (@sorted_responses.size > 1) %>
<% if @sorted_responses.size > 1 %>
<%@sorted_responses = @sorted_responses.reverse%>
<% for i in 1..@sorted_responses.size-1 %>
<tr>
Expand Down

0 comments on commit 24d750f

Please sign in to comment.