h1 = "#{@exercise} (external user #{@external_user})"
- submissions = Submission.where("user_id = ?  AND exercise_id = ?", @external_user.id, @exercise.id).order("created_at")
- current_submission = submissions.first
- submissions_and_interventions = (submissions + UserExerciseIntervention.where("user_id = ?  AND exercise_id = ?", @external_user.id, @exercise.id)).sort_by { |a| a.created_at }

- if current_submission
  - initial_files = current_submission.files.to_a

  - all_files = []
  - file_types = Set.new()
  - submissions.each do |submission|
    - submission.files.each do |file|
      - file_types.add(ActiveSupport::JSON.encode(file.file_type))
    - all_files.push(submission.files)

  .hidden#data data-submissions=ActiveSupport::JSON.encode(submissions) data-files=ActiveSupport::JSON.encode(all_files) data-file-types=ActiveSupport::JSON.encode(file_types)

  #stats-editor.row
    - index = 0
    - all_files.each do |files|
      .files class=(@exercise.hide_file_tree ? 'hidden col-sm-3' : 'col-sm-3') data-index=index data-entries=FileTree.new(files).to_js_tree
      - index += 1
    div class=(@exercise.hide_file_tree ? 'col-sm-12' : 'col-sm-9')
      #current-file.editor

  .flex-container
    button.btn.btn-default id='play-button'
      span.fa.fa-play
    #submissions-slider.flex-item
      input type='range' orient='horizontal' list='datapoints' min=0 max=submissions.length-1 value=0
      datalist#datapoints
        - index=0
        - submissions.each do |submission|
          option data-submission=submission
            =index
          - index += 1
  - working_times_until = Array.new
  #timeline
    .table-responsive
      table.table
        thead
          tr
            - ['.time', '.cause', '.score', '.tests', '.time_difference'].each do |title|
              th.header = t(title)
        tbody
          - deltas = submissions.map.with_index {|item, index| delta = item.created_at - submissions[index - 1].created_at if index > 0; if delta == nil or delta > 10*60 then 0 else delta end}
          - submissions_and_interventions.each_with_index do |submission_or_intervention, index|
            tr data-id=submission_or_intervention.id
              td.clickable = submission_or_intervention.created_at.strftime("%F %T")
              - if submission_or_intervention.is_a?(Submission)
                td = submission_or_intervention.cause
                td = submission_or_intervention.score
                td
                  -submission_or_intervention.testruns.each do |run|
                    - if run.passed
                      .unit-test-result.positive-result  title=run.output
                    - else
                      .unit-test-result.unknown-result title=run.output
                td = Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0
                -working_times_until.push((Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0))
              - elsif submission_or_intervention.is_a? UserExerciseIntervention
                td = submission_or_intervention.intervention.name
                td =
                td =
                td =
    p = t('.addendum')
    .hidden#wtimes data-working_times=ActiveSupport::JSON.encode(working_times_until);
    div#progress_chart.col-lg-12
      .graph-functions-2

- else
  p = t('.no_data_available')
