5d2c2033
孙向锦
自定义出题
|
1
2
3
|
$(function(){
/*快速创建答案列表*/
var score=0;
|
10146a46
孙向锦
创建试卷
|
4
5
|
var total_score = 0;
var questionNUm = 0 ;
|
5d2c2033
孙向锦
自定义出题
|
6
|
function creat(str_ans,a_num,fraction){
|
10146a46
孙向锦
创建试卷
|
7
8
|
// $(".section").remove();
answer_index_b=$(".section").length+1;
|
0b46638a
孙向锦
标准答案
|
9
|
/*$(".content").append('<div class="section section-1 single" data-fraction="'+fraction+'" data-score=""> <div class="title"> <h3><span class="que_num">一、</span><span class="que_name">单选</span></h3> <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> </div> <div class="question_list"></div></div>')*/
|
5d2c2033
孙向锦
自定义出题
|
10
11
12
13
14
15
16
17
18
|
var str=str_ans.split('');
console.log(str);
for(i=0;i<str.length;i++){
if(str[i] == " "){
str.splice(i,1);
i= i-1;
}
}
q_num=str.length;
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
19
|
$(".content").append('<div class="section section-' + answer_index_b +' single" data-fraction="'+fraction+'" data-score="'+(q_num * fraction)+'"><div class="title"><h3>第' +answer_index_b +'大题总分: ' + (q_num * fraction)+'分<!--<span>请在试题选项上点击,亮色为该试题的正确答案 </span> --></h3> </div><div class="question_list"></div></div>');
|
5d2c2033
孙向锦
自定义出题
|
20
21
22
23
24
|
for(var i=0;i<q_num;i++){
str_temp=str[i];
str_temp=str_temp.toUpperCase()
code = str_temp.charCodeAt();
on_index=code-65;
|
10146a46
孙向锦
创建试卷
|
25
|
questionNUm++;
|
5d2c2033
孙向锦
自定义出题
|
26
27
|
if(code<(65+a_num)){
console.log(str_temp);
|
10146a46
孙向锦
创建试卷
|
28
|
$(".section-" +answer_index_b +" .question_list").append('<div class="question question'+(questionNUm)+'"><span>'+(questionNUm)+'、</span><ul></ul></div>');
|
5d2c2033
孙向锦
自定义出题
|
29
30
31
32
|
for(var j=0;j<a_num;j++){
option=String.fromCharCode(0x41+j);
if(on_index==j){
console.log(on_index+"---"+j);
|
10146a46
孙向锦
创建试卷
|
33
|
$(".question"+(questionNUm)+' ul').append('<li class="btn btn-default on">'+option+'</li>');
|
5d2c2033
孙向锦
自定义出题
|
34
|
}else
|
10146a46
孙向锦
创建试卷
|
35
|
$(".question"+(questionNUm)+' ul').append('<li class="btn btn-default">'+option+'</li>');
|
5d2c2033
孙向锦
自定义出题
|
36
37
38
39
40
41
|
}
}else{
alert("题目"+(i+1)+":"+String.fromCharCode(code)+"答案错误,超出选项数");
//return;
}
}
|
10146a46
孙向锦
创建试卷
|
42
43
44
|
$(".section-" +answer_index_b).attr("data-score",$(".section-1").find(".question").length*fraction);
total_score += q_num * fraction;
$("#score_all").text(total_score);
|
5d2c2033
孙向锦
自定义出题
|
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
|
}
/***********
*1、单选题
*2、完形填空
*3、阅读理解
*4、判断题
*5、多选题
***********/
function addQuestion(type,a_num,index_s_2,index_e_2,fraction2){
console.log(type);
answer_index_b=$(".section").length+1;
var question_num=SectionToChinese($(".section").length+1);
switch(type){
case 1: //单选题
//alert(typeof(index_s_2));
$(".content").append('<div class="section section-'+answer_index_b+' single" data-fraction="'+fraction2+'" data-score=""> <div class="title"> <h3><span class="que_num">'+question_num+'、</span>'+'<span class="que_name">单选</span></h3> <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> </div> <div class="question_list"></div></div>');
for(i=index_s_2;i<=index_e_2;i++){
$(".section-"+answer_index_b+" .question_list").append('<div class="question question'+i+'"><span>'+i+'、</span><ul></ul></div>');
for(var j=0;j<a_num;j++){
option=String.fromCharCode(0x41+j);
$(".section-"+answer_index_b+" .question"+i+' ul').append('<li class="btn btn-default">'+option+'</li>');
}
}
break;
case 2: //完形填空
$(".content").append('<div class="section section-'+answer_index_b+' single" data-fraction="'+fraction2+'" data-score=""> <div class="title"> <h3><span class="que_num">'+question_num+'、</span><span class="que_name">完形填空</span></h3> <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> </div> <div class="question_list"></div></div>');
for(var i=index_s_2;i<=index_e_2;i++){
$(".section-"+answer_index_b+" .question_list").append('<div class="question question'+i+'"><span>'+i+'、</span><ul></ul></div>');
for(var j=0;j<a_num;j++){
option=String.fromCharCode(0x41+j);
$(".section-"+answer_index_b+" .question"+i+' ul').append('<li class="btn btn-default">'+option+'</li>');
}
}
break;
case 3: //阅读理解
$(".content").append('<div class="section section-'+answer_index_b+' single" data-fraction="'+fraction2+'" data-score=""> <div class="title"> <h3><span class="que_num">'+question_num+'、</span><span class="que_name">阅读理解</span></h3> <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> </div> <div class="question_list"></div></div>');
for(var i=index_s_2;i<=index_e_2;i++){
$(".section-"+answer_index_b+" .question_list").append('<div class="question question'+i+'"><span>'+i+'、</span><ul></ul></div>');
for(var j=0;j<a_num;j++){
option=String.fromCharCode(0x41+j);
$(".section-"+answer_index_b+" .question"+i+' ul').append('<li class="btn btn-default">'+option+'</li>');
}
}
break;
case 4: //判断题
$(".content").append('<div class="section section-'+answer_index_b+' single" data-fraction="'+fraction2+'" data-score=""> <div class="title"> <h3><span class="que_num">'+question_num+'、</span><span class="que_name">判断题</span></h3> <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> </div> <div class="question_list"></div></div>');
for(var i=index_s_2;i<=index_e_2;i++){
$(".section-"+answer_index_b+" .question_list").append('<div class="question question'+i+'"><span>'+i+'、</span><ul></ul></div>');
for(var j=0;j<a_num;j++){
if(j%2==0)
option="√";
else
option="×";
$(".section-"+answer_index_b+" .question"+i+' ul').append('<li class="btn btn-default">'+option+'</li>');
}
}
break;
|
0b46638a
孙向锦
标准答案
|
104
|
/*case 5: //多选题
|
5d2c2033
孙向锦
自定义出题
|
105
106
107
108
109
110
111
|
$(".content").append('<div class="section section-'+answer_index_b+' check" data-fraction="'+fraction2+'" data-score=""> <div class="title"> <h3><span class="que_num">'+question_num+'、</span><span class="que_name">多选题</span></h3> <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> </div> <div class="question_list"></div></div>');
for(var i=index_s_2;i<=index_e_2;i++){
$(".section-"+answer_index_b+" .question_list").append('<div class="question question'+i+'"><span>'+i+'、</span><ul></ul></div>');
for(var j=0;j<a_num;j++){
option=String.fromCharCode(0x41+j);
$(".section-"+answer_index_b+" .question"+i+' ul').append('<li class="btn btn-default">'+option+'</li>');
}
|
0b46638a
孙向锦
标准答案
|
112
113
|
}*/
case 5: //多选题
|
10146a46
孙向锦
创建试卷
|
114
|
// $(".content").html("");
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
115
|
$(".content").append('<div class="section section-'+ answer_index_b +' check" data-fraction="'+fraction2+'" data-score="' + ((index_e_2- index_s_2 + 1 )* fraction2)+ '"> <div class="title"><h3>第' +answer_index_b +'大题总分: ' + ((index_e_2- index_s_2 + 1 )* fraction2)+'分<!--<span>请在试题选项上点击,亮色为该试题的正确答案 </span>--></h3> </div> <div class="question_list"></div></div>');
|
0b46638a
孙向锦
标准答案
|
116
|
for(var i=index_s_2;i<=index_e_2;i++){
|
10146a46
孙向锦
创建试卷
|
117
118
|
questionNUm++;
$(".section-" + answer_index_b +" .question_list").append('<div class="question question'+questionNUm+'"><span>'+questionNUm+'、</span><ul></ul></div>');
|
0b46638a
孙向锦
标准答案
|
119
120
|
for(var j=0;j<a_num;j++){
option=String.fromCharCode(0x41+j);
|
10146a46
孙向锦
创建试卷
|
121
|
$(".section-" + answer_index_b +" .question"+questionNUm+' ul').append('<li class="btn btn-default">'+option+'</li>');
|
0b46638a
孙向锦
标准答案
|
122
|
}
|
5d2c2033
孙向锦
自定义出题
|
123
|
}
|
10146a46
孙向锦
创建试卷
|
124
125
|
total_score +=((index_e_2- index_s_2 + 1 )* fraction2);
$("#score_all").text(total_score);
|
5d2c2033
孙向锦
自定义出题
|
126
127
|
break;
}
|
0b46638a
孙向锦
标准答案
|
128
129
|
// $(".section-"+answer_index_b).attr("data-score",$(".section-"+answer_index_b).find(".question").length*fraction2);
$(".section0").attr("data-score",$(".section0").find(".question").length*fraction2);
|
5d2c2033
孙向锦
自定义出题
|
130
131
132
133
134
135
136
|
}
$(document).on('click','.remove',function(){ //删除按钮
$(this).parent().parent(".section").remove();
})
$("#fast_submit").click(function(){ //点击确定,创建答案列表
|
10146a46
孙向锦
创建试卷
|
137
|
// $("#addQuestion").attr("disabled","disabled");
|
5d2c2033
孙向锦
自定义出题
|
138
139
140
141
|
var answer=$("#answer").val();
var num_ans=$("#num_ans").val();
var fraction=$("#fraction").val();
if(answer==''){
|
ee61a3f0
孙向锦
增强判断
|
142
|
alert("请输入题目答案");
|
5d2c2033
孙向锦
自定义出题
|
143
144
145
146
147
|
return;
}else if(fraction==''){
alert("请输入题目分数");
return;
}
|
10146a46
孙向锦
创建试卷
|
148
|
var frac = parseFloat(fraction);
|
67dfaf5c
孙向锦
提交代码
|
149
150
151
152
153
154
155
156
|
if(frac > 0){
$('.fast').modal('hide');
//score += parseInt(fraction)*answer.split(",").length;
creat(answer,num_ans,fraction);
}else{
alert("请输入正确分数");
return;
}
|
5d2c2033
孙向锦
自定义出题
|
157
158
159
160
|
})
/*添加试题的确定按钮*/
$("#addQuestion_submit").click(function(){
|
10146a46
孙向锦
创建试卷
|
161
|
// $("#fast").attr("disabled","disabled");
|
0b46638a
孙向锦
标准答案
|
162
163
164
|
var type_2=5;//parseInt($("#type").val())
var index_s_2=1;//parseInt($("#index_s_2").val())
var index_e_2=parseInt($("#index_s_2").val());
|
5d2c2033
孙向锦
自定义出题
|
165
166
|
//var answer_2=$("#answer_2").val();
var num_ans_2=$("#num_ans_2").val();
|
10146a46
孙向锦
创建试卷
|
167
|
var fraction2=parseFloat($("#fraction2").val());
|
ee61a3f0
孙向锦
增强判断
|
168
|
if(isNaN(index_s_2)){
|
5d2c2033
孙向锦
自定义出题
|
169
170
|
alert("请输入题目开始序号");
return;
|
ee61a3f0
孙向锦
增强判断
|
171
|
}else if(isNaN(index_e_2)){
|
0b46638a
孙向锦
标准答案
|
172
|
alert("请输入题目个数");//alert("请输入题目结束序号");
|
5d2c2033
孙向锦
自定义出题
|
173
|
return;
|
ee61a3f0
孙向锦
增强判断
|
174
175
176
|
}else if(isNaN(fraction2)){
alert("请输入题目分数");
return;
|
5d2c2033
孙向锦
自定义出题
|
177
|
}
|
67dfaf5c
孙向锦
提交代码
|
178
179
180
181
182
|
var iindex_e_2 = parseInt(index_e_2);
if(iindex_e_2 < 1 || iindex_e_2 > 100){
alert("题目个数不合法");
return;
}
|
5d2c2033
孙向锦
自定义出题
|
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
|
//console.log(typeof(type_2));
addQuestion(type_2,num_ans_2,index_s_2,index_e_2,fraction2);
$('.addQuestion').modal('hide');
})
$("#type").change(function(){
if($("#type").val()==4){
$("#num_ans_2").val(2);
$("#num_ans_2").attr("disabled","disabled");
}else{
$("#num_ans_2").removeAttr("disabled");
$("#num_ans_2").val(4);
}
})
/*更改考试时长*/
$("#time_submit").click(function(){
var test_time=$("#enter_time").val();
if(test_time==''){
alert("请输入考试时间");
return;
}
$("#time").html(test_time);
$('.test_time').modal('hide');
})
/*更改单选答案*/
$(document).on('click','.single li',function(){
$(this).siblings().removeClass("on");
$(this).addClass("on");
})
/*更改多选答案*/
$(document).on('click','.check li',function(){
//$(this).siblings().removeClass("on");
|
67dfaf5c
孙向锦
提交代码
|
215
216
217
218
219
|
if($(this).hasClass('on')){
$(this).removeClass("on");
}else{
$(this).addClass("on");
}
|
5d2c2033
孙向锦
自定义出题
|
220
221
222
223
|
})
/*提交保存数据*/
$("#save").click(function(){
var url=URL;
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
224
|
|
5d2c2033
孙向锦
自定义出题
|
225
226
227
228
229
230
231
|
var data={
title: $(".header_box h1").text(),
exam_time: parseInt($("#time").text()),
paper_type: testData.paper_type,
subject_id: testData.subject_id,
grade_id: testData.grade_id,
user_id: testData.user_id,
|
4b6a5239
孙向锦
管理员界面
|
232
|
school_id: testData.school_id,
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
233
|
score:total_score,
|
5d2c2033
孙向锦
自定义出题
|
234
235
236
237
238
239
|
questions:[]
}
if($(".section").length>0){
var rank=0
for(i=0;i<$(".section").length;i++){
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
240
|
//rank++;
|
5d2c2033
孙向锦
自定义出题
|
241
242
243
244
|
data.questions[i]={
chapter_id: "0",
problem_type_id: "0",
knowledge_id: "0",
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
245
|
// content: $(".section").eq(i).find(".que_name").text(),
|
5d2c2033
孙向锦
自定义出题
|
246
247
248
249
250
251
|
option_num: "",
option_content: "",
answer: "",
difficulty: "",
analysis: "",
question_from: "",
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
252
|
score:parseFloat($(".section").eq(i).attr("data-score")),
|
5d2c2033
孙向锦
自定义出题
|
253
254
255
256
257
|
part_score: "",
remark: "",
rank: rank,
no_name: $(".section").eq(i).find(".que_num").text(),
questions:[]
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
258
|
}
|
5d2c2033
孙向锦
自定义出题
|
259
260
261
262
263
264
265
266
|
for(j=0;j<$(".section").eq(i).find(".question_list").children(".question").length;j++){
rank++;
var on_num=$(".section").eq(i).find(".question").eq(j).find(".on").length;
var answer="";
for(k=0;k<on_num;k++){
answer+=$(".section").eq(i).find(".question").eq(j).find(".on").eq(k).text();
//console.log(answer);
}
|
67dfaf5c
孙向锦
提交代码
|
267
268
269
270
|
if(answer == ''){
alert("还有试题未编辑答案。");
return;
}
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
271
|
data.questions[i].questions[j]={
|
5d2c2033
孙向锦
自定义出题
|
272
273
274
275
276
277
278
279
280
281
|
chapter_id: "0",
problem_type_id: "0",
knowledge_id: "0",
content: "",
option_num: $(".section").eq(i).find(".question").eq(j).find("li").length,
option_content: "",
answer: answer,
difficulty: "0",
analysis: "",
question_from: "1",
|
a0ec879e
孙向锦
修改部分bug
|
282
|
score: parseFloat($(".section").eq(i).attr("data-fraction")),
|
5d2c2033
孙向锦
自定义出题
|
283
284
285
|
part_score: "0",
remark: "",
rank: rank,
|
10146a46
孙向锦
创建试卷
|
286
|
no_name: rank,
|
5d2c2033
孙向锦
自定义出题
|
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
}
}
}
}
if(data.questions.length>0){
data=JSON.stringify(data);
dataJson={"json":data};
console.log(data);
ajax_submit(url,dataJson);
}
else
alert("请添加试题");
})
})
/*ajax封装函数*/
function ajax_submit(url,data){
$(".loading").css("display","block");
|
a0ec879e
孙向锦
修改部分bug
|
309
|
console.log(data);
|
5d2c2033
孙向锦
自定义出题
|
310
311
312
313
314
|
$.ajax({
url:url,
type:"POST",
data:data,
dataType:"json",
|
a0ec879e
孙向锦
修改部分bug
|
315
|
contentType:"application/x-www-form-urlencoded; charset=utf-8",
|
5d2c2033
孙向锦
自定义出题
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
success:function(data){
$(".loading").css("display","none");
window.location.href = JUMP_URL ;
}
})
}
function fastSort(array,head,tail){
//考虑到给每个分区操作的时候都是在原有的数组中进行操作的,所以这里head,tail来确定分片的位置
/*生成随机项*/
var randomnum = parseInt((head + tail) / 2 );
var random = array[randomnum];
/*将小于random的项放置在其左边 策略就是通过一个临时的数组来储存分好区的结果,再到原数组中替换*/
var arrayTemp = [];
var unshiftHead = 0;
for(var i = head;i <= tail;i++){
if(parseInt(array[i].rank)<parseInt(random.rank)){
arrayTemp.unshift(array[i]);
unshiftHead++;
}else if(parseInt(array[i].rank)>parseInt(random.rank)){
arrayTemp.push(array[i]);
}
/*当它等于的时候放哪,这里我想选择放到队列的前面,也就是从unshift后的第一个位置放置*/
if(parseInt(array[i].rank)===parseInt(random.rank)){
arrayTemp.splice(unshiftHead,0,array[i]);
}
}
/*将对应项覆盖原来的记录*/
for(var j = head , u=0;j <= tail;j++,u++){
array.splice(j,1,arrayTemp[u]);
}
/*寻找中间项所在的index*/
var nowIndex = array.indexOf(random);
/*设置出口,当要放进去的片段只有2项的时候就可以收工了*/
if(arrayTemp.length <= 2){
return;
}
/*递归,同时应用其左右两个区域*/
fastSort(array,head,nowIndex);
fastSort(array,nowIndex+1,tail);
}
if(testData.questions.length > 0){
fastSort(testData.questions,0,testData.questions.length-1);
for(var i = 0 ; i < testData.questions.length;i++){
|
0b46638a
孙向锦
标准答案
|
360
361
|
if(testData.questions[0].questions && testData.questions[0].questions.length > 1){
|
5d2c2033
孙向锦
自定义出题
|
362
363
364
365
366
367
368
369
370
371
|
fastSort(testData.questions[i].questions,0,testData.questions[i].questions.length-1);
}
}
}
creatHtml(testData);
function creatHtml(data){
console.log(data);
$(".header_box h1").html(data.title);
$("#time").html(data.exam_time);
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
372
|
$("#score_all").html(data.score);
|
0b46638a
孙向锦
标准答案
|
373
374
375
376
377
378
379
|
if(data.questions.length>0){
$(".time").removeAttr("data-target");
$(".remove").remove();
$(".btn_box").remove();
}
|
5d2c2033
孙向锦
自定义出题
|
380
|
for(var i=0;i<data.questions.length;i++){
|
0b46638a
孙向锦
标准答案
|
381
|
if(data.questions[i].questions){
|
107fa3a0
孙向锦
修改试卷单选多远混合出题
|
382
|
$(".content").append('<div class="section section-'+i+'" data-fraction="'+data.questions[i].score+'" style="margin-top:20px;"> <h3><span class="que_num">'+'第'+ (i+1) + '大题总分:'+ data.questions[i].sug_score +'</span>'+'<span class="que_name">'+data.questions[i].content+'</span></h3><!-- <input type="button" class="btn btn-danger pull-right remove" name="remove" value="删除" /> --> <div class="question_list"></div></div>');
|
0b46638a
孙向锦
标准答案
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
}else{
if(i == 0){
$(".content").append('<div class="section section0"> <div class="question_list"></div></div>');
}
$(".section0").find(".question_list").append('<div class="question question'+(i+1)+'"><span>'+(i+1)+'、</span><ul></ul></div>');
for(var k=0;k<parseInt(data.questions[i].option_num);k++){
str_temp=data.questions[i].answer;
$(".section0").find(".question"+(i+1)+' ul').append('<li class="btn btn-default">'+String.fromCharCode(0x41+k)+'</li>');
for(var l=0;l<str_temp.length;l++){
str_temp_arry=str_temp.split('');
code=str_temp_arry[l].charCodeAt();
on_index=code-65;
if(on_index==k){
$(".section0").find(".question"+(i+1)+' ul li').eq(on_index).attr("class","btn btn-default on");
}
}
}
|
5d2c2033
孙向锦
自定义出题
|
400
|
}
|
0b46638a
孙向锦
标准答案
|
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
if(data.questions[i].questions){
for(var j=0;j<data.questions[i].questions.length;j++){
$(".section-"+i).find(".question_list").append('<div class="question question'+(j+1)+'"><span>'+(j+1)+'、</span><ul></ul></div>');
if($(".section-"+i).find(".que_name").text()=="判断题"){
for(var k=0;k<parseInt(data.questions[i].questions[j].option_num);k++){
str_temp=data.questions[i].questions[j].answer;
if(k%2==0){
$(".section-"+i).find(".question"+(j+1)+' ul').append('<li class="btn btn-default">√</li>');
}else if(k%2==1){
$(".section-"+i).find(".question"+(j+1)+' ul').append('<li class="btn btn-default">×</li>');
}
if(str_temp=="√")
$(".section-"+i).find(".question"+(j+1)+' ul li').eq(0).attr("class","btn btn-default on");
else
$(".section-"+i).find(".question"+(j+1)+' ul li').eq(1).attr("class","btn btn-default on");
|
5d2c2033
孙向锦
自定义出题
|
418
|
}
|
0b46638a
孙向锦
标准答案
|
419
420
421
422
423
424
425
426
427
428
429
430
|
}else{
for(var k=0;k<parseInt(data.questions[i].questions[j].option_num);k++){
str_temp=data.questions[i].questions[j].answer;
$(".section-"+i).find(".question"+(j+1)+' ul').append('<li class="btn btn-default">'+String.fromCharCode(0x41+k)+'</li>');
for(var l=0;l<str_temp.length;l++){
str_temp_arry=str_temp.split('');
code=str_temp_arry[l].charCodeAt();
on_index=code-65;
if(on_index==k){
$(".section-"+i).find(".question"+(j+1)+' ul li').eq(on_index).attr("class","btn btn-default on");
}
}
|
5d2c2033
孙向锦
自定义出题
|
431
432
433
434
435
436
|
}
}
}
}
}
}
|
7242423d
孙向锦
添加固件管理
|
437
438
|
var answerLen = 0 ;
|
5d2c2033
孙向锦
自定义出题
|
439
|
/*快速建题中,每输入五个答案就加一个空格*/
|
67dfaf5c
孙向锦
提交代码
|
440
441
442
443
444
445
446
447
448
449
|
$("#answer").on("input propertychange", function(event) {
var answerStr = "";
answerStr = $("#answer").val();
var result = "";
if (answerStr.length > 5) {
answerStr = answerStr.replace(new RegExp(" ", "gm"), "");
for (var i = 0; i < answerStr.length; i++) {
result += answerStr[i];
if (i % 5 == 4 && i != answerStr.length -1) {
result += " ";
|
0b46638a
孙向锦
标准答案
|
450
|
}
|
7242423d
孙向锦
添加固件管理
|
451
|
}
|
67dfaf5c
孙向锦
提交代码
|
452
453
454
455
456
457
458
459
|
} else {
result = answerStr;
}
$("#answer").val(result);
if (answerStr.length > 0) {
$(".tips").text("共" + answerStr.length + "题");
} else {
$(".tips").text("");
|
7242423d
孙向锦
添加固件管理
|
460
|
}
|
5d2c2033
孙向锦
自定义出题
|
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
})
/*数字转汉字数字*/
var chnNumChar = ["零","一","二","三","四","五","六","七","八","九"];
var chnUnitSection = ["","万","亿","万亿","亿亿"];
var chnUnitChar = ["","十","百","千"];
function SectionToChinese(section){
var strIns = '', chnStr = '';
var unitPos = 0;
var zero = true;
while(section > 0){
var v = section % 10;
if(v === 0){
if(!zero){
zero = true;
chnStr = chnNumChar[v] + chnStr;
}
}else{
zero = false;
strIns = chnNumChar[v];
strIns += chnUnitChar[unitPos];
chnStr = strIns + chnStr;
}
unitPos++;
section = Math.floor(section / 10);
}
return chnStr;
}
|