linzhijie
2021-03-11 93af1c6ffb9ae0e894689ad3a37b548e57d54cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增题目列表-intelligence')"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
 
    <form class="form-horizontal m" id="form-question-add" th:object="${tExamLevel}">
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{menu.exam.level.view}]]:</label>
            <div class="col-sm-8">
                <input name="levelName" class="form-control" th:value="*{levelName}" type="text" readonly>
                <input name="levelId" class="form-control" th:value="*{id}" type="hidden" readonly>
            </div>
        </div>
        <div class="form-group input-focus">
            <label class="col-sm-3 control-label">[[#{jsp.exam.product.questionStem}]]:</label>
            <div class="col-sm-8">
                <input name="title" onclick="$.modal.richtext(this)" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group permanent" hidden="true">
            <label class="col-sm-3 control-label">[[#{jsp.exam.question.questionNumberPermanent}]]:</label>
            <div class="col-sm-8">
                <input name="permanentId" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.exam.demographyParam.languagetype}]]:</label>
            <div class="col-sm-8">
                <select name="langType" id="langType" class="form-control m-b"
                        th:with="type=${@dict.getType('lang_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">[[#{jsp.level.questionType}]]:</label>
            <div class="col-sm-8 template-option">
                    <input type="radio" name="template" value= "intelligence_title" checked="true">
                    <label>[[#{jsp.exam.product.questionsAndAnswers}]]</label>
                    <input type="radio" name="template" value= "intelligence">
                    <label>[[#{jsp.exam.product.questionsAndAnswers.title}]]</label>
            </div>
        </div>
        <div class="form-group option-group option-intelligence" hidden="true">
            <label class="col-sm-3 control-label">[[#{jsp.exam.question.item}]]:</label>
            <div class="col-sm-8 layui-layer-border input-focus item-must" style="padding-top: 2%" id="optionEdit">
                <div class="form-group form-inline">
                    <label class="col-sm-1">1</label>
                    <input name="choiceInput" class="form-control valid  option-input" type="text"
                           style="width: 10%; margin-right: 2%;" value="1">
                    <input name="selectInput" onclick="$.modal.richtext(this)" class="form-control valid  option-input" type="text" style="width: 60%;"
                    value="">
                    <button type="button" class="btn btn-danger glyphicon glyphicon-trash delet-trash"></button>
                </div>
                <div class="form-group form-inline">
                    <label class="col-sm-1">2</label>
                    <input name="choiceInput" class="form-control valid" type="text"
                           style="width: 10%; margin-right: 2%;" value="2">
                    <input name="selectInput" onclick="$.modal.richtext(this)"  class="form-control valid" type="text" style="width: 60%;" value="">
                    <button type="button" class="btn btn-danger glyphicon glyphicon-trash"></button>
                </div>
                <div class="form-group form-inline">
                    <label class="col-sm-1">3</label>
                    <input name="choiceInput" class="form-control valid" type="text"
                           style="width: 10%; margin-right: 2%;" value="3">
                    <input name="selectInput" onclick="$.modal.richtext(this)"  class="form-control valid" type="text" style="width: 60%;" value="">
                    <button type="button" class="btn btn-danger glyphicon glyphicon-trash"></button>
                </div>
                <div class="form-group form-inline">
                    <label class="col-sm-1">4</label>
                    <input name="choiceInput" class="form-control valid" type="text"
                           style="width: 10%; margin-right: 2%;" value="4">
                    <input name="selectInput" onclick="$.modal.richtext(this)"  class="form-control valid" type="text" style="width: 60%;" value="">
                    <button type="button" class="btn btn-danger glyphicon glyphicon-trash"></button>
                </div>
                <div class="form-group form-inline">
                    <label class="col-sm-1">5</label>
                    <input name="choiceInput" class="form-control valid" type="text"
                           style="width: 10%; margin-right: 2%;" value="5">
                    <input name="selectInput" onclick="$.modal.richtext(this)"  class="form-control valid" type="text" style="width: 60%;" value="">
                    <button type="button" class="btn btn-danger glyphicon glyphicon-trash"></button>
                </div>
            </div>
        </div>
 
        <div class="form-group message-item-must form-group" hidden="true">
            <label class="col-sm-3 control-label" style="color: red">*select</label>
        </div>
 
        <div class="form-group">
            <label class="col-sm-3 control-label"></label>
            <div class="col-sm-8">
                <button type="button" class="btn btn-w-m btn-success" id="optionAdd" style="display: none">
                    [[#{jsp.exam.question.addOption}]]
                </button>
                <button type="button" class="btn btn-w-m btn-primary" id="optionView" style="display: none">[[#{jsp.exam.question.preview}]]
                </button>
            </div>
        </div>
    </form>
 
    <div class="form-group form-inline" id="optionTemplte" hidden="true">
        <label class="col-sm-1">E</label>
        <input name="choiceInput" class="form-control valid" type="text"
               style="width: 10%; margin-right: 2%;">
        <input name="selectInput" onclick="$.modal.richtext(this)" class="form-control valid" type="text" style="width: 60%;">
        <button type="button" class="btn btn-danger glyphicon glyphicon-trash" value="trashButton"></button>
    </div>
 
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>save
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>close
        </button>
    </div>
 
    <!--模态窗口-->
    <!--<div class="modal inmodal" id="modalWindow" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="ibox-title">
                    <h5>input</h5>
                </div>
                <div class="modal-body" id="eg">
                    <div class="click2edit wrapper">
                        <p>[[#{jsp.exam.product.pleaseEnterQuestions}]]...</p>
                    </div>
                </div>
                <div class="modal-footer">
                    <button id="save" class="btn btn-primary  btn-xs" onclick="save()" type="button">save</button>
                    <button id="edit" class="btn btn-danger btn-xs m-l-sm" onclick="cancel()" type="button">cancel
                    </button>
                </div>
            </div>
        </div>
    </div>-->
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: summernote-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script type="text/javascript">
 
 
    var prefix = ctx + "exam/question";
    var option = [];
    var clicknum = 2;
    // 多语言的uuid
    var uuid = $("input[name='uuid']").val();
 
    function submitHandler() {
        if ($.validate.form()) {
            var inputflag = false;
            $('.item-must').find('input').each(function (i) {
                if ($(this).val().trim() == "") {
                    inputflag = true;
                    return;
                }
            });
            // 区分题目还是维度
            if ($('input:radio[name="template"]:checked').val() == "intelligence_title") {
                $('[name="permanentId"]').remove();
                $('.option-intelligence').remove();
            }
            $.operate.saveTab(prefix + "/add", $('#form-question-add').serialize());
        }
    };
 
    var cancel = function () {
        $('.input-focus').find('[edit="true"]').removeAttrs("edit");
        $('#modalWindow').modal('hide');
    };
 
    //大写字母数组
    var createletter = function () {
        for (var i = 97; i < 123; i++) {
            option.push(String.fromCharCode(i));
        }
    };
 
    // 多语言的默认选项
    var defualItem = function () {
        var $selectInput = $('#optionEdit').find('[name="selectInput"]');
 
        if ($('[name="langType"]').val() == "Chinese") {
        }
 
        if ($('[name="langType"]').val() == "English") {
        }
 
        if ($('[name="langType"]').val() == "Thai") {
        }
    };
 
    $(function () {
        createletter();
        //打开富文本编辑器
 
 
        // add questionItems
        $('#optionAdd').click(function () {
            if (clicknum < 0 || clicknum > 26) {
                return;
            }
 
            //添加答案项
            var $content = $('#optionTemplte').clone();
            $content.removeAttrs('id');
            $content.removeAttrs('hidden');
            $content.removeAttrs('style');
            var $contenChildren = $content.children();
            $contenChildren.eq(0).html(option[clicknum]);
            $contenChildren.eq(1).val(option[clicknum]);
            clicknum++;
            $('#optionEdit').append($content);
        });
 
        $('.option-group').on("click", ".glyphicon", function () {
            var optiontext = $(this).parent().children().eq(0).html();
            $('.radio-inline').find('[value=' + optiontext + ']').parent().remove();
            $(this).parent().remove();
        });
 
        $('.layui-layer-border').on("focus", "input", function () {
            $('.question-item-must').attr('hidden', 'true');
        });
 
 
        $('#optionView').click(function () {
            $modal = $('#modalWindow').clone();
            $modal.attr('id', 'modalView');
            $modal.find('.modal-footer').html('');
            $modal.find('H5').html("view");
            $('#modalhidden').append($modal);
            $modal.modal('show');
            $modal.find('.modal-body').html('<div class="click2edit wrapper"></div>');
            $qution = $modal.find('.click2edit');
            $qution.html("<p style='font-size:15px;font-weight: bold'>" + $('[name="title"]').val() + "</p>" + "<ul><li>");
            $('#optionEdit').children('div').each(
                function () {
                    $qution.append($(this).children('input').eq(0).val() + ". " + $(this).children('input').eq(1).val() +"&nbsp;&nbsp;&nbsp;");
                }
            );
            $qution.append("</li></ul>");
        });
 
        $('#modalhidden').on('click', 'button', function () {
            $(this).parents('.modal').modal('hide');
            $('#modalhidden').html("");
        });
 
        $('.input-focus').on('blur', '[name="choiceInput"]', function () {
            var $choiceInputs = $('.input-focus').find('[name="choiceInput"]');
            $(this).prev().html($(this).val());
            $('#answer').find('input').each(function (i) {
                $(this).val($choiceInputs.eq(i).val());
                var $input = $(this).clone();
                var $parent = $(this).parent();
                $parent.empty();
                $parent.append($input);
                $parent.append($choiceInputs.eq(i).val());
            });
        });
 
        // 给个语言对应的默认值
        defualItem();
        $('[name="langType"]').change(function () {
            var $selectInput = $('#optionEdit').find('[name="selectInput"]');
 
            if ($(this).val() == "Chinese") {
            }
 
            if ($(this).val() == "English") {
            }
 
            if ($(this).val() == "Thai") {
            }
        });
 
        $(':radio').click(function () {
            var checkValue = $('input:radio[name="template"]:checked').val();
            if (checkValue == "intelligence") {
                $('.option-intelligence').removeAttrs("hidden");
                $('#optionView').removeAttrs("style");
                $('#optionAdd').removeAttrs("style");
                $('.permanent').removeAttrs("hidden");
                $('#permanentId').attr("required","true");
            } else {
                $('.option-intelligence').attr("hidden", "true");
                $('#optionView').css("display","none");
                $('#optionAdd').css("display","none");
                $('.permanent').attr("hidden","true");
                $('#permanentId').removeAttrs("required");
            }
        });
 
    });
 
 
</script>
</body>
</html>