<commit_before><style>
th.tablesorter-headerAsc{
  background-image: url(<%= asset_path("up-arrow.png") %>);
  background-size: 15px 15px;
  background-repeat: no-repeat;
  background-position: center right;
  padding-right: 15px;
}

th.tablesorter-headerDesc{
  background-image: url(<%= asset_path("down-arrow.png") %>);
  background-size: 15px 15px;
  background-repeat: no-repeat;
  background-position: center right;
  padding-right: 15px;
}

th.sorter-true.tablesorter-headerUnSorted{
  background-image: url(<%= asset_path("sort.png") %>);
  background-size: 15px 7px;
  background-repeat: no-repeat;
  background-position: center right;
  padding-right: 15px;
}
</style>
<script>
  $(function () {
    $("[data-toggle='tooltip']").tooltip();
    $("#scoresTable").tablesorter();
  });

  var lesser = false;
  // Function to sort the columns based on the total review score
  function col_sort(m) {
    
    lesser = !lesser
    // Swaps two columns of the table
    jQuery.moveColumn = function(table, from, to) {
      var rows = jQuery('tr', table);

      var hidden_child_row = table.find('tr.tablesorter-childRow');

      hidden_child_row.each(function() {
        inner_table=jQuery(this).find('table.tbl_questlist')
        hidden_table=inner_table.eq(0).find('tr')


        hidden_table.eq(from-1).detach().insertBefore(hidden_table.eq(to-1));
        if (from - to > 1) {
          hidden_table.eq(to-1).detach().insertAfter((hidden_table.eq(from - 2)));

        }

      });


      var cols;
      rows.each(function() {
        cols = jQuery(this).children('th, td');
        cols.eq(from).detach().insertBefore(cols.eq(to));
        if (from - to > 1) {
          cols.eq(to).detach().insertAfter((cols.eq(from - 1)));

        }
      });
    }

    // Gets all the table with the class "tbl_heat"
    var tables = $("table.tbl_heat");
    // Get all the rows with the class accordion-toggle
    var tbr = tables.eq(m).find('tr.accordion-toggle');
    // Get the cells from the last row of the table
    var columns = tbr.eq(tbr.length - 1).find('td');
    // Init an array to hold the review total
    var sum_array = [];
    // iterate through the rows and calculate the total of each review
    for (var l = 2; l < columns.length - 2; l++) {
      var total = 0;
      for (var n = 0; n < tbr.length; n++) {
        var row_slice = tbr.eq(n).find('td');
        if (parseInt(row_slice[l].innerHTML) > 0) {
          total = total + parseInt(row_slice[l].innerHTML)
        }
      }
      sum_array.push(total)
    }

    // The sorting algorithm
    for (var i = 3; i < columns.length - 2; i++)
    {
      var j=i;
      while(j>2 && compare(sum_array[j - 2], sum_array[j - 3], lesser))
      {
        var tmp
        tmp = sum_array[j - 3]
        sum_array[j - 3] = sum_array[j-2]
        sum_array[j-2] = tmp
        jQuery.moveColumn($("table.tbl_heat").eq(m), j, j-1);
        // This part is repeated since the table is updated
        tables = $("table.tbl_heat")
        tbr = tables.eq(m).find('tr.accordion-toggle');
        columns = tbr.eq(tbr.length - 1).find('td')
        j=j-1	;

      }
    }
  }

  // Function to return boolean based on lesser or greater operator
  function compare(a, b, less) {
    if(less) {
      return a < b
    } else {
      return a > b
    }
  }



</script>

<h1>Summary Report for assignment: <%= @assignment.name %></h1>
<h4>Team: <%= @team.name %></h4>

<!-- For each of the models in the list, generate a heatgrid table. this is the outer most loop -->
<% table_count = 0 %>
<% @vmlist.each do |vm| %>

    <% if (vm.questionnaire_display_type == "Metareview" or vm.questionnaire_display_type == "Author Feedback" or vm.questionnaire_display_type == "Teammate Review") and @current_role_name.eql?'Student' %>
    <% else %>
        <% if vm.list_of_reviewers.length > 0 %>

          <!-- display the list of questions for this questionnaire -->
          <div id="hid<%= vm.questionnaire_type + vm.round.to_s %>" class="accordion-body collapse" >
            <table class="tbl_questlist" >
              <thead>
              <th>#</th>
              <th>Question</th>
              </thead>
              <% count = 0 %>
              <% vm.list_of_rows.each do |row| %>
                  <% if row.score_row.count > 0  %>
                      <tr style="background-color: #ffffff;">
                        <td><%= count += 1 %></td>
                        <td><%= row.questionText %></td>
                      </tr>
                  <% end %>
              <% end %>
            </table>
          </div>

          <!-- display the table title and tooltips -->
          <span style="width:100%;">
              <h4 style="font-weight:bold;display:inline-block;"><%= vm.questionnaire_display_type %>
                <% if vm.questionnaire_type == "ReviewQuestionnaire" %>
                    (Round: <%= vm.round.to_s  %> of <%= vm.rounds.to_s  %>)
                <%end %>
              </h4>
              <span class="spn_qsttog" data-toggle="collapse" class="accordion-toggle" data-target="#hid<%= vm.questionnaire_type + vm.round.to_s %>" data-toggle="tooltip" data-placement="right" title="Click to display/hide questions">toggle question list</span>
            <span class="spn_tooltip" data-toggle="tooltip" data-placement="right" title="Colors are scaled from poor to excellent in the following order: red, orange, yellow, light-green, dark-green">color legend</span>
            <span class="spn_tooltip" data-toggle="tooltip" data-placement="right" title="Click a row to see the comments for the respective question. Click 'Review Total' row to see Add'l Comments. Useful tip: decreasing your browser's zoom to 75% or 90% many improve your experience.">interaction legend</span>

          </span>

          <table id="scoresTable" class="tbl_heat tablesorter">
            <!-- display the header row of the heatgrid table. this involves iterating through reviewers.-->
            <thead>
            <tr>
              <th class="sorter-true">Criterion<span></span></th>
              <th class="sorter-false">Max</th>

              <% i = 1 %>
              <% vm.list_of_reviews.each do |review| %>
                  <!-- instructors (or higher level users) see reviewer name, students see anonymized string -->
                  <% if ['Student'].include? @current_role_name %>
                      <th class="sorter-false"> <a target="_blank" href="../response/view?id=<%= review.id.to_s %>"  data-toggle="tooltip" data-placement="right" title="Click to see details"><%= "Review " + i.to_s %></a>  </th>
                      <% i += 1 %>
                  <% end %>
                  <% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? @current_role_name %>
                      <% user_name = User.find(Participant.find(ResponseMap.find(Response.find(review.id).map_id).reviewer_id).user_id).fullname.to_s %>
                      <th class="sorter-false"> <a target="_blank" href="../response/view?id=<%= review.id.to_s %>"  data-toggle="tooltip" data-placement="right" title="Click to see details"><%= user_name.to_s %></a>  </th>
                      <% i += 1 %>
                  <% end %>
              <% end %>

              <th class="sorter-true" align="right" >
                Avg<span></span>
              </th>
              <th class="sorter-false">
                <span  data-toggle="tooltip" data-placement="right" title="A count of comments, for the respective question, which have word count > 10. The purpose of this metric is to represent how many comments for the question are of a substantial length to provide quality feedback.">metric-1</span>
              </th>

            </tr>
            </thead>


            <% score_row_count = vm.list_of_rows.first.score_row.count %><commit_msg>Show reviewers' names on heat map if assgt is non-anonymous.<commit_after><style>
th.tablesorter-headerAsc{
  background-image: url(<%= asset_path("up-arrow.png") %>);
  background-size: 15px 15px;
  background-repeat: no-repeat;
  background-position: center right;
  padding-right: 15px;
}

th.tablesorter-headerDesc{
  background-image: url(<%= asset_path("down-arrow.png") %>);
  background-size: 15px 15px;
  background-repeat: no-repeat;
  background-position: center right;
  padding-right: 15px;
}

th.sorter-true.tablesorter-headerUnSorted{
  background-image: url(<%= asset_path("sort.png") %>);
  background-size: 15px 7px;
  background-repeat: no-repeat;
  background-position: center right;
  padding-right: 15px;
}
</style>
<script>
  $(function () {
    $("[data-toggle='tooltip']").tooltip();
    $("#scoresTable").tablesorter();
  });

  var lesser = false;
  // Function to sort the columns based on the total review score
  function col_sort(m) {
    
    lesser = !lesser
    // Swaps two columns of the table
    jQuery.moveColumn = function(table, from, to) {
      var rows = jQuery('tr', table);

      var hidden_child_row = table.find('tr.tablesorter-childRow');

      hidden_child_row.each(function() {
        inner_table=jQuery(this).find('table.tbl_questlist')
        hidden_table=inner_table.eq(0).find('tr')


        hidden_table.eq(from-1).detach().insertBefore(hidden_table.eq(to-1));
        if (from - to > 1) {
          hidden_table.eq(to-1).detach().insertAfter((hidden_table.eq(from - 2)));

        }

      });


      var cols;
      rows.each(function() {
        cols = jQuery(this).children('th, td');
        cols.eq(from).detach().insertBefore(cols.eq(to));
        if (from - to > 1) {
          cols.eq(to).detach().insertAfter((cols.eq(from - 1)));

        }
      });
    }

    // Gets all the table with the class "tbl_heat"
    var tables = $("table.tbl_heat");
    // Get all the rows with the class accordion-toggle
    var tbr = tables.eq(m).find('tr.accordion-toggle');
    // Get the cells from the last row of the table
    var columns = tbr.eq(tbr.length - 1).find('td');
    // Init an array to hold the review total
    var sum_array = [];
    // iterate through the rows and calculate the total of each review
    for (var l = 2; l < columns.length - 2; l++) {
      var total = 0;
      for (var n = 0; n < tbr.length; n++) {
        var row_slice = tbr.eq(n).find('td');
        if (parseInt(row_slice[l].innerHTML) > 0) {
          total = total + parseInt(row_slice[l].innerHTML)
        }
      }
      sum_array.push(total)
    }

    // The sorting algorithm
    for (var i = 3; i < columns.length - 2; i++)
    {
      var j=i;
      while(j>2 && compare(sum_array[j - 2], sum_array[j - 3], lesser))
      {
        var tmp
        tmp = sum_array[j - 3]
        sum_array[j - 3] = sum_array[j-2]
        sum_array[j-2] = tmp
        jQuery.moveColumn($("table.tbl_heat").eq(m), j, j-1);
        // This part is repeated since the table is updated
        tables = $("table.tbl_heat")
        tbr = tables.eq(m).find('tr.accordion-toggle');
        columns = tbr.eq(tbr.length - 1).find('td')
        j=j-1	;

      }
    }
  }

  // Function to return boolean based on lesser or greater operator
  function compare(a, b, less) {
    if(less) {
      return a < b
    } else {
      return a > b
    }
  }



</script>

<h1>Summary Report for assignment: <%= @assignment.name %></h1>
<h4>Team: <%= @team.name %></h4>

<!-- For each of the models in the list, generate a heatgrid table. this is the outer most loop -->
<% table_count = 0 %>
<% @vmlist.each do |vm| %>

    <% if (vm.questionnaire_display_type == "Metareview" or vm.questionnaire_display_type == "Author Feedback" or vm.questionnaire_display_type == "Teammate Review") and @current_role_name.eql?'Student' %>
    <% else %>
        <% if vm.list_of_reviewers.length > 0 %>

          <!-- display the list of questions for this questionnaire -->
          <div id="hid<%= vm.questionnaire_type + vm.round.to_s %>" class="accordion-body collapse" >
            <table class="tbl_questlist" >
              <thead>
              <th>#</th>
              <th>Question</th>
              </thead>
              <% count = 0 %>
              <% vm.list_of_rows.each do |row| %>
                  <% if row.score_row.count > 0  %>
                      <tr style="background-color: #ffffff;">
                        <td><%= count += 1 %></td>
                        <td><%= row.questionText %></td>
                      </tr>
                  <% end %>
              <% end %>
            </table>
          </div>

          <!-- display the table title and tooltips -->
          <span style="width:100%;">
              <h4 style="font-weight:bold;display:inline-block;"><%= vm.questionnaire_display_type %>
                <% if vm.questionnaire_type == "ReviewQuestionnaire" %>
                    (Round: <%= vm.round.to_s  %> of <%= vm.rounds.to_s  %>)
                <%end %>
              </h4>
              <span class="spn_qsttog" data-toggle="collapse" class="accordion-toggle" data-target="#hid<%= vm.questionnaire_type + vm.round.to_s %>" data-toggle="tooltip" data-placement="right" title="Click to display/hide questions">toggle question list</span>
            <span class="spn_tooltip" data-toggle="tooltip" data-placement="right" title="Colors are scaled from poor to excellent in the following order: red, orange, yellow, light-green, dark-green">color legend</span>
            <span class="spn_tooltip" data-toggle="tooltip" data-placement="right" title="Click a row to see the comments for the respective question. Click 'Review Total' row to see Add'l Comments. Useful tip: decreasing your browser's zoom to 75% or 90% many improve your experience.">interaction legend</span>

          </span>

          <table id="scoresTable" class="tbl_heat tablesorter">
            <!-- display the header row of the heatgrid table. this involves iterating through reviewers.-->
            <thead>
            <tr>
              <th class="sorter-true">Criterion<span></span></th>
              <th class="sorter-false">Max</th>

              <% i = 1 %>
              <% vm.list_of_reviews.each do |review| %>
                  <!-- instructors (or higher level users) see reviewer name, students see anonymized string -->
                  <% if (['Student'].include? @current_role_name) && @assignment.is_anonymous%>
                      <th class="sorter-false"> <a target="_blank" href="../response/view?id=<%= review.id.to_s %>"  data-toggle="tooltip" data-placement="right" title="Click to see details"><%= "Review " + i.to_s %></a>  </th>
                  <% else %>
                      <% user_name = User.find(Participant.find(ResponseMap.find(Response.find(review.id).map_id).reviewer_id).user_id).fullname.to_s %>
                      <th class="sorter-false"> <a target="_blank" href="../response/view?id=<%= review.id.to_s %>"  data-toggle="tooltip" data-placement="right" title="Click to see details"><%= user_name.to_s %></a>  </th>
                  <% end %>
                  <% i += 1 %>
              <% end %>

              <th class="sorter-true" align="right" >
                Avg<span></span>
              </th>
              <th class="sorter-false">
                <span  data-toggle="tooltip" data-placement="right" title="A count of comments, for the respective question, which have word count > 10. The purpose of this metric is to represent how many comments for the question are of a substantial length to provide quality feedback.">metric-1</span>
              </th>

            </tr>
            </thead>


            <% score_row_count = vm.list_of_rows.first.score_row.count %>
{'fraction_non_alphanumeric': 0.1515964240102171, 'fraction_numerical': 0.008492975734355045, 'mean_word_length': 2.2613494377342773, 'pattern_counts': {'":': 0, '<': 219, '<?xml version=': 0, '>': 227, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1668610', 'n_tokens_mistral': 5069, 'n_tokens_neox': 4683, 'n_words': 1183}