{% extends "base_admin.html" %}

{% load projecttags %}
{% load bootstrap %}

{% block scripts %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}DataTables/datatables.min.css"/>
<script type="text/javascript" src="{{STATIC_URL}}DataTables/datatables.min.js"></script>
{% endblock %}

{% block docready %}
{{ block.super }}
var table=$('#duplicates').DataTable( 
	{
		paging: false,
		order: [[ 0, "asc" ], [1, "desc"], [4, "asc"]],
		rowGroup: {dataSrc: 0},
		columnDefs: [
            {
                "targets": [ 0 ],
                "visible": false
            }
        ]
	});
{% endblock %}

{% block title %}
    {{ block.super }} - Duplicate Report for {{ assignment }}
{% endblock %}

{% block breadcrumbs %}
<ul>
    <li><a href="{{ main_url }}/teacher/">Home</a></li>
    <li>
        <a href="{{ main_url }}/teacher/opensubmit/assignment/">Assignments</a>
    </li>
    <li>Duplicates</li>
</ul>


{% endblock %}

{% block content %}

<div class="page-header">
    <h1>Duplicate Report for {{ assignment }}</h1>
</div>

<p>Hint: Use the Shift key for working with sub-ordered columns.</p>

<table id="duplicates" class="table table-bordered table-condensed table-hover">
<thead>
	<tr>
		<th>Content Hash</th>
		<th>Last change</th>
		<th>Submission</th>
		<th>Assignment</th>
		<th>Course</th>
		<th>Authors</th>
		<th>Grading finished?</th>
		<th>Grading Notes</th>
	</tr>
</thead>
<tbody>
{% for key, file_list in duplicates %}
	{% for dupfile in file_list %}
		{% with dupfile.submissions.all.0 as submission %}
		<tr {% if submission.assignment.pk != assignment.pk %} style="font-style: italic"{%endif%}>
			<td>Case {{ forloop.parentloop.counter }}</td>
			<td>{{ submission.modified }}
			{% url 'teacher:opensubmit_submission_change' submission as suburl %}
			<td><a href="{{ suburl }}" target="_new">#{{submission}}</a> (<a href="{{ dupfile.get_preview_url }}" target="_new">file preview</a>)</td>
			<td>{{ submission.assignment }}</td>
			<td>{{ submission.assignment.course }}</td>
			<td>{{ submission.authors.all|join:", " }}</td>
			<td>{{ submission.grading_status_text }}</td>
			<td>{{ submission.grading_notes|default_if_none:""}}</td>
		</tr>
		{% endwith %}
	{% endfor %}
{% endfor %}
</tbody>
</table>

{% endblock %}

