如何做在线测试的填空题(不用数据库)并且能自动判断对错,并给出成绩.(如果有合适的答案马上结贴)

rjjjhsjy 2005-10-08 02:29:21
如何做在线测试的填空题(不用数据库)并且能自动判断对错,并给出成绩.(如果有合适的答案马上结贴)
给一下源代码最好,如没有提示也好
...全文
428 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
precipitant 2005-10-08
  • 打赏
  • 举报
回复
看看行不行,如果不行,自己改改吧。

<html>
<head>
<title>在线答题--塞北的雪</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
var tlist="t1_1,t1_2,t2_1"
var tk=new Array() //题库
//第一道题
tk["t1_1"]=new Array();
tk["t1_1"]["code"]="1"
tk["t1_1"]["result"]="北京"
tk["t1_1"]["score"]=5

tk["t1_2"]=new Array();
tk["t1_2"]["code"]="2"
tk["t1_2"]["result"]="东京"
tk["t1_2"]["score"]=8

//第二道题
tk["t2_1"]=new Array();
tk["t2_1"]["code"]="3"
tk["t2_1"]["result"]="周笔畅"
tk["t2_1"]["score"]=7

var points=0;
//判卷
function fncSubmit(){
points=0;
var arrT=tlist.split(',');
for(var i=0;i<arrT.length;i++)
{
var tInput=eval("document.form1." + arrT[i]);
if(!tInput) continue;
var tInputValue=tInput.value;
if(tInputValue==tk[arrT[i]]["result"])
points+=tk[arrT[i]]["score"]
}
document.getElementById("oScore").innerText="得分:" + points.toString();
}

//显示正确答案
function showResult(){
var arrT=tlist.split(',');
var resultList=new String();
resultList="";
for(var i=0;i<arrT.length;i++)
{
var tInput=eval("document.form1." + arrT[i]);
if(!tInput) continue;
var tInputValue=tInput.value;
resultList = resultList + tk[arrT[i]]["code"].toString() + ":" + tk[arrT[i]]["result"] + "(" + tk[arrT[i]]["score"] + "分)" + "   ";
}
document.getElementById("oResult").innerHTML="标准答案:" + resultList.toString();
}
//-->
</SCRIPT>
<style>
.line_r { font-size: 12px; color: #000000; background:; border: none; border-bottom:solid 1px #000000; text-align:left;}
</style>
</head>

<body>
<form name="form1" id="form1">
在线答题:
<br><br>
1、中国的首都是<input class="line_r" type="text" name="t1_1" value="">,日本的首都是<input class="line_r" type="text" name="t1_2" value=""><br>
2、2005孟牛酸酸乳超级女生的亚军是<input class="line_r" type="text" name="t2_1" value="" ><br><br>
<input type="button" name="btn1" value="提交" onclick="fncSubmit()">
<input type="button" name="btn2" value="正确答案" onclick="showResult();">
<br>
<span id="oScore"></span>
<br>
<span id="oResult"></span>
</form>
</body>
</html>

rjjjhsjy 2005-10-08
  • 打赏
  • 举报
回复
只要求填空的用JavaScript写的代码,各位高手来几个撒
GX198302 2005-10-08
  • 打赏
  • 举报
回复
原来是要代码啊?

Flash可以啊
rjjjhsjy 2005-10-08
  • 打赏
  • 举报
回复
很好了,不过还有更好的象这样的源代码吗?
安迪 2005-10-08
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Doc</title>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<SCRIPT LANGUAGE="JavaScript">
<!--
var points=0;
function fncSubmit(){
if (document.form1.text1.value=="1"){
points=points+2;
}
if (document.form1.text2.value=="2"){
points=points+3;
}
alert(points);
window.location.reload();
}
//-->
</SCRIPT>
</head>

<body>
<form name="form1" id="form1">
共5分:
<br>
<input type="text" name="text1" value="">2分
<input type="text" name="text2" value="" >3分
<input type="button" name="btn1" value="提交" onclick="fncSubmit()">
<input type="button" name="btn2" value="正确答案" onclick="alert('1,2')">

</form>
</body>
</html>
//是这个样子吗?
rjjjhsjy 2005-10-08
  • 打赏
  • 举报
回复
能说的详细具体吗?
precipitant 2005-10-08
  • 打赏
  • 举报
回复
只要将题号与其答案对应好,很容易的。但是最好用数据库存储题。

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧