{% extends "root.html" %}

{% block Navi %}
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a class="navbar-brand" href="javascript:void(0);" onclick="jumpto('/admin')">作业提交admin</a>
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
            data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
            aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-link" href="javascript:void(0);" onclick="jumpto('/admin/studentList')">导入学生名单</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="javascript:void(0);" onclick="jumpto('/admin/publish')">发布新作业</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/contact">Contact</a>
                </li>
            </ul>
        </div>
    </div>
</nav>
{% endblock %}

{% block main %}
<div class="container">

    <!-- Page Heading/Breadcrumbs -->
    <h1 class="mt-4 mb-3">作业一览
    </h1>

    <div class="row">

        <!-- Blog Entries Column -->
        <div class="col-md-8">
            {% for homework in homeworks %}
            <!-- Blog Post -->
            <div class="card mb-4">
                <div class="card-body">
                    <h2 class="card-title">{{homework["name"]}}</h2>
                    <h2 class="card-title">DEADLINE:{{homework["deadline"]}}</h2>
                    <p class="card-text">{{homework["describe"]}}</p>
                    <button class="btn btn-primary" onclick="jumpto('/admin/{{homework['name']}}')">提交情况
                        &rarr;</button>
                    <button class="btn btn-danger" onclick="cancelHomework('{{homework['name']}}')">取消
                        &rarr;</button>
                </div>
            </div>
            {% endfor %}
        </div>

    </div>
    <!-- /.row -->
</div>
{% endblock %}

{% block form %}
<div class="modal fade" id="studentList" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="homeworkName">
                    作业名称
                </h4>
            </div>
            <div class="modal-body">
                <!--上传信息表格-->
                <form id="upload" action="/upload" enctype='multipart/form-data' method='POST'>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text">姓名</span>
                        </div>
                        <label for="name"></label>
                        <input type="text" class="form-control" id="name" name="name">
                    </div>

                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text">学号</span>
                        </div>
                        <label for="num"></label>
                        <input type="text" class="form-control" id="num" name="num">
                    </div>
                    <!--上传文件的控件-->
                    <input id='file' class="btn btn-info" name="file" type="file">
                    <div class="modal-footer">
                        <button type="button" onclick="submit_form()" class="btn btn-primary">提交</button>
                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}