{% extends "base.html" %}
{% block title %}提交列表 - 智联青云{% endblock %}
{% block content %}
<div class="max-w-4xl mx-auto space-y-6">
    <div class="flex justify-between items-center">
        <div>
            <h1 class="text-2xl font-bold text-slate-900">提交列表</h1>
            <p class="text-sm text-slate-500 mt-1">{{ exam.title }} · 共{{ submissions|length }}份提交</p>
        </div>
        <div class="flex items-center space-x-3">
            {% if next_ungraded %}
            <a href="/exams/{{ exam.id }}/grade/{{ next_ungraded }}" class="inline-flex items-center px-3 py-1.5 bg-yellow-50 border border-yellow-300 text-yellow-700 text-sm font-medium rounded-md hover:bg-yellow-100">
                开始批改 →
            </a>
            {% endif %}
            <a href="/exams" class="text-sm text-slate-500 hover:text-slate-700">← 返回列表</a>
        </div>
    </div>

    <!-- 统计摘要 -->
    {% if stats %}
    <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">
        <div class="bg-white rounded-lg shadow-sm border border-slate-200 p-4 text-center">
            <div class="text-2xl font-bold text-slate-900">{{ stats.total }}</div>
            <div class="text-xs text-slate-500 mt-1">总提交</div>
        </div>
        <div class="bg-white rounded-lg shadow-sm border border-green-200 p-4 text-center">
            <div class="text-2xl font-bold text-green-600">{{ stats.graded }}</div>
            <div class="text-xs text-slate-500 mt-1">已批改</div>
        </div>
        <div class="bg-white rounded-lg shadow-sm border border-yellow-200 p-4 text-center">
            <div class="text-2xl font-bold text-yellow-600">{{ stats.ungraded }}</div>
            <div class="text-xs text-slate-500 mt-1">待批改</div>
        </div>
        <div class="bg-white rounded-lg shadow-sm border border-blue-200 p-4 text-center">
            <div class="text-2xl font-bold text-blue-600">{{ stats.avg_score }}</div>
            <div class="text-xs text-slate-500 mt-1">平均分</div>
        </div>
        <div class="bg-white rounded-lg shadow-sm border border-purple-200 p-4 text-center">
            <div class="text-2xl font-bold text-purple-600">{{ stats.max_score }}</div>
            <div class="text-xs text-slate-500 mt-1">最高分</div>
        </div>
        <div class="bg-white rounded-lg shadow-sm border border-slate-200 p-4 text-center">
            <div class="text-2xl font-bold text-slate-600">{{ stats.min_score }}</div>
            <div class="text-xs text-slate-500 mt-1">最低分</div>
        </div>
    </div>
    {% endif %}

    {% if submissions|length == 0 %}
    <div class="bg-white rounded-lg shadow-sm border border-slate-200 p-12 text-center text-slate-500">暂无提交</div>
    {% else %}
    <div class="bg-white shadow overflow-hidden sm:rounded-md">
        <ul class="divide-y divide-slate-200">
            {% for sub in submissions %}
            <li>
                <div class="px-4 py-4 sm:px-6 hover:bg-slate-50 transition-colors
                    {% if sub.graded %}border-l-4 border-l-green-400{% else %}border-l-4 border-l-yellow-400{% endif %}">
                    <div class="flex items-center justify-between">
                        <div class="flex flex-col">
                            <p class="text-sm font-medium text-slate-900">{{ sub.user_name }}</p>
                            <div class="mt-1 text-sm text-slate-500">提交时间：{{ sub.submitted_at }}</div>
                        </div>
                        <div class="flex items-center space-x-3">
                            {% if sub.graded %}
                            <div class="text-right">
                                <span class="text-sm font-medium text-green-600">{{ sub.score }}/{{ exam.totalScore }}分</span>
                                <div class="text-xs text-slate-400">批改人：{{ sub.graded_by }}</div>
                            </div>
                            {% else %}
                            <span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800">待批改</span>
                            {% endif %}
                            <a href="/exams/{{ exam.id }}/grade/{{ sub.id }}" class="inline-flex items-center px-3 py-1.5 border border-slate-300 text-sm font-medium rounded-md text-slate-700 bg-white hover:bg-slate-50">
                                {% if sub.graded %}查看{% else %}批改{% endif %}
                            </a>
                        </div>
                    </div>
                </div>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}
</div>
{% endblock %}