{% extends "base.html" %}
{% block title %}考试管理{% endblock %}
{% block content %}
<h1>考试管理</h1>
<table class="table table-striped">
    <thead>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>科目</th>
            <th>考试日期</th>
            <th>状态</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {% for exam in exams %}
        <tr>
            <td>{{ exam.id }}</td>
            <td>{{ exam.name }}</td>
            <td>{{ exam.subject }}</td>
            <td>{{ exam.exam_date }}</td>
            <td>
                {% if exam.status == 'active' %}
                    <span class="badge bg-success">进行中</span>
                {% else %}
                    <span class="badge bg-secondary">已停止</span>
                {% endif %}
            </td>
            <td>{{ exam.created_at }}</td>
            <td>
                {% if exam.status == 'active' %}
                <form action="{{ url_for('stop_exam', id=exam.id) }}" method="post" style="display:inline;">
                    <button type="submit" class="btn btn-warning btn-sm" onclick="return confirm('确定停止该考试吗？')">停止</button>
                </form>
                {% else %}
                <span class="text-muted">无操作</span>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}