最近应朋友的需求,自己也正在找工作,想更提高、牢固自己做web系统的能力,所以做模仿驾校考试系统,花了几天时间。数据库表只有几个。
从09年毕业工作就一直用Java平台。asp.net是在学校学的。所以还是用2.0 的。Javascript封装设计的不够好,需要提高一下。
下载地址:http://code.google.com/p/leyipai/downloads/list
用asp.net 2.0做系统自己感觉优点:开发速度快。
部署成本低,小公司比较容易接受。
缺点:就不说了。
前台考试的JS如下:
//考试倒计时var SysSecond;var InterValObj;function SysExamCountdown() {if (SysSecond > -1) {SysSecond = SysSecond - 1;var second = Math.floor(SysSecond % 60); // 计算秒 var minite = Math.floor((SysSecond / 60) % 60); //计算分var hour = Math.floor((SysSecond / 3600) % 24); //计算小时$("#sysEaxmTimeTag").html( hour + ":" + minite + ":" + second + "");} else {//剩余时间小于或等于0的时候,就停止间隔函数window.clearInterval(InterValObj);$.blockUI({message:"考试时间到了"});//阴影}}//考试参数
var singleSelet=true;//是多选的
var totalTopicNum=<%=totalTopicNums %>;//题目总数100//考题
var eaxmtopics=<%=topics %>;var userKeysArray=new Array(totalTopicNum);
//选中答案
function gotoKeys(text){if (SysSecond < 0) return;var topicId=$("#currentTopic").val();//索引标题栏变色var objgt="#EOV"+topicId;$(objgt).removeClass();$(objgt).addClass("ExamOrderViewVisited");var topicKeys=$("#currentTopicKeys").html();if(singleSelet){//单选考试topicKeys=text;$("#currentTopicKeys").html(text);//保存用户答案userKeysArray[parseInt(topicId)]=topicKeys;//提交给服务器if("对"==topicKeys)topicKeys="Y";if("错"==topicKeys)topicKeys="N";var stuId=$("#HiddenStudentID").val();var subId=$("#HiddenSubjectID").val();var tid=eaxmtopics[parseInt(topicId)].TopicID;$.ajax({type: "get",dataType: "json",url: 'submitMyKeys.ashx',data: "TopicID="+tid+"&Keys="+topicKeys+"&StudentID="+stuId+"&SubjectID="+subId,success: function(data) {}});//进入下一题gontoNext();}else{//不是单选题if(''==topicKeys){topicKeys=text;}else if(topicKeys.indexOf(text)>=0){topicKeys=topicKeys.replace(text,'');}else{topicKeys=topicKeys+text;}topicKeys=sortKeys(topicKeys);$("#currentTopicKeys").html(topicKeys);}}/*
* 排序
*/
var sortKeys =function (str){if(typeof(str) != "string")return "";var sarray=new Array(str.length);for(var i=0;i<str.length;i++){sarray[i]=str.charAt(i);}sarray.sort();var result=sarray.toString();return result.replace(/,/g,'');
};//点击数字直达题干
var gotoTopic=function (index){$("#currentTopic").val(index);//保存当前ID//遍历一下checkDoneAndSetCss();//标题栏变色var objgt="#EOV"+index;$(objgt).removeClass();$(objgt).addClass("ExamOrderViewHover");//清空答案 currentTopicKeysvar obj=eaxmtopics[parseInt(index)-1];$("#topicTexts").html(obj.Texts);setKeysListStr(obj);setKeysItem(obj);
}//进入下一题
var gontoNext=function(){checkDoneAndSetCss();var ctopic=$("#currentTopic").val();var nexttopic=parseInt(ctopic)+1;if(nexttopic >totalTopicNum) nexttopic=totalTopicNum;gotoTopic(nexttopic);
}
//进入上一题
var gotoPrevious=function(){checkDoneAndSetCss();var ctopic=$("#currentTopic").val();var Prevtopic=parseInt(ctopic)-1;if(Prevtopic<1)Prevtopic=1;gotoTopic(Prevtopic);
}//循环检查完成情况,而且给索引数字换样式
var checkDoneAndSetCss=function(){for(var i=0;i<userKeysArray.length;i++){if(null==userKeysArray[i+1] || typeof(userKeysArray[i+1]) == "undefined" || ''== userKeysArray[i+1]){var objge="#EOV"+(i+1);$(objge).removeClass();$(objge).addClass("ExamOrderViewWait");}else if(''!=userKeysArray[i+1]){var objge="#EOV"+(i+1);$(objge).removeClass();$(objge).addClass("ExamOrderViewVisited");}}}//
//输出答案列表----就是题干下面的答案列表\
//
var setKeysItem=function(node){var restr="";if(0==node.Type){if(null!=node.A && ''!=node.A ){restr=restr+"<div class=\"keyitems\" id=\"Item_A\" onClick=\"gotoKeys('A')\">A</div>";}if(null!=node.B && ''!=node.B ){restr=restr+"<div class=\"keyitems\" id=\"Item_B\" onClick=\"gotoKeys('B')\">B</div>";}if(null!=node.C && ''!=node.C ){restr=restr+"<div class=\"keyitems\" id=\"Item_C\" onClick=\"gotoKeys('C')\">C</div>";}if(null!=node.D && ''!=node.D){restr=restr+"<div class=\"keyitems\" id=\"Item_D\" onClick=\"gotoKeys('D')\">D</div>";}if(null!=node.E && ''!=node.E ){restr=restr+"<div class=\"keyitems\" id=\"Item_E\" onClick=\"gotoKeys('E')\">E</div>";}if(null!=node.F && ''!=node.F ){restr=restr+"<div class=\"keyitems\" id=\"Item_F\" onClick=\"gotoKeys('F')\">F</div>";}if(null!=node.G && ''!=node.G ){restr=restr+"<div class=\"keyitems\" id=\"Item_G\" onClick=\"gotoKeys('G')\">G</div>";}if(null!=node.H && ''!=node.H ){restr=restr+"<div class=\"keyitems\" id=\"Item_H\" onClick=\"gotoKeys('H')\">H</div>";}if(null!=node.I && ''!=node.I ){restr=restr+"<div class=\"keyitems\" id=\"Item_I\" onClick=\"gotoKeys('I')\">I</div>";}if(null!=node.J && ''!=node.J){restr=restr+"<div class=\"keyitems\" id=\"Item_J\" onClick=\"gotoKeys('J')\">J</div>";}if(null!=node.K && ''!=node.K ){restr=restr+"<div class=\"keyitems\" id=\"Item_K\" onClick=\"gotoKeys('K')\">K</div>";}}else{restr=restr+"<div class=\"keyitems\" id=\"Item_Y\" onClick=\"gotoKeys('对')\">对</div>";restr=restr+"<div class=\"keyitems\" id=\"Item_N\" onClick=\"gotoKeys('错')\">错</div>";}$("#selectItem").html(restr);}//得到选择题的选项var setKeysListStr=function(node){var restr="";if(node.Type==1){// 判断 return null}else if(node.Type==0){if(null!=node.A && ''!=node.A ){restr=restr+"<p><font color=\"#993300\">A </font>"+node.A+"</p>";}if(null!=node.B && ''!=node.B ){restr=restr+"<p><font color=\"#993300\">B </font>"+node.B+"</p>";}if(null!=node.C && ''!=node.C ){restr=restr+"<p><font color=\"#993300\">C </font>"+node.C+"</p>";}if(null!=node.D && ''!=node.D){restr=restr+"<p><font color=\"#993300\">D </font>"+node.D+"</p>";}if(null!=node.E && ''!=node.E ){restr=restr+"<p><font color=\"#993300\">E </font>"+node.E+"</p>";}if(null!=node.F && ''!=node.F ){restr=restr+"<p><font color=\"#993300\">F </font>"+node.F+"</p>";}if(null!=node.G && ''!=node.G ){restr=restr+"<p><font color=\"#993300\">G </font>"+node.G+"</p>";}if(null!=node.H && ''!=node.H ){restr=restr+"<p><font color=\"#993300\">H </font>"+node.H+"</p>";}if(null!=node.I && ''!=node.I ){restr=restr+"<p><font color=\"#993300\">I </font>"+node.I+"</p>";}if(null!=node.J && ''!=node.J){restr=restr+"<p><font color=\"#993300\">J </font>"+node.J+"</p>";}if(null!=node.K && ''!=node.K){restr=restr+"<p><font color=\"#993300\">K</font>"+node.K+"</p>";}}$("#topicKeys").html(restr);}$(document).ready(function() {SysSecond =<%=examTime %> //这里我是在服务端算好了剩余的秒数,并保存到客户端,如果过期则返回0InterValObj = window.setInterval(SysExamCountdown, 1000); //间隔函数,1秒执行//鼠标滑过样式var objStr = ".keyitems";$(objStr).each(function(i){$(this).mouseover(function(){$(this).removeClass("keyitems");$(this).addClass("keyitems_over");});$(this).hover(function(){},function(){$(this).removeClass("keyitems_over");$(this).addClass("keyitems");}); //gotoTopic('1');//});gotoTopic('1');//alert('D'>'A');});
运行图片: