<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base th:href="${#request.getContextPath() + '/'} ">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
    <div id="questionTemplateBox"></div>
    <script id="questionTemplate" type="text/html">
        <div class="layui-card">
            <div class="layui-card-header"><b>题目</b></div>
            <div class="layui-card-body subject">
                {{d.subject}}
            </div>
        </div>
        {{# if(d.type == 'choice' || d.type == 'tureOrFalse') { }}
        <div class="layui-card">
            <div class="layui-card-header"><b>选项</b></div>
            <div class="layui-card-body options">
            {{# for(var i = 0, item; item = d.options[i++];) { }}
                <div><b>{{item.option}}.</b> <span>{{item.content}}</span></div>
            {{# } }}
            </div>
        </div>
        {{# } }}
        <div class="layui-card">
            <div class="layui-card-header"><b>正确答案</b></div>
            <div class="layui-card-body answer">
                {{# for(var i = 0, item; item = d.answerArray[i++];) { }}
                {{# if(d.type != 'answer') { }}
                <span>【{{item}}】</span>
                {{# } else { }}
                <span>{{item}}</span>
                {{# } }}
                {{# } }}
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header"><b>解析</b></div>
            <div class="layui-card-body analysis">
                {{d.analysis}}
            </div>
        </div>
    </script>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: 'assets/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'laytpl'], function(){
        var $ = layui.$;
        var form = layui.form;
        var laytpl = layui.laytpl;
        var laydate = layui.laydate;
        var questionId = top.restAjax.params(window.location.href).questionId;

        var fillTag = '$_WenG_$';

        // 初始化内容
        function initData() {
            var loadLayerIndex;
            top.restAjax.get(top.restAjax.path('api/question/get/{questionId}', [questionId]), {}, null, function(code, data) {
                data.answerArray = data.answer.split('$_WenG_$');
                laytpl(document.getElementById('questionTemplate').innerHTML).render(data, function(html) {
                    document.getElementById('questionTemplateBox').innerHTML = html;
                });
            }, function(code, data) {
                top.dialog.msg(data.msg);
            }, function() {
                loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
            }, function() {
                top.dialog.close(loadLayerIndex);
            });
        }
        initData();

        $('.close').on('click', function() {
            closeBox();
        });

        // 校验
        form.verify({
        });
    });
</script>
</body>
</html>