<commit_before><% @title = "Annotate Submission" %>

<% content_for :stylesheets do %>
  <%= stylesheet_link_tag "annotations" %>
  <% # highlightjs - change the style sheet for different styles %>
  <%= stylesheet_link_tag "highlightjs-styles/vs.css" %>
  <%= external_stylesheet_link_tag "jquery-ui", "1.11.4" %>
<% end %>

<% content_for :javascripts do %>
  <%= javascript_include_tag "pdf.js" %>
  <%= external_javascript_include_tag "lodash", "3.3.1" %>
  <%= javascript_include_tag "highlight.pack.js" %>
  <%= javascript_include_tag "jquery.jeditable" %>
  <%= external_javascript_include_tag "jquery-ui", "1.11.4" %>
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.2/jquery.scrollTo.min.js"></script>
  <script type="application/javascript">
    <% if @cud.instructor || @cud.course_assistant then %>
      var isInstructor = true;
    <% else %>
      var isInstructor = false;
    <% end %>

    const editableUrl = "<%= url_for ([:quickSetScore, @course, @assessment]) %>"
    const rootFiles = $('.file-list').children()
    const allFilesFolders = $('.file-list').find("*")
    var currentHeaderPos = <%= params[:header_position] || 0 %>

    var submissionID = <%= @submission.id %>
    var curHeaderPos = <%= params[:header_position] || 0 %>

    var annotations = <%=raw @annotations.to_json %>;
    var annotationsByPositionByLine = {};
    var fileNameStr = "<%= @filename %>";
    var cudEmailStr = "<%= @cud.email %>";
    // a json list of problems for this assessment
    var problems = <%= raw @problems.to_json %>;
    var basePath = "<%= course_assessment_submission_annotations_path(@course, @assessment, @submission) %>";

    var localCache = {};

    <% if params[:header_position] %>
      var headerPositionStr = "<%= params[:header_position] %>";
    <% else %>
      var headerPositionStr = null;
    <% end %>
    hljs.initHighlightingOnLoad();
    PDFJS.workerSrc = "<%= asset_url 'pdf.worker.js' %>";
  </script>
  <%= javascript_include_tag "annotations.js" %>
  <%= javascript_include_tag "submission_view.js" %>
  <script type="text/javascript">
    $('.problem_score a').each( function( index, element ){
        make_editable($(element));
    });
    setActiveFilePos(currentHeaderPos)
    initializeAnnotationsForCode();
    attachEvents();
    // Set up file switching to use the local cache
    $(".file").on("click", function(e) {
    wasCachedLocally = changeFile($(this).data("header_position"));
    if (wasCachedLocally) {
      e.preventDefault();
      return false;
    }
    return true;
  });
  </script>

  <script>
    var newFile = {};
    newFile.url = '<%= url_for(params) %>'

    <% if @is_pdf %>
    newFile.pdf = true;
    newFile.pdfUrl = "<%= url_for [:download, @course, @assessment, @submission, header_position: params[:header_position]] %>";
    newFile.annotatedPdfUrl = "<%= url_for [:download, @course, @assessment, @submission, header_position: params[:header_position], annotated: true] %>";
    newFile.previewMode = false;
    <% if @preview_mode %>
        newFile.previewMode = true;
    <% end %>
    <% else %>
    newFile.pdf = false;
    <% end %>
  </script>
<% end %>

<!-- force end the container -->
</div></div>

<!-- Header to navigate between student submissions for instructors -->
<% if @cud.instructor || @cud.course_assistant then %>
  <div class="row">
    <div class="col s2 center-align">
      <% if @prevSubmission != nil %>
        <%= link_to(url_for([:view, @course, @assessment, @prevSubmission]), class: "valign-wrapper", id: "prev_submission_link") do %>
          <i class="material-icons" style="margin-right: 3px">arrow_back</i> <%= @prevSubmission.course_user_datum.user.email %>
        <% end %>
      <% end %>
    </div>
    <div class="col s8 center-align valign-wrapper">
      <div style="display: inline-block">
      <%= @submission.course_user_datum.email %> (v<%= @submission.version %>) [<%= @curSubmissionIndex+1 %>/<%= @latestSubmissions.length %>]</div>

      <a href="<%= download_file_url(@submission) %>" class="tooltipped" data-placement="top" data-tooltip="Download Submission" title="Download Submission" ><i class="material-icons" aria-hidden="true" style="margin-left:6px; font-size: 20px;">file_download</i></a>
    </div>

    <div class="col s2 center-align">
      <% if @nextSubmission != nil %>
        <%= link_to(url_for([:view, @course, @assessment, @nextSubmission]), class: "valign-wrapper", id: "next_submission_link") do %>
          <%= @nextSubmission.course_user_datum.user.email %> <i class="material-icons" style="margin-left: 3px">arrow_forward</i>
        <% end %>
      <% end %>
    </div>
  </div>
<% end %>

<div class="row" style="height: 100%">
  <%# If there are multiple files, we have a header position and need a file tree %>
  <% if (params[:header_position] || !@ctag_obj.empty?) %>
    <div class="col l2" style="height: 100%">
      <% if (params[:header_position]) %>
        <%= render "file_tree" %>
      <% end %>
      <div id="symbol-tree-container">
      <% unless @ctag_obj.nil? || @ctag_obj.empty? %>
        <%= render "code_symbol_tree", ctag_obj: @ctag_obj %>
      <% end %>
      </div>
    </div>
    <div class="col l8">
      <%= render "code_viewer" %>
    </div>
    <div class="col l2">
      <%= render "annotation_pane" %><commit_msg>Fixed bug when ctag_obj is nil<commit_after><% @title = "Annotate Submission" %>

<% content_for :stylesheets do %>
  <%= stylesheet_link_tag "annotations" %>
  <% # highlightjs - change the style sheet for different styles %>
  <%= stylesheet_link_tag "highlightjs-styles/vs.css" %>
  <%= external_stylesheet_link_tag "jquery-ui", "1.11.4" %>
<% end %>

<% content_for :javascripts do %>
  <%= javascript_include_tag "pdf.js" %>
  <%= external_javascript_include_tag "lodash", "3.3.1" %>
  <%= javascript_include_tag "highlight.pack.js" %>
  <%= javascript_include_tag "jquery.jeditable" %>
  <%= external_javascript_include_tag "jquery-ui", "1.11.4" %>
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.2/jquery.scrollTo.min.js"></script>
  <script type="application/javascript">
    <% if @cud.instructor || @cud.course_assistant then %>
      var isInstructor = true;
    <% else %>
      var isInstructor = false;
    <% end %>

    const editableUrl = "<%= url_for ([:quickSetScore, @course, @assessment]) %>"
    const rootFiles = $('.file-list').children()
    const allFilesFolders = $('.file-list').find("*")
    var currentHeaderPos = <%= params[:header_position] || 0 %>

    var submissionID = <%= @submission.id %>
    var curHeaderPos = <%= params[:header_position] || 0 %>

    var annotations = <%=raw @annotations.to_json %>;
    var annotationsByPositionByLine = {};
    var fileNameStr = "<%= @filename %>";
    var cudEmailStr = "<%= @cud.email %>";
    // a json list of problems for this assessment
    var problems = <%= raw @problems.to_json %>;
    var basePath = "<%= course_assessment_submission_annotations_path(@course, @assessment, @submission) %>";

    var localCache = {};

    <% if params[:header_position] %>
      var headerPositionStr = "<%= params[:header_position] %>";
    <% else %>
      var headerPositionStr = null;
    <% end %>
    hljs.initHighlightingOnLoad();
    PDFJS.workerSrc = "<%= asset_url 'pdf.worker.js' %>";
  </script>
  <%= javascript_include_tag "annotations.js" %>
  <%= javascript_include_tag "submission_view.js" %>
  <script type="text/javascript">
    $('.problem_score a').each( function( index, element ){
        make_editable($(element));
    });
    setActiveFilePos(currentHeaderPos)
    initializeAnnotationsForCode();
    attachEvents();
    // Set up file switching to use the local cache
    $(".file").on("click", function(e) {
    wasCachedLocally = changeFile($(this).data("header_position"));
    if (wasCachedLocally) {
      e.preventDefault();
      return false;
    }
    return true;
  });
  </script>

  <script>
    var newFile = {};
    newFile.url = '<%= url_for(params) %>'

    <% if @is_pdf %>
    newFile.pdf = true;
    newFile.pdfUrl = "<%= url_for [:download, @course, @assessment, @submission, header_position: params[:header_position]] %>";
    newFile.annotatedPdfUrl = "<%= url_for [:download, @course, @assessment, @submission, header_position: params[:header_position], annotated: true] %>";
    newFile.previewMode = false;
    <% if @preview_mode %>
        newFile.previewMode = true;
    <% end %>
    <% else %>
    newFile.pdf = false;
    <% end %>
  </script>
<% end %>

<!-- force end the container -->
</div></div>

<!-- Header to navigate between student submissions for instructors -->
<% if @cud.instructor || @cud.course_assistant then %>
  <div class="row">
    <div class="col s2 center-align">
      <% if @prevSubmission != nil %>
        <%= link_to(url_for([:view, @course, @assessment, @prevSubmission]), class: "valign-wrapper", id: "prev_submission_link") do %>
          <i class="material-icons" style="margin-right: 3px">arrow_back</i> <%= @prevSubmission.course_user_datum.user.email %>
        <% end %>
      <% end %>
    </div>
    <div class="col s8 center-align valign-wrapper">
      <div style="display: inline-block">
      <%= @submission.course_user_datum.email %> (v<%= @submission.version %>) [<%= @curSubmissionIndex+1 %>/<%= @latestSubmissions.length %>]</div>

      <a href="<%= download_file_url(@submission) %>" class="tooltipped" data-placement="top" data-tooltip="Download Submission" title="Download Submission" ><i class="material-icons" aria-hidden="true" style="margin-left:6px; font-size: 20px;">file_download</i></a>
    </div>

    <div class="col s2 center-align">
      <% if @nextSubmission != nil %>
        <%= link_to(url_for([:view, @course, @assessment, @nextSubmission]), class: "valign-wrapper", id: "next_submission_link") do %>
          <%= @nextSubmission.course_user_datum.user.email %> <i class="material-icons" style="margin-left: 3px">arrow_forward</i>
        <% end %>
      <% end %>
    </div>
  </div>
<% end %>

<div class="row" style="height: 100%">
  <%# If there are multiple files, we have a header position and need a file tree %>
  <% if (params[:header_position] || (!@ctag_obj.nil? && !@ctag_obj.empty?)) %>
    <div class="col l2" style="height: 100%">
      <% if (params[:header_position]) %>
        <%= render "file_tree" %>
      <% end %>
      <div id="symbol-tree-container">
      <% unless @ctag_obj.nil? || @ctag_obj.empty? %>
        <%= render "code_symbol_tree", ctag_obj: @ctag_obj %>
      <% end %>
      </div>
    </div>
    <div class="col l8">
      <%= render "code_viewer" %>
    </div>
    <div class="col l2">
      <%= render "annotation_pane" %>
{'fraction_non_alphanumeric': 0.18247903075489283, 'fraction_numerical': 0.006337371854613234, 'mean_word_length': 3.615483870967742, 'pattern_counts': {'":': 0, '<': 215, '<?xml version=': 0, '>': 215, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4104979', 'n_tokens_mistral': 3817, 'n_tokens_neox': 3453, 'n_words': 712}