<commit_before><table>
  <% review_no = 1 %>
  <% mappings.each do |map| %>
      <%- # ACS Have metareviews done for all teams   -%>
      <%- # removed code that handles team and individual assignments differently   -%>
      <% if map.type.to_s == "MetareviewResponseMap" %>
          <% logger.warn "map: #{map.inspect}" %>
          <% review_mapping = ResponseMap.find(map.reviewed_object_id) %>
          <% logger.warn "review_mapping: #{review_mapping.inspect}" %>
          <% participant = AssignmentTeam.first_member(review_mapping.reviewee_id) %>
      <% else %>
          <% participant = AssignmentTeam.first_member(map.reviewee_id) %>
      <% end %>

      <% if participant %>
          <% topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id) %>
          <tr>
            <td>
              <%round = map.round%>
              <%if round==nil %>
                  <%round = ""  %>
              <%else%>
                  <%round = " (Round"+round.to_s+")"  %>
              <%end%>

              <b><%= "#{title} #{review_no}." %></b> <%=round%>
              <!--In ‘student_review/list’ page, if the topic_identifier is empty, ‘:’ sign should not be displayed.-->
              <% if !topic_id.nil? %>
                  <% if SignUpTopic.find(topic_id).topic_identifier != '' %>
                      <%= " #{SignUpTopic.find(topic_id).topic_identifier}: #{SignUpTopic.find(topic_id).topic_name}" %>
                  <% else %>
                      <%= " #{SignUpTopic.find(topic_id).topic_name}" %>
                  <% end %>
              <% end %>
            </td>

            <td>&nbsp;</td>
            <% if map.response %>
                <% array_not_empty = 0 %>
                <% @sorted_responses = Array.new %>
                <% @prev = Response.where(:map_id => map.id) %>
                <% for element in @prev %>
                    <% array_not_empty = 1 %>
                    <% @sorted_responses << element %>
                <% end %>

                <% if (array_not_empty == 1) %>

                    <% @sorted_responses = @sorted_responses.sort { |a,b| a.updated_at <=> b.updated_at}%>
                    <% @latest_response = @sorted_responses.last %>
                    <% @latest_response_created_time = @latest_response.created_at %>
                    <% due_dates = DueDate.where(["assignment_id = ?", @assignment.id]) %>
                    <% @sorted_deadlines = Array.new %>
                    <% @sorted_deadlines = due_dates.sort { |m1, m2| (m1.due_at and m2.due_at) ? m1.due_at <=> m2.due_at : (m1.due_at ? -1 : 1) } %>
                    <% current_time = Time.new.getutc %>

                    <% for deadline_version in @sorted_deadlines %>
                      <% if (@latest_response.created_at < deadline_version.due_at) %>
                        <% break %>
                      <% end %>
                    <% end %>

                    <% for coming_deadline in @sorted_deadlines %>
                      <% if (current_time < coming_deadline.due_at) %>
                        <% break %>
                      <% end %>
                    <% end %>

                    <td>
                       <%= link_to "View", {:controller => 'response', :action => 'view', :id => @sorted_responses.first.id} %>
                    </td>

                    <% if @assignment.get_current_stage(topic_id) != "Finished" %>
                      <%- # show the link as edit when latest review is done in current deadline   -%>
                      <%- # show link as update when latest review is done in different deadline than current phase   -%>
                      <% if (deadline_version.due_at == coming_deadline.due_at) %>
                        <td><%= link_to "Edit", {:controller => 'response', :action => 'edit', :id => @sorted_responses.first.id} %></td>
                      <% else %>
                        <td><%= link_to "Update", {:controller => 'response', :action => 'new', :id => map.map_id} %></td>
                      <% end %>
                    <% end %>
                <%end%>
            <% elsif @assignment.get_current_stage(topic_id) != "Complete" %>
                <% if @assignment.staggered_deadline? %>
                            <% if map.type.to_s == "MetareviewResponseMap" %>
                                <% if @assignment.get_current_stage(topic_id) == 'metareview' %><commit_msg>Fix edit and view link on students' others' work list.<commit_after><table>
  <% review_no = 1 %>
  <% mappings.each do |map| %>
      <%- # ACS Have metareviews done for all teams   -%>
      <%- # removed code that handles team and individual assignments differently   -%>
      <% if map.type.to_s == "MetareviewResponseMap" %>
          <% logger.warn "map: #{map.inspect}" %>
          <% review_mapping = ResponseMap.find(map.reviewed_object_id) %>
          <% logger.warn "review_mapping: #{review_mapping.inspect}" %>
          <% participant = AssignmentTeam.first_member(review_mapping.reviewee_id) %>
      <% else %>
          <% participant = AssignmentTeam.first_member(map.reviewee_id) %>
      <% end %>

      <% if participant %>
          <% topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id) %>
          <tr>
            <td>
              <%round = map.round%>
              <%if round==nil %>
                  <%round = ""  %>
              <%else%>
                  <%round = " (Round"+round.to_s+")"  %>
              <%end%>

              <b><%= "#{title} #{review_no}." %></b> <%=round%>
              <!--In ‘student_review/list’ page, if the topic_identifier is empty, ‘:’ sign should not be displayed.-->
              <% if !topic_id.nil? %>
                  <% if SignUpTopic.find(topic_id).topic_identifier != '' %>
                      <%= " #{SignUpTopic.find(topic_id).topic_identifier}: #{SignUpTopic.find(topic_id).topic_name}" %>
                  <% else %>
                      <%= " #{SignUpTopic.find(topic_id).topic_name}" %>
                  <% end %>
              <% end %>
            </td>

            <td>&nbsp;</td>
            <% if map.response %>
                <% array_not_empty = 0 %>
                <% @sorted_responses = Array.new %>
                <% @prev = Response.where(:map_id => map.id) %>
                <% for element in @prev %>
                    <% array_not_empty = 1 %>
                    <% @sorted_responses << element %>
                <% end %>

                <% if (array_not_empty == 1) %>

                    <% @sorted_responses = @sorted_responses.sort_by {|obj| obj.updated_at} # the latest should be at the last%>
                    <% @latest_response = @sorted_responses.last %>
                    <% @latest_response_created_time = @latest_response.created_at %>
                    <% due_dates = DueDate.where(["assignment_id = ?", @assignment.id]) %>
                    <% @sorted_deadlines = Array.new %>
                    <% @sorted_deadlines = due_dates.sort { |m1, m2| (m1.due_at and m2.due_at) ? m1.due_at <=> m2.due_at : (m1.due_at ? -1 : 1) } %>
                    <% current_time = Time.new.getutc %>

                    <% for deadline_version in @sorted_deadlines %>
                      <% if (@latest_response.created_at < deadline_version.due_at) %>
                        <% break %>
                      <% end %>
                    <% end %>

                    <% for coming_deadline in @sorted_deadlines %>
                      <% if (current_time < coming_deadline.due_at) %>
                        <% break %>
                      <% end %>
                    <% end %>

                    <td>
                       <%= link_to "View", {:controller => 'response', :action => 'view', :id => @latest_response.id} %>
                    </td>

                    <% if @assignment.get_current_stage(topic_id) != "Finished" %>
                      <%- # show the link as edit when latest review is done in current deadline   -%>
                      <%- # show link as update when latest review is done in different deadline than current phase   -%>
                      <% if (deadline_version.due_at == coming_deadline.due_at) %>
                        <td><%= link_to "Edit", {:controller => 'response', :action => 'edit', :id => @latest_response.id} %></td>
                      <% else %>
                        <td><%= link_to "Update", {:controller => 'response', :action => 'new', :id => map.map_id} %></td>
                      <% end %>
                    <% end %>
                <%end%>
            <% elsif @assignment.get_current_stage(topic_id) != "Complete" %>
                <% if @assignment.staggered_deadline? %>
                            <% if map.type.to_s == "MetareviewResponseMap" %>
                                <% if @assignment.get_current_stage(topic_id) == 'metareview' %>
{'fraction_non_alphanumeric': 0.15021843844516636, 'fraction_numerical': 0.0029125126022179902, 'mean_word_length': 1.5015410479125806, 'pattern_counts': {'":': 0, '<': 184, '<?xml version=': 0, '>': 196, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5097718', 'n_tokens_mistral': 2820, 'n_tokens_neox': 2425, 'n_words': 481}