-
Notifications
You must be signed in to change notification settings - Fork 0
/
addtest.html
289 lines (273 loc) · 9.68 KB
/
addtest.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>创建试题</title>
<link href="css/mui.min.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="css/app.css"/>
<link rel="stylesheet" type="text/css" href="css/iconfont.css"/>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/tool.js"></script>
<script type="text/javascript" src="js/jquery-clock-timepicker.min.js"></script>
<script type="text/javascript" src="css/bootstrap-clockpicker.css"></script>
<script type="text/javascript" src="js/bootstrap-clockpicker.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap-clockpicker.min.css"/>
<script type="text/javascript" src="js/bootstrap-clockpicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery-clockpicker.css"/>
<script type="text/javascript" src="js/jquery-clockpicker.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery-clockpicker.min.css"/>
<!--<script type="text/javascript" src="jquery-clockpicker.min.js"></script>-->
<style>
input{
width:100%;
}
.time
{
display:inline-block;
font-size:26px;
padding:5px;
text-align:center;
width:110%;
}
.choice{
font-size: 15px;
}
.check{
vertical-align:middle;
}
</style>
<script >
var data1;//班级列表数据
var data2;//试卷列表数据
var userid = GetUseridCookie().get("userid");
// if(userid==undefined){
// alert("登录过期,请重新登录!");
// javascript:window.location.href="login.html"
// }
var paperid;
function fp_ready(){
Flatpickr.l10n.firstDayOfWeek = 1;
document.getElementById("flatpickr-tryme").flatpickr();
}
// function selectpaper(){
// paper=[];
// var str='';
// mui.ajax('http://'+url+'/jizhibackend/servlet/GetPaperServlet',{
// data:
// {
// userid:userid,
// },
// xhrFields: {
//
// withCredentials: true
//
// },
// crossDomain: true,
// dataType: 'json', //服务器返回json格式数据
// type: 'post', //HTTP请求类型
// timeout: 10000, //超时时间设置为10秒;
// headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
// success: function(data) {
// data1=data.papers;
// jQuery.each(data1,function(index,item){
// document.getElementById('testid').options.add(new Option(item.title,item.id));
// });
// },
// error: function(xhr, type, errorThrown) {
// console.log(errorThrown);
// }
// });
// }
window.onload = function(){
mui.ajax('http://'+url+'/jizhibackend/servlet/GetStudentClassServlet',{
data:
{
userid:userid,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
data1=data.classes;
// alert(data1.length);
jQuery.each(data1,function(index,item){
document.getElementById('class').options.add(new Option(item.name,item.id));
});
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
}
});
mui.ajax('http://'+url+'/jizhibackend/servlet/GetPaperServlet',{
data:
{
userid:userid,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
data2=data.papers;
jQuery.each(data2,function(index,item){
document.getElementById('testid').options.add(new Option(item.title,item.id));
});
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
}
});
}
// function selectclass(){
// jQuery.each(data1,function(index,item){
// document.getElementById('class').options.add(new Option(item.name,item.id));
// });
// }
</script>
<script async src="js/flatpickr.js" onload="fp_ready()"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class=" mui-icon mui-icon-left-nav mui-pull-left" href="t_test.html"></a>
<h1 class="mui-title">创建测试</h1>
</header>
<div class="mui-content">
<form>
<p></p>
<p><strong> 选择日期</strong></p>
<p>
<input id="flatpickr-tryme" >
</p>
<p></p>
<p><strong> 开始时间</strong></p>
<p>
<!--<input class="time" type="text" id="starttime" value="00:00" onchange="console.log('Time changed')" />-->
<div class="input-group clockpicker">
<input type="text" class="form-control" id="starttime" value="00:00">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</p>
<p></p>
<p><strong> 结束时间</strong></p>
<p>
<!--<input class="time" type="text" id="endtime" value="00:00" onchange="console.log('Time changed')" />-->
<div class="input-group clockpicker">
<input type="text" class="form-control" id="endtime" value="00:00">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</p>
<p></p>
<p><strong> 测试班级</strong></p>
<p>
<select id="class">
<option></option>
</select>
</p>
<p></p>
<p><strong> 测试题目</strong></p>
<p>
<select id="testid">
<option></option>
</select>
</p>
<p></p>
<p><strong> 标题</strong></p>
<p>
<input id="title" >
</p>
<!--<div class="choice">
<label class="label" for="remembercheck">
允许测试未结束时查看答题解析<input class="check" type="checkbox" name="frm_checkbox" >
</label>
</div>-->
</form>
</div>
<div class="mui-content-padded">
<div class="login_btn">
<button id='reg' class="mui-btn mui-btn-block mui-btn-primary">完成</button>
</div>
</div>
</body>
<script src="js/mui.min.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript" src="js/jquery-clock-timepicker.min.js"></script>
<script type="text/javascript">
// $(document).ready(function() {
// $('.time').clockTimePicker({});
// });
$(document).ready(function() {
$('.clockpicker').clockpicker();
});
(function($,doc){
var day = document.getElementById("flatpickr-tryme");
var starttime = document.getElementById("starttime");
var endtime=document.getElementById("endtime");
if(starttime>=endtime)
var classid = document.getElementById('class');
var testid=document.getElementById("testid");
var title=document.getElementById("title");
var btnlogin=document.getElementById("reg");
btnlogin.onclick = function() {
var start_time=day.value+' '+starttime.value+':00';
var end_time=day.value+' '+endtime.value+':00';
start_time = start_time.replace(new RegExp("-","gm"),"/");
var start_timeH = (new Date(start_time)).getTime(); //得到毫秒数
end_time = end_time.replace(new RegExp("-","gm"),"/");
var end_timeH = (new Date(end_time)).getTime(); //得到毫秒数
if(start_timeH>=end_timeH){
alert("结束时间必须晚于开始时间!");
return;
}
mui.ajax('http://'+url+'/jizhibackend/servlet/CreateTestServlet',{
data:
{
title:title.value,
start_time:start_timeH,
end_time:end_timeH,
paperid:testid.value,
privilege:1,
classes:classid.value,
userid:userid,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
mui.toast("创建测试成功!");
javascript:window.location.href="t_test.html"
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
console.log(type);
console.log(xhr);
}
});
}
}
)(mui.document);
</script>
</html>