南皮县网站建设,wordpress y郁思注意,wordpress站点地址没更改,做网站万网前言 我发现一个人厉害不只是他厉害#xff0c;他的名字也一定要跟着厉害才行#xff0c;比如我刀狂剑痴叶小钗了#xff0c;若是老夫叫做刀狂剑痴叶小草#xff0c;估计就缺少气势了#xff01;#xff01;#xff01; 又如百世经纶一页书#xff0c;如果叫做百世经纶…前言 我发现一个人厉害不只是他厉害他的名字也一定要跟着厉害才行比如我刀狂剑痴叶小钗了若是老夫叫做刀狂剑痴叶小草估计就缺少气势了 又如百世经纶一页书如果叫做百世经纶一本书估计也不会是绝代高手了说了我给标题取了个很霸气的名字 “前端无优化庸人自扰之”其实我也不知道他是什么意思了好了啰嗦结束进入正题。 最近遇到一个有意思的东西是关于考试题相关的东东其实就是我有很多试题需要生成试卷让人来做了真实应用有点不同但是他却让我想起了我的初恋 我原来花了一年时间做的考试系统所以有了这篇文章。 PS本人前端水平很水在此就是大言不惭罢了甚至想引出真正的高手解决问题各位看到我的“优化”权当笑话看吧 在线考试系统 有图有真相 图太长给删了。。。 当年我还很纯洁 那一年是我在大学的一年那一年我还以为苍老师只是老师那一年我不会把波多野结衣当做林志玲那一年我还是处男。。。。 于是那一年天真的我做出了以上页面并且承受住了学院400人的C语言期末考试。但是如今我们来看看页面来看看我的纯洁吧 因为有几年的时间了我已经忘了当年开发.net项目的岁月了但是我隐约记得我的这个界面使用gridview搞出来的里面还好像有很多嵌套。。 1 % Page LanguageC# AutoEventWireuptrue CodeFileStudent_Exam_Ajax_Paper.aspx.cs2 InheritsStudent_Student_Exam_Ajax_Paper %3 4 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd5 html xmlnshttp://www.w3.org/1999/xhtml6 head idHead1 runatserver7 title考试界面/title8 %--曾沿用--%9 link href../css/style.css typetext/css relstylesheet /10 %--曾沿用--%11 link hrefcss/public.css relstylesheet typetext/css /12 link hrefcss/master.css relstylesheet typetext/css /13 style typetext/css14 body15 {16 padding-bottom: 70px;17 background: #e2f1ff url(http://exam.51edu.com/images/pagebodybg.jpg) 0 0 repeat-x;18 }19 .wlArea88020 {21 margin: 5px 0px 0px;22 border: 1px solid #ecc9c9;23 width: 300px;24 height: 20px;25 font-size: 12px;26 line-height: 18px;27 background-color: #fff0f0;28 color: #333;29 }30 /style31 32 script typetext/javascript 33 34 35 var xmlhttprequest_yas //XMLHttp对象36 37 38 39 var m%lbRemainTime.Text %;40 if(m90)41 {42 mm1;43 }44 var TimeNumm*60; 45 var timeStr; 46 47 48 function createXmlHttpRequest()49 {50 //IE7,FireFox and others;51 if(window.XMLHttpRequest)52 {53 xmlhttprequest_yasnew XMLHttpRequest();54 }55 else if(window.ActiveXObject)//IE其它的版本56 {57 xmlhttprequest_yasnew ActiveXObject(Microsoft.XMLHTTP);58 }59 else60 { 61 alert(Your browser cannt support XMLHttpRequest!)62 }63 }64 65 function autoputin() //自动提交发送Ajax请求 完成的业务逻辑为将当前剩余时间与当前考试时间读入并将考试状态读出。66 {67 var remaintimem; //获得剩余时间68 var RequestURLAjaxServer.aspx?remaintimeremaintimeexamid%lbExamID.Text %;69 70 createXmlHttpRequest();71 if(xmlhttprequest_yas)72 {73 74 xmlhttprequest_yas.onreadystatechangecallBack;75 xmlhttprequest_yas.open(GET,RequestURL,true) ;76 xmlhttprequest_yas.send(null);77 // xmlhttprequest_yasnull;78 }79 }80 81 82 function callBack()83 {84 if(xmlhttprequest_yas.readyState4)85 {86 87 88 89 //xml中读出状态90 var stateNodesxmlhttprequest_yas.responseXML.documentElement.getElementsByTagName(state);91 var state ;92 statestateNodes[0].text;93 94 //var o document.getElementById(wlqq);95 // getreturn state;96 // o.valuegetreturn ;97 98 // if(state0)99 // {
100 // alert(你已经断线请尽快同管理员联系);
101 // }
102
103 if(state 3)
104 {
105 document.getElementById(btOk).click();
106 }
107
108 }
109 }
110
111
112
113 var timeShowIdtimeshow; //设置时间显示层ID
114
115
116
117 function ChangeTime(){
118 TimeNum--;
119 if(TimeNum 0){
120 var mnTimeNum/60;
121 if(m-mn1)
122 {
123 var nownew Date();
124 m--;
125
126 autoputin();
127 }
128
129 timeStrsetTimeout(ChangeTime(),1000);
130 }
131 else{
132 m0;
133 autoputin();
134 document.getElementById(btOk).click();
135 }
136 var mmm,sss;
137 mmmMath.floor(TimeNum/60)
138 sssTimeNum%60
139 if(mmm10)
140 mmm0mmm;
141 if(sss10)
142 sss0sss;
143
144 document.getElementById(timeShowId).innerHTML mmm分sss秒;
145
146 }
147
148 /script
149
150 script typetext/javascript charsetUTF-8
151
152 var xmlhttprequest_wl //XMLHttp对象
153
154
155 function createXmlHttpRequestForProblem()
156 {
157
158 //IE7,FireFox and others;
159 if(window.XMLHttpRequest)
160 {
161
162 xmlhttprequest_wlnew XMLHttpRequest();
163 }
164 else if(window.ActiveXObject)//IE其它的版本
165 {
166 xmlhttprequest_wlnew ActiveXObject(Microsoft.XMLHTTP);
167 }
168 else
169 {
170 alert(Your browser cannt support XMLHttpRequest!)
171 }
172 }
173
174
175 function putinanwer(answer , id) //自动提交发送Ajax请求 完成的业务逻辑为将当前剩余时间与当前考试时间读入并将考试状态读出。
176 {
177
178 var RequestURLAjaxServerPutIn.aspx?ididanswerescape(answer)randnew Date().getTime().toString(36);
179
180 createXmlHttpRequestForProblem();
181 if(xmlhttprequest_wl)
182 {
183
184
185 xmlhttprequest_wl.onreadystatechangecallBackAnswer;
186 xmlhttprequest_wl.open(GET,RequestURL,true) ;
187 xmlhttprequest_wl.setRequestHeader(Content-Type, utf-8);
188 xmlhttprequest_wl.send(null);
189
190 }
191
192 }
193
194
195
196 function callBackAnswer()
197 {
198 if(xmlhttprequest_wl.readyState4)
199 {
200
201 // var o document.getElementById(wlqq);
202 var getreturnsxmlhttprequest_wl.responseXML.documentElement.getElementsByTagName(getreturn);
203 var getreturn ;
204 getreturn getreturns[0].text;
205 // o.valuegetreturn ;
206 if(getreturn0)
207 {
208 alert(你已经断线请尽快同监考老师联系,或者重新登录考试);
209 window.close();
210 }
211
212 //alert(xmlhttprequest_wl.responseText);
213
214 //alert(你已经断线请尽快同管理员联系);
215
216 }
217
218
219 }
220
221
222 /script
223
224 script languageJavaScript
225 !--
226
227 if (window.Event)
228 document.captureEvents(Event.MOUSEUP);
229
230 function nocontextmenu()
231 {
232 event.cancelBubble true
233 event.returnValue false;
234
235 return false;
236 }
237
238 function norightclick(e)
239 {
240 if (window.Event)
241 {
242 if (e.which 2 || e.which 3)
243 return false;
244 }
245 else
246 if (event.button 2 || event.button 3)
247 {
248 event.cancelBubble true
249 event.returnValue false;
250 return false;
251 }
252
253 }
254
255 document.oncontextmenu nocontextmenu; //对ie5.0以上
256 document.onmousedown norightclick; //对其它浏览器
257 //--
258
259
260 !--
261 function document.onkeydown()
262 {
263 if ( event.keyCode116)
264 {
265 event.keyCode 0;
266 event.cancelBubble true;
267 return false;
268 }
269 }
270
271 --
272
273 /script
274
275 script typetext/javascript
276
277 //更改字体大小
278 var status0;
279 var curfontsize12;
280 var curlineheight20;
281 var count1;
282 function fontZoomA(){
283 if(curfontsize8){
284 document.getElementById(fontzoom).style.fontSize(--curfontsize)px;
285 document.getElementById(fontzoom).style.lineHeight(--curlineheight)px;
286 }
287 }
288 function fontZoomB(){
289 if(curfontsize100){
290 document.getElementById(fontzoom).style.fontSize(curfontsize)px;
291 document.getElementById(fontzoom).style.lineHeight(curlineheight)px;
292 }
293 }
294 /script
295
296 /head
297 body onloadChangeTime()
298 !--paperBox_begin--
299 div idpaperBox runatserver
300 div idpaperBoxTop
301 div classpagelogo
302 img srcimages/pagelogo.jpg width168 height79 border0 /
303 /div
304 div classpaperBoxtext
305 span欢迎您
306 %lbStudentName.Text %
307 /span
308 /div
309 /div
310 !--paperCont_begin--
311 div idpaperCont
312 form idpaperForm runatserver
313 h2 classbox_title
314 asp:Label IDlbName runatserver TextLabel/asp:Label
315 asp:Label IDlbStateTime runatserver TextLabel Visiblefalse/asp:Label
316 %--测试Ajax传输问题
317
318
319 input typetext idwlqq value111 style width:400px; /
320 --%
321
322 br /
323 /h2
324 div classbox_sttg
325 span所属课程
326 asp:Label IDlbCourse runatserver TextLabel/asp:Label
327 /spanspan试卷性质
328 asp:Label IDlbFlag runatserver TextLabel/asp:Label/span span难度系数
329 asp:Label IDlbGrade runatserver TextLabel/asp:Label【0为随机难度】
330 /span
331 /div
332 div classbox_sttg
333 table width100%
334 tr
335 td
336 span
337 asp:Label IDlbTime runatserver Text1 Visiblefalse/asp:Label/span span总分
338 asp:Label IDlbScore runatserver TextLabel/asp:Label
339 /span
340
341 【字体a hrefjavascript:fontZoomB(); target_self↑大/a a hrefjavascript:fontZoomA(); target_self↓小/a】
342 /td
343 /tr
344 /table
345 /div
346 div classpagerref
347 table cellpadding0 cellspacing0 width400px aligncenter
348 tr
349 td alignright valigntop
350 剩余时间
351 /td
352 td alignleft valigntop stylecolor: Red;
353 asp:Label IDlbRemainTime runatserver Visiblefalse/asp:Label
354 asp:Label IDtimeshow runatserver/asp:Label
355 /td
356 /tr
357 /table
358 input typehidden idanswerQuestionNum nameanswerQuestionNum /
359 /div
360 div classcoda-slider-wrapper
361 div classcoda-slider preload idcoda-slider-1
362 !-- end panel --
363 table cellpadding0px cellspacing0px width100% classtext idfontzoom
364 tr
365 td alignleft valigntop
366 br /
367 table cellpadding0px cellspacing0px width100%
368 tr
369 td alignleft valigntop
370 asp:GridView IDGridView1 runatserver AutoGenerateColumnsFalse Width90%
371 BorderStyleNone GridLinesNone OnRowDataBoundGridView1_RowDataBound
372 Columns
373 asp:TemplateField HeaderText基础型选择题
374 HeaderStyle HorizontalAlignCenter /
375 HeaderTemplate
376 table cellpadding0px cellspacing0px width100%
377 tr
378 td width10%
379 /td
380 td width90% alignleft stylefont-size: 14px; font-weight: bold; color: Black;
381 基础型选择题
382 /td
383 /tr
384 /table
385 /HeaderTemplate
386 ItemTemplate
387 br /
388 table cellpadding0px cellspacing0px width100%
389 tr
390 td alignright valigntop width50px
391 span stylefont-size: 14px; font-weight: bold; color: Black;
392 %# Container.DataItemIndex1%. nbsp;nbsp; /span
393 /td
394 td alignleft valigntop width650px
395 %# Eval(ProblemName)%
396 /td
397 td alignright valigntop width150px
398 【分值%# Eval(ProblemScore)%分】
399 %--
400 %# lbSingleScore.Text 【分值Eval(ProblemScore)分】 %
401 --%
402 /td
403 /tr
404 tr
405 td
406 /td
407 td alignleft valigntop colspan2
408 div
409 asp:Label IDlbID runatserver Text%# Eval(ExamDetailID)% Visiblefalse/asp:Label
410 asp:Label IDlbStudentAnswer runatserver Text%# Eval(StudentAnswer)%
411 Visiblefalse/asp:Label
412 asp:RadioButtonList IDradioSingleBasic runatserver Width300px RepeatDirectionHorizontal
413 asp:ListItem ValueA TextA onclickputinanwer(A, this.value)/asp:ListItem
414 asp:ListItem ValueB TextB onclickputinanwer(B, this.value)/asp:ListItem
415 asp:ListItem ValueC TextC onclickputinanwer(C, this.value)/asp:ListItem
416 asp:ListItem ValueD TextD onclickputinanwer(D, this.value)/asp:ListItem
417 /asp:RadioButtonList
418 /div
419 div runatserver iddiv1 visiblefalse styleborder-bottom: 1px dashed red;
420 border-left: 1px dashed red; border-right: 1px dashed red; border-top: 1px dashed red;
421 table cellpadding0px cellspacing0px width100%
422 tr
423 td alignright valigntop width10%
424 span stylecolor: Red;正确答案/span
425 /td
426 td alignleft valigntop width90%
427 %# Eval(ProblemAnswer)%
428 /td
429 /tr
430 tr
431 td alignright valigntop width10%
432 span stylecolor: Red;试卷性质/span
433 /td
434 td alignleft valigntop width90%
435 %# Eval(FlagDes)%.nbsp;nbsp; .nbsp;nbsp; span stylecolor: Red;所属章节/span%# Eval(CourseName)%.nbsp;nbsp;
436 .nbsp;nbsp; span stylecolor: Red;试题难度/span%# Eval(GradeName)%.nbsp;nbsp;
437 .nbsp;nbsp;
438 /td
439 /tr
440 tr
441 td alignright valigntop width10%
442 span stylecolor: Red;【解析】/span
443 /td
444 td alignleft valigntop width90%
445 %# Eval(ProblemDes)%
446 /td
447 /tr
448 /table
449 /div
450 /td
451 /tr
452 /table
453 /ItemTemplate
454 /asp:TemplateField
455 /Columns
456 /asp:GridView
457 /td
458 /tr
459 /table
460 /td
461 /tr
462 tr
463 td alignleft valigntop
464 br /
465 asp:GridView IDGridView2 runatserver AutoGenerateColumnsFalse Width90%
466 BorderStyleNone GridLinesNone OnRowDataBoundGridView2_RowDataBound
467 Columns
468 asp:TemplateField HeaderText综合型选择题
469 HeaderStyle HorizontalAlignCenter /
470 HeaderTemplate
471 table cellpadding0px cellspacing0px width100%
472 tr
473 td width10%
474 /td
475 td width90% alignleft stylefont-size: 14px; font-weight: bold; color: Black;
476 综合型选择题
477 /td
478 /tr
479 /table
480 /HeaderTemplate
481 ItemTemplate
482 br /
483 table cellpadding0px cellspacing0px width100%
484 tr
485 td alignright valigntop width50px
486 span stylefont-size: 14px; font-weight: bold; color: Black;
487 %# Container.DataItemIndex1%. nbsp;nbsp; /span
488 /td
489 td alignleft valigntop width700px
490 %# Eval(ProblemName)%
491 /td
492 td alignleft valigntop width100px
493 【分值%# Eval(ProblemScore)%分】
494 %--
495 %# lbSingleScore.Text 【分值Eval(ProblemScore)分】 %
496 --%
497 /td
498 /tr
499 tr
500 td
501 /td
502 td alignleft valigntop colspan2
503 div
504 asp:Label IDlbID runatserver Text%# Eval(ExamDetailID)% Visiblefalse/asp:Label
505 asp:Label IDlbStudentAnswer runatserver Text%# Eval(StudentAnswer)%
506 Visiblefalse/asp:Label
507 asp:RadioButtonList IDradioSingle runatserver Width300px RepeatDirectionHorizontal
508 asp:ListItem ValueA TextA onclickputinanwer(A, this.value)/asp:ListItem
509 asp:ListItem ValueB TextB onclickputinanwer(B, this.value)/asp:ListItem
510 asp:ListItem ValueC TextC onclickputinanwer(C, this.value)/asp:ListItem
511 asp:ListItem ValueD TextD onclickputinanwer(D, this.value)/asp:ListItem
512 /asp:RadioButtonList
513 /div
514 div runatserver iddiv1 visiblefalse styleborder-bottom: 1px dashed red;
515 border-left: 1px dashed red; border-right: 1px dashed red; border-top: 1px dashed red;
516 table cellpadding0px cellspacing0px width100%
517 tr
518 td alignright valigntop width10%
519 span stylecolor: Red;正确答案/span
520 /td
521 td alignleft valigntop width90%
522 %# Eval(ProblemAnswer)%
523 /td
524 /tr
525 tr
526 td alignright valigntop width10%
527 span stylecolor: Red;试卷性质/span
528 /td
529 td alignleft valigntop width90%
530 %# Eval(FlagDes)%.nbsp;nbsp; .nbsp;nbsp; span stylecolor: Red;所属章节/span%# Eval(CourseName)%.nbsp;nbsp;
531 .nbsp;nbsp; span stylecolor: Red;试题难度/span%# Eval(GradeName)%.nbsp;nbsp;
532 .nbsp;nbsp;
533 /td
534 /tr
535 tr
536 td alignright valigntop width10%
537 span stylecolor: Red;【解析】/span
538 /td
539 td alignleft valigntop width90%
540 %# Eval(ProblemDes)%
541 /td
542 /tr
543 /table
544 /div
545 /td
546 /tr
547 /table
548 /ItemTemplate
549 /asp:TemplateField
550 /Columns
551 /asp:GridView
552 /td
553 /tr
554 tr
555 td alignleft valigntop
556 br /
557 asp:GridView IDGridView3 runatserver AutoGenerateColumnsFalse Width90%
558 BorderStyleNone GridLinesNone OnRowDataBoundGridView3_RowDataBound
559 Columns
560 asp:TemplateField HeaderText填空题
561 HeaderStyle HorizontalAlignCenter VerticalAlignBottom /
562 HeaderTemplate
563 table cellpadding0px cellspacing0px width100%
564 tr
565 td width10%
566 /td
567 td width90% alignleft stylefont-size: 14px; font-weight: bold; color: Black;
568 填空题
569 /td
570 /tr
571 /table
572 /HeaderTemplate
573 ItemTemplate
574 br /
575 table cellpadding0px cellspacing0px width100%
576 tr
577 td alignright valigntop width50px
578 span stylefont-size: 14px; font-weight: bold; color: Black;
579 %# Container.DataItemIndex1%
580 .nbsp;nbsp; /span
581 /td
582 td alignleft valigntop width700px
583 %# Eval(ProblemName)%
584 /td
585 td alignleft valigntop width100px
586 【分值%# Eval(ProblemScore)%分】
587 /td
588 /tr
589 tr
590 td
591 /td
592 td alignleft valigntop colspan2
593 div
594 input typetext idtxtFills onchangeputinanwer(this.value,%# Eval(ExamDetailID)%)
595 stylewidth: 300px; classwlArea880 value%# Eval(StudentAnswer)% /
596 br /
597 asp:TextBox IDtxtFill runatserver Width300px CssClasswlArea880 Visiblefalse
598 ToolTip%# Eval(ExamDetailID)%/asp:TextBox
599 asp:Label IDlbID runatserver Text%# Eval(ExamDetailID)% Visiblefalse/asp:Label
600 asp:Label IDlbStudentAnswer runatserver Text%# Eval(StudentAnswer)%
601 Visiblefalse/asp:Label
602 /div
603 div runatserver iddiv4 visiblefalse styleborder-bottom: 1px dashed red;
604 border-left: 1px dashed red; border-right: 1px dashed red; border-top: 1px dashed red;
605 table cellpadding0px cellspacing0px width100%
606 tr
607 td alignright valigntop width10%
608 span stylecolor: Red;正确答案/span
609 /td
610 td alignleft valigntop width90%
611 %# Eval(ProblemAnswer)%
612 /td
613 /tr
614 tr
615 td alignright valigntop width10%
616 span stylecolor: Red;试卷性质/span
617 /td
618 td alignleft valigntop width90%
619 %# Eval(FlagDes)%.nbsp;nbsp; .nbsp;nbsp; span stylecolor: Red;所属章节/span%# Eval(CourseName)%.nbsp;nbsp;
620 .nbsp;nbsp; span stylecolor: Red;试题难度/span%# Eval(GradeName)%.nbsp;nbsp;
621 .nbsp;nbsp;
622 /td
623 /tr
624 tr
625 td alignright valigntop width10%
626 span stylecolor: Red;【解析】/span
627 /td
628 td alignleft valigntop width90%
629 %# Eval(ProblemDes)%
630 /td
631 /tr
632 /table
633 /div
634 /td
635 /tr
636 /table
637 /ItemTemplate
638 /asp:TemplateField
639 /Columns
640 /asp:GridView
641 /td
642 /tr
643 tr
644 td alignleft valigntop
645 /td
646 /tr
647 /table
648 asp:Label IDlbPaperID runatserver TextLabel Visiblefalse/asp:Label
649 asp:Label IDlbStudentID runatserver TextLabel Visiblefalse/asp:Label
650 asp:Label IDlbNum runatserver TextLabel Visiblefalse/asp:Label
651 asp:Label IDlbExamID runatserver TextLabel Visiblefalse/asp:Label
652 asp:Label IDlbStudentName runatserver TextLabel Visiblefalse/asp:Label
653 %-- asp:Label IDlbSingleScore runatserver /asp:Label--%
654 div classpagescoll
655 asp:Button IDbtOk runatserver OnClickbtOk_Click Text全部完成,交卷 CssClassbtnOrgBig
656 UseSubmitBehaviorFalse /
657 /div
658 !-- end panel --
659 /div
660 /div
661 /form
662 !--paperCont_end--
663 /div
664 /div
665 div idsmallLay classhidden
666 div classlaybottom
667 /div
668 /div
669 !--收藏浮层结束--
670 /body
671 /html 当年纯洁的代码 我还记得当年我很神奇的组织了许多学生在实验室帮我测试生怕考试过程中出现问题甚至在期末考试前一周仍然这是问题那是问题最后终于承受住了各种压力写下了我大学光辉的一页甚至现在想起来我还是很自豪的呢。 PS本来想运行起来截图说明问题的无奈确实找不到数据库了而且这个给改来改去也不知道改成什么样了所以只有作罢 虽然无图但是我这里还是可以说说原来系统存在的一些问题 ① 使用了很多.net服务器空间光是页面就有36K还没有算生成后的大小呢。。。 ② 请看当时数据库中存的数据 我也是绝技没有想到我当时会这样存储题目的用的fck直接由word上将题目考进来的 ③ 我们来看看我们一共有多少题呢 PS乖乖这家伙居然还有这么多题呢。。。 结果 不知道从什么时间开始不知道是什么原因系统变得很卡然后呢然后我就大四了也就没有管这个系统了而且还靠着这个系统忽悠了几个offer呢 去年今日此门中 现在回过头来看整个系统的优化似乎心里都有谱了除却数据库的东西我们来看看前端的优化吧首先我从数据库中选择100到单选题出来 PS当然还是使用gridview啦哇哈哈 哎当年的题导入的怎一个丑字了得现在让我们来处理一番 第一步去掉多余的东西只留下题目即可但是 真正到看到题目我突然明白了当年为什么会这么做因为他是有格式的。。。 引出问题万能的json 其实之前扯这么多东西都没什么意义的原因就是在工作中遇到的我这里没胆子写出来所以就东扯西扯的搞了这么久其实就是为了数据源 真实的场景是这样的 我有100道题已经存于数据库中而且每个用户读取不会改变后端同事问我如何请求 我想了下首先得到了这一个结论 后端同事将100道题目形成json格式的数据我直接将json格式保存在js中页面加载时候就引用了 我当时的思考点就是反正题目是不变的所以我就将它静态化得了完了又遇到了一个问题 因为页面上一次只显示10道题点击下一页再显示下一道题于是问题出来了
1 我将所有题目一次生成点击下一页控制隐藏显示即可
2 我只生成10道题点击下一页再生成10道题 我当时在这两种方案徘徊了好久地球人都知道方案一简单一点而且迫于项目时间我当时就直接运用了第一种方案 对于这个各位大哥可以说下自己的想法请一定说出来哟 无心插柳去你的json 我当时做着做着突然发现另外一件事情 1 我会将数据库中的数据变为json格式时因为我想减少服务器以及数据库的压力 2 因为数据是不变的所以我可以这样做 于是我傻傻的意识到一件事情 1 我将不变的json数据生成了不变的题目而且每次我都会使用js生成相同的HTML 于是我感觉我真是弱爆了 我为什么不直接将json生成的html保存为页面片呢 考试系统与页面片 当年我为了防止学生作弊会随机生成100套试卷而学生进入时随机选择一套来做所以作弊的情况可以杜绝那么我们进入今天的思考阶段 在人数比较多的情况下生成试卷会不停的访问服务器不停的读取数据库在刚刚开始考试的时间点对我们来说是个噩梦但是经过最近发生的事情我觉得我们是不是可以这样做1 每个人都会做100道题
2 每个人做的题来源于数据库
3 所以我们要读取数据库
。。。。但是我们是不是可以这样做呢提前生成试卷并且学生考试时候根本不访问数据库直接由服务器拖页面我们生成试卷时候设置一个随机数生成100套不同的页面片
学生进入考试时候根据随机是直接引入htm页面片生成试卷 如此一来我们考试时候的性能是否会有所优化呢原来能承受400人同时考试的系统可否变为800人呢我不知道也许我永远都不会知道了 光说不练假把式 说了那么多也没有意思我们今天就来干一下吧实现我们儿时的梦想 PS 100道题太多我们搞10道就是了吧。。。。 然后我们将这100道题保存为变化p_1-p_10的页面片用户进来时候随机引入即可我这里就暂时不写了。。。。。 结语 在写之前我还以为能写一篇好文章呢写着写着就找不着北了哎就这样吧。。。。 转载于:https://www.cnblogs.com/yexiaochai/archive/2013/05/24/3097744.html