📄 test.aspx
字号:
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
'Relative file path to XML data
Dim strXmlFilePath as String = Server.MapPath("quiz.xml")
Dim xDoc as XmlDocument = New XmlDocument()
Dim intTotalQuestion as Integer
Dim intQuestionNo as Integer = 1
Dim intScore as Integer = 0
Dim arrAnswerHistory as new ArrayList()
Sub Page_Load(src as Object, e as EventArgs)
'Load xml data
xDoc.Load(strXmlFilePath)
'Start a new quiz?
If Not Page.IsPostBack Then
'Yes! Count total question
intTotalQuestion = xDoc.SelectNodes("/quiz/mchoice").Count
'Record start time
ViewState("StartTime") = DateTime.Now
ShowQuestion(intQuestionNo)
End If
End Sub
Sub btnSubmit_Click(src as Object, e as EventArgs)
'Retrieve essential variables from state bag
intTotalQuestion = ViewState("TotalQuestion")
intQuestionNo = ViewState("QuestionNo")
intScore = ViewState("Score")
arrAnswerHistory = ViewState("AnswerHistory")
'Correct answer?
If rblAnswer.SelectedItem.Value = ViewState("CorrectAnswer") Then
intScore += 1
arrAnswerHistory.Add(0)
Else
arrAnswerHistory.Add(rblAnswer.SelectedItem.Value)
End If
'End of quiz?
If intQuestionNo=intTotalQuestion Then
'Yes! Show the result...
QuizScreen.Visible = False
ResultScreen.Visible = True
'Render result screen
ShowResult()
Else
'Not yet! Show another question...
QuizScreen.Visible = True
ResultScreen.Visible = False
intQuestionNo += 1
'Render next question
ShowQuestion(intQuestionNo)
End If
End Sub
Sub ShowQuestion(intQuestionNo as Integer)
Dim xNodeList as XmlNodeList
Dim xNodeAttr as Object
Dim strXPath as String
Dim i as Integer
Dim tsTimeSpent as TimeSpan
strXPath = "/quiz/mchoice[" & intQuestionNo.ToString() & "]"
'Extract question
lblQuestion.Text = intQuestionNo.ToString() & ". " & xDoc.SelectSingleNode(strXPath & "/question").InnerXml
'Extract answers
xNodeList = xDoc.SelectNodes(strXPath & "/answer")
'Clear previous listitems
rblAnswer.Items.Clear
For i = 0 to xNodeList.Count-1
'Add item to radiobuttonlist
rblAnswer.Items.Add(new ListItem(xNodeList.Item(i).InnerText, i+1))
'Extract correct answer
xNodeAttr = xNodeList.Item(i).Attributes.ItemOf("correct")
If not xNodeAttr is Nothing Then
If xNodeAttr.Value = "yes" Then
ViewState("CorrectAnswer") = i+1
End If
End If
Next
'Output Total Question
lblTotalQuestion.Text = intTotalQuestion
'Output Time Spent
tsTimeSpent = DateTime.Now.Subtract(ViewState("StartTime"))
lblTimeSpent.Text = tsTimeSpent.Minutes.ToString() & ":" & tsTimeSpent.Seconds.ToString()
'Store essential data to viewstate
ViewState("TotalQuestion") = intTotalQuestion
ViewState("Score") = intScore
ViewState("QuestionNo") = intQuestionNo
ViewState("AnswerHistory") = arrAnswerHistory
End Sub
Sub ShowResult()
Dim strResult as String
Dim intCompetency as Integer
Dim i as Integer
Dim strXPath as String
Dim tsTimeSpent as TimeSpan
tsTimeSpent = DateTime.Now.Subtract(ViewState("StartTime"))
strResult = "<center>"
strResult += "<h3>结果</h3>"
strResult += "<br>分数: " & intScore.ToString() & " / " & intTotalQuestion.ToString()
strResult += "<br>成功率: " & Int(intScore/intTotalQuestion*100).ToString() & "%"
strResult += "<br>用时: " & tsTimeSpent.Minutes.ToString() & ":" & tsTimeSpent.Seconds.ToString()
strResult += "</center>"
strResult += "<h3>结果:</h3>"
For i = 1 to intTotalQuestion
strXPath = "/quiz/mchoice[" & i.ToString() & "]"
strResult += "<b>" & i.ToString() & ". " & xDoc.SelectNodes(strXPath & "/question").Item(0).InnerXml & "</b><br>"
If arrAnswerHistory.Item(i-1)=0 Then
strResult += "<font color=""write""><b>正确!</b></font><br><br>"
Else
strResult += "<b>您的答案:</b> " & xDoc.SelectNodes(strXPath & "/answer[" & arrAnswerHistory.Item(i-1).ToString() & "]").Item(0).InnerXml & "<br>"
strResult += "<font color=""red""><b>错误</b></font><br><br>"
End If
Next
lblResult.Text = strResult
End Sub
</script>
<html>
<head>
<title>测试系统</title>
<style type="text/css">
<!--
.样式3 {font-size: 12pt}
-->
</style>
</head>
<style>
body {
font-size: 10pt;
FONT-FAMILY: Arial;
color:#000000;
background-color:#eeeedd;
}
tr.heading {
background-color:#0033CC;
}
.button {
border: 1px solid #000000;
background-color: #ffffff;
}
.样式1 {
font-family: "华文行楷";
font-weight: bold;
font-size: 20pt;
color: #FFFF00;
}
.样式2 {
font-size: 14pt;
font-weight: bold;
}
</style>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="css/index05.css" type=text/css rel=stylesheet>
<BODY background="css/bg.gif">
<span id="QuizScreen" runat="server">
<form runat="server">
<table width="100%" border="0" cellpadding="2" cellspacing="0"><!--DWLayoutTable-->
<tr class="heading">
<td width="100%"><span class="样式1">测试系统(英语六级试卷)</span></td>
<td width="60%" align="right"><p class="样式2 样式3"><font color="white">制作 </font><font color="white">lyx</font></p> </td>
</tr>
<tr>
<td colspan="2" bgColor=#ffffff>
<b><asp:label id="lblQuestion" runat="server" /></b><br>
<asp:radiobuttonlist
id="rblAnswer"
RepeatDirection="vertical"
TextAlign="right"
RepeatLayout="table"
runat="server" /><br>
<asp:requiredfieldvalidator
ControlToValidate="rblAnswer"
ErrorMessage="请选择答案!"
runat="server" /><br>
<asp:button id="btnSubmit" class="button" text=" 下一个问题 " onClick="btnSubmit_Click" runat="server" />
</td>
</tr>
<tr class="heading">
<td><font color="white"><b>总计 <asp:label id="lblTotalQuestion" runat="server" /> 问题</b></font></td>
<td width="50%" align="right"><font color="white"><b>用时 <asp:label id="lblTimeSpent" runat="server" /></b></font></td>
</tr>
</table>
</form>
</span>
<span id="ResultScreen" runat="server">
<asp:label id="lblResult" runat="server" />
</span>
<TABLE width="100%">
<TR>
<TD bgColor=#ffffff>
<hr size='1' noshade>
<a href="http://www.shfu.edu.cn" target="_blank">001</a> |
<a href="http://www.shfu.edu.cn" target="_blank">002</a> |
<a href="http://www.shfu.edu.cn" target="_blank">003</a> |
<SCRIPT language=javascript>
<!-- Begin
document.write('<div id="c0" style="position:absolute;right:6;top:6; z-index:2;"></div>');
document.write(' <div id="c1" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>1</b></div>');
document.write(' <div id="c2" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>2</b></div>');
document.write(' <div id="c3" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>3</b></div>');
document.write(' <div id="c4" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>4</b></div>');
document.write(' <div id="c5" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>5</b></div>');
document.write(' <div id="c6" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>6</b></div>');
document.write(' <div id="c7" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>7</b></div>');
document.write(' <div id="c8" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>8</b></div>');
document.write(' <div id="c9" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>9</b></div>');
document.write(' <div id="c10" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>10</b></div>');
document.write(' <div id="c11" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>11</b></div>');
document.write(' <div id="c12" style="position:absolute;left:20;top:-20; z-index:5;font-size:11px;"><b>12</b></div>');
document.write(' <div id="ob0" style="position:absolute;left:-20;top:-20;z-index:1"> </div>');
document.write(' <div id="ob1" style="position:absolute;left:-20;top:-20;z-index:8"> <font size="+3" color="#0000FF"><b>.</b></font></div>');
document.write(' <div id="ob2" style="position:absolute;left:-20;top:-20;z-index:8"> <font size="+3" color="#0000FF"><b>.</b></font></div>');
document.write(' <div id="ob3" style="position:absolute;left:-20;top:-20;z-index:8"> <font size="+3" color="#0000FF"><b>.</b></font></div>');
document.write(' <div id="ob4" style="position:absolute;left:-20;top:-20;z-index:8"> <font size="+3" color="#0000FF"><b>.</b></font></div>');
document.write(' <div id="ob5" style="position:absolute;left:-20;top:-20;z-index:8"> <font size="+3" color="#0000FF"><b>.</b></font></div>');
document.write(' <div id="ob6" style="position:absolute;left:-20;top:-20;z-index:7"> <font size="+3" color="#00FFFF"><b>.</b></font></div>');
document.write(' <div id="ob7" style="position:absolute;left:-20;top:-20;z-index:7"> <font size="+3" color="#00FFFF"><b>.</b></font></div>');
document.write(' <div id="ob8" style="position:absolute;left:-20;top:-20;z-index:7"> <font size="+3" color="#00FFFF"><b>.</b></font></div>');
document.write(' <div id="ob9" style="position:absolute;left:-20;top:-20;z-index:7"> <font size="+3" color="#00FFFF"><b>.</b></font></div>');
document.write(' <div id="ob10" style="position:absolute;left:-20;top:-20;z-index:6"> <font size="+3" color="#F30000"><b>.</b></font></div>');
document.write(' <div id="ob11" style="position:absolute;left:-20;top:-20;z-index:6"> <font size="+3" color="#F30000"><b>.</b></font></div>');
document.write(' <div id="ob12" style="position:absolute;left:-20;top:-20;z-index:6"> <font size="+3" color="#F30000"><b>.</b></font></div>');
pX=660;pY=150
obs = new Array(13)
function ob () {
for (i=0; i<13; i++) {
if (document.all) obs[i]=new Array (eval('ob'+i).style,-100,-100)
else obs[i] = new Array (eval('document.ob'+i),-100,-100)
}
}
function cl(a,b,c){
if (document.all) {
if (a!=0) b+=-1
eval('c'+a+'.style.pixelTop='+(pY+(c)))
eval('c'+a+'.style.pixelLeft='+(pX+(b)))
}
else{
if (a!=0) b+=10
eval('document.c'+a+'.top='+(pY+(c)))
eval('document.c'+a+'.left='+(pX+(b)))
}
if (document.all) c0.style.pixelLeft=26
}
function runClock() {
for (i=0; i<13; i++) {
obs[i][0].left=obs[i][1]+pX
obs[i][0].top=obs[i][2]+pY
}
}
var lastsec
function timer() {
time = new Date ()
sec = time.getSeconds()
if (sec!=lastsec) {
lastsec = sec
sec=Math.PI*sec/30
min=Math.PI*time.getMinutes()/30
hr =Math.PI*((time.getHours()*60)+time.getMinutes())/360
for (i=1;i<6;i++) {
obs[i][1] = Math.sin(sec) * (44 - (i-1)*11)-16;
if (document.layers)obs[i][1]+=10;
obs[i][2] = -Math.cos(sec) * (44 - (i-1)*11)-27;
}
for (i=6;i<10;i++) {
obs[i][1] = Math.sin(min) * (40 - (i-6)*10)-16;
if (document.layers)obs[i][1]+=10;
obs[i][2] = -Math.cos(min) * (40 - (i-6)*10)-27;
}
for (i=10;i<13;i++) {
obs[i][1] = Math.sin(hr) * (37 - (i-10)*11)-16;
if (document.layers)obs[i][1]+=10;
obs[i][2] = -Math.cos(hr) * (37 - (i-10)*11)-27;
}
}
}
function setNum(){
cl (0,-67,-65);
cl (1,10,-51);
cl (2,28,-33);
cl (3,35,-8);
cl (4,28,17);
cl (5,10,35);
cl (6,-15,42);
cl (7,-40,35);
cl (8,-58,17);
cl (9,-65,-8);
cl (10,-58,-33);
cl (11,-40,-51);
cl (12,-16,-56);
}
document.onLoad=ob(),setNum(),setInterval('timer()',100);setInterval('runClock()',100)
// End -->
</SCRIPT>
<script language="JavaScript">
<!-- Begin
if (document.all) {
yourLogo = "测试系统 制作:李云霄 ";
logoFont = "宋体";
logoColor = "FF0000";
yourLogo = yourLogo.split('');
L = yourLogo.length;
TrigSplit = 360 / L;
Sz = new Array()
logoWidth = 100;
logoHeight = -30;
ypos = 0;
xpos = 0;
step = 0.03;
currStep = 0;
document.write('<div id="outer" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < L; i++) {
document.write('<div id="ie" style="position:absolute;top:0px;left:0px;'
+'width:10px;height:10px;font-family:'+logoFont+';font-size:12px;'
+'color:'+logoColor+';text-align:center">'+yourLogo[i]+'</div>');
}
document.write('</div></div>');
function Mouse() {
ypos = event.y;
xpos = event.x - 5;
}
document.onmousemove=Mouse;
function animateLogo() {
outer.style.pixelTop = document.body.scrollTop;
for (i = 0; i < L; i++) {
ie[i].style.top = ypos + logoHeight * Math.sin(currStep + i * TrigSplit * Math.PI / 180);
ie[i].style.left = xpos + logoWidth * Math.cos(currStep + i * TrigSplit * Math.PI / 180);
Sz[i] = ie[i].style.pixelTop - ypos;
if (Sz[i] < 5) Sz[i] = 5;
ie[i].style.fontSize = Sz[i] / 1.7;
}
currStep -= step;
setTimeout('animateLogo()', 20);
}
window.onload = animateLogo;
}
// End -->
</script></TD>
</TR>
<TR>
<TD bgColor=#ffffff><P>
<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr> <td colspan='4'> <hr size='1' noshade> </td></tr>
<tr>
<td width='340' colspan='4'><a href=\"javascript:window.external.AddFavorite('http://www.shfu.edu.cn','hello')\" title='请点击这里收藏' class='txt_blue'>收藏</a> | <a href=\"javascript:window.external.AddFavorite('http://www.shfu.edu.cn','hello')\" title='请点击这里收藏' class='txt_blue'>收藏</a> |
<a href='http://www.shfu.edu.cn' class='txt_blue'>联系我们</a> </td>
</tr>
<tr> <td colspan='4'> <hr size='1' noshade> </td></tr>
<tr>
<td colspan='4'></td>
</tr>
<tr>
<td colspan='4'>电话: 传真: 地址:</td>
</tr>
</table>
</TD>
</TR>
</TABLE>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -