<!--

    Queue - A Queueing system that can be used to handle labs in higher education
    Copyright (C) 2016-2020  Delft University of Technology

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

-->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{edition/view}">
    <!--@thymesVar id="edition" type="nl.tudelft.labracore.api.dto.EditionDetailsDTO"-->

    <head>
        <title th:text="|Questions - ${edition.course.name} (${edition.name})|"></title>
    </head>

    <body>
        <section class="flex vertical" layout:fragment="subcontent">
            <th:block th:if="${#lists.isEmpty(questions)}">No questions for this edition.</th:block>

            <th:block th:unless="${#lists.isEmpty(questions)}">
                <table class="table">
                    <tr class="table__header">
                        <th scope="col" class="fit-content">Id</th>
                        <th scope="col">Question</th>
                        <th scope="col">Answer</th>
                        <th scope="col">Assignment</th>
                        <th scope="col">Asked at</th>
                    </tr>
                    <tr th:each="question : ${questions}">
                        <th class="fit-content" th:text="${question.id}"></th>
                        <td th:text="${question.question}"></td>
                        <td th:text="${question.answer} ?: 'No answer'"></td>
                        <td th:text="${question.assignment?.name} ?: 'None'"></td>
                        <td th:text="${#temporals.format(question.askedAt, 'dd MMMM yyyy HH:mm')}"></td>
                        <td>
                            <div class="flex gap-3">
                                <a
                                    th:href="@{/edition/{edition}/questions/{question}/edit(edition=${edition.id},question=${question.id})}"
                                    class="button p-min"
                                    data-style="outlined">
                                    <i class="fa-solid fa-pencil"></i>
                                </a>
                                <a
                                    th:href="@{/edition/{edition}/questions/{question}/remove(edition=${edition.id},question=${question.id})}"
                                    class="button p-min"
                                    data-type="error"
                                    data-style="outlined">
                                    <i class="fa-solid fa-trash"></i>
                                </a>
                            </div>
                        </td>
                    </tr>
                </table>
            </th:block>
        </section>
    </body>
</html>
