亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

利用ASP+XML架設在線考試系統 

2019-11-18 20:18:50
字體:
來源:轉載
供稿:網友
利用asp + xml 架設在線考試系統

<-------------此程序非本人原創-------->
  
使用這個在線的考試系統,我們能處理任何類型在線測試。 盡管我們一般是用傳統方式實現,讀者非常希望將。

如果從總體上考慮。 所有問題都儲存在服務器( 它可能在數據庫里) 里面的的xml 文件里。 用戶準備花費考試,然后用戶測試的通體將通過微軟的XML HTTP 組件傳送到瀏覽器。 使用同一個XML HTTP 組件,每當用戶請求一個問題的時候,那些問題內容被從服務器解釋并且顯示在頁上。 對用戶的任何問題,你所選擇的答案會被儲存在客戶端。  



一次考試的持續時間是5 分鐘。 沒有回答不了,你可以使用NEXT回答下洋問題。 一旦用戶啟動考試,所有問題目錄將來自服務器。 所給問題的Id 每請求到服務器以來在內目錄在客戶拿給并且給服務器派內儲存。 服務器將返回問題內容,符合問題Id,從xml 文件。 當用戶選擇任何一個答案時,體制將在那些應答表里儲存和在在客戶邊里的選擇表里。 用戶最后已經選擇的正確的答案,應答表用來并不地檢查。 選擇表在那里是以便系統將自動選擇用戶已經選擇了的選擇 ( 例如用戶點擊以前的按鈕) 考試將結束或者用戶點擊終結按鈕或者首先來,時間( 例如5 分鐘) 結束。 關于終結,系統將計算并不右邊答案的并且展示它。 那些以下的文件被在在線的考試系統里使用:

OLExam.html

<html>
<script>
  var objxmlhttp,objXmlDOM;
  var aQuest; //to store question ids
  var aAnswer = new Array(); // to track the result
  var aSelected = new Array(); // to store user's response
  var count = 0; //to store the current question no
  var ansSel = 0; //to store user's selection
  var ExamDuration = 5 * 60 ; // 5 minutes
  var timerID; //to store the setInterval fun's id
  var radIndex = -1; //to store the selected radio's index

  //constructor like function
  //here XML objects are created and
  //No of questions as well as question ids list
  //are fetched from the server.
  function init(){
    objXmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
    objXmlDOM = new ActiveXObject("Microsoft.XMLDOM");
    objXmlHTTP.open("POST","OLExam.asp?Action=Start",false);
    objXmlHTTP.send("");
    temp =objXmlHTTP.ResponseText;
    aQuest = temp.split(",");

    //initialize the user's answers list
    for(i=0;i<aQuest.length; i++){
      aAnswer[i] = 0; // 0 for wrong; 1 for right answer
      aSelected[i] = -1; // to store the radio's index
    }

    if(count < aQuest.length) {
      url = "OLExam.asp?Action=NextQ&QNo=" + aQuest[count];
      objXmlHTTP.open("POST", url ,false);
      objXmlHTTP.send("");
      objXmlDOM.loadXML(objXmlHTTP.ResponseText);
      
      //parse the response content fetched from the server
      //and display the question
      parseQ();
    }
    
    //change the Start button's caption and its click event
    document.frm.btnFinish.value = "Finish the Exam";
    document.frm.btnFinish.onclick = showResult; //function
    
    //start the timer
    timerID = setInterval("timer()",1000);
  }

  function getPReQ() {
    //update the user's answers list
    checkAnswer();
    
    //decrement the question no - i.e. to previous Question
    count--;
    
    //stop the timer
    clearInterval(timerID);
    
    //fetch the question for the aQuest[count] id
    url = "OLExam.asp?Action=NextQ&QNo=" + aQuest[count];
    objXmlHTTP.open("POST",url ,false);
    objXmlHTTP.send("");
    objXmlDOM.loadXML(objXmlHTTP.ResponseText);

    //parse the response content fetched from the server
    //and display the question
    parseQ();
    
    //start the timer
    timerID = setInterval("timer()",1000);
  }

  function getNextQ() {
    //update the user's answers list
    checkAnswer();

    //increment the question no - i.e. to next Question
    count++;

    //stop the timer
    clearInterval(timerID);

    url = "OLExam.asp?Action=NextQ&QNo=" + aQuest[count];
    objXmlHTTP.open("POST", url ,false);
    objXmlHTTP.send("");
    objXmlDOM.loadXML(objXmlHTTP.ResponseText);

    //parse the response content fetched from the server
    //and display the question
    parseQ();

    //start the timer
    timerID = setInterval("timer()",1000);
  }

  function parseQ(){
    //fetch the question from theXML Object
    //format the display     
    strOut  = "<table border=0 align=center width=80%>";
    strOut += "<tr><td colspan=2><b>";
    strOut += "Question No: " + (count+1) + " of ";
    strOut += aQuest.length + "</b></td></tr>";
    strOut += "<tr><td colspan=2> </td></tr>";

    temp = objXmlDOM.selectSingleNode("data/qtext").text;

    strOut += "<tr><td colspan=2><b>"+temp+"</b></td></tr>";
    strOut += "<tr><td colspan=2> </td></tr>";

    Nodes = objXmlDOM.selectNodes("data/choice");

    for(i=0;i<Nodes.length;i++){
      strOut += "<tr><td align=center width=10%>";
      strOut += "<input type=radio name=ansUsr ";
      strOut += " onClick='ansSel=" + (i+1);
      strOut += ";radIndex=" + i + "' ";
      strOut += "value=" + (i+1) + "></td><td>";
      strOut +=  Nodes.item(i).text + "</td></tr>";        
    }

    //set ansNo (hidden field) to the actual answer
    temp = objXmlDOM.selectSingleNode("data/answer").text;
    document.frm.ansNo.value = temp;

    strOut += "<tr><td colspan=2> </td></tr>";
    strOut += "<tr><td colspan=2>";

    if(count != 0 ){
      strOut += "<input type=button value=Previous ";
      strOut += " onClick='getPreQ()'> ";
    }

    if(count < aQuest.length-1){
      strOut += " <input type=button value=Next";
      strOut += " onClick='getNextQ()'>";            
    }

    strOut += "</td></tr></table>";

    //set the strOut content to <P> tag named QArea
    QArea.innerHTML = strOut;

    //set the default value to ansSel
    ansSel = 0;
    radIndex = -1;

    //check the radio if user has selected previously
    if (aSelected[count] != -1) {
      radIndex = aSelected[count];
      ansSel = radIndex + 1;
      document.frm.ansUsr[radIndex].checked = true;
    }
  }

  function checkAnswer(){
    //store the selected radio's index
    aSelected[count] = radIndex;

    //if the user selection matches the actual answer
    if (ansSel == document.frm.ansNo.value)
      aAnswer[count] = 1;
    else
      aAnswer[count] = 0;
  }

  function showResult() {
    rights = 0;

    //stop the timer
    clearInterval(timerID);

    //update the user's answers list
    checkAnswer();

    //count no of answers
    for(i=0;i<aAnswer.length;i++){
      if(aAnswer[i] == 1)
      rights++;
    }
    strRes = "<h2 align=center><br>";

    //if all the answers are correct then greet
    if(rights == aAnswer.length)
      strRes += "<br><br>Congratulations...!";

    strRes += "<br><br>your score is " + rights;
    strRes += " out of " + aAnswer.length + "</h2>";

    document.write(strRes);
  }

  var timeCount = 0;
  function timer(){
    timeCount++;  //increment the time by one second

    //to display the time in the status bar,
    // uncomment the next line
    //window.status = "..." + timeCount + " secs" ;

    //to display the time
    temp =  "Time:   " + parseInt(timeCount/60);
    temp += "  min : " + (timeCount%60) + " sec ";
    TBlock.innerText = temp;

    //if the time is up
    if (timeCount == ExamDuration) {
      alert("Sorry, time is up");
      showResult();
    }
  }
</script>

<body>
<h2 align=center><font color=green>OnLine Exam</font></h2>

<form name=frm >
<table border=1 width=95% bgcolor=DarkSeaGreen align=center>
<tr><td align=right><b id=TBlock></b></td></tr>
<tr><td>
<p id="QArea">
<center>
<br>
Relax...! The duration of this exam is 5 minutes.
<br>
There is no order to answer a question. You may use Next as
well as Previous button to get a question to answer.
<br>
<br>
<input type=button name=btnFinish value="Start the Exam"
onClick="init()">
</center>
</p>
<input type=hidden name=ansNo>
</td></tr></table>
</form>

</body>
</html>





OLExam.asp


<%
Response.expires = 0
'create an instance of MS XMLDOM Object
'and load the QBank.xml file where all the questions are.

set obj = server.createobject("Microsoft.XMLDOM")
obj.async = false
obj.load(Server.MapPath("QBank.xml"))

'very first request from the client
if trim(request("Action")) = "Start" then
  'set no of questions per exam
  Dim NoQ,TotalQ
  
  NoQ = 5 'set no less than the totalquestions
  
  'count no of questions in the xml file
  '( or from database)
  TotalQ = obj.selectNodes("data/question").length

  Dim aQuest(),temp,isExist, strQ
  ReDim aQuest(0) 'to store the question ids
  
  'generate (=NoQ) question ids randomly
  while ubound(aQuest) < NoQ
    isExist = false
    temp = Int((TotalQ * Rnd) + 1)
    for i = 1 to ubound(aQuest)
      if aQuest(i) = temp then
        isExist = true
        exit for
      end if
    next
    if Not isExist then
      Redim Preserve aQuest(ubound(aQuest)+1)
      aQuest(ubound(aQuest)) = temp
      strQ = aQuest(i) & "," & strQ
    end if
  wend
  
  'remove the last comma ',' from strQ
  strQ = left(strQ,len(strQ)-1)
  
  'send the question in the strQ to the client
  response.write strQ
  
'all further requests - after the first request
elseif trim(request("Action")) = "NextQ" then
  'fetch the question from the XML Object
  'and form the output string
  temp = "data/question[@id=" & trim(request("QNo")) & "]"

  set Node = obj.selectSingleNode(temp)

  strXML = "<data>"
  strXML = strXML & "<qtext>"
  strXML = strXML & Node.selectSingleNode("qtext").text
  strXML = strXML & "</qtext>"
  strXML = strXML & "<answer>"
  strXML = strXML & Node.selectSingleNode("answer").text
  strXML = strXML & "</answer>"

  set Node = Node.selectNodes("choices/choice")

  for i = 0 to Node.length-1
    strXML = strXML & "<choice>"
    strXML = strXML & Node.item(i).text
    strXML = strXML & "</choice>"
  next

  strXML = strXML & "</data>"

  'send the output to the client
  Response.Write (strXML)
end if
%>





QBank.xml

<?xml version="1.0"?>
<data>
  <question id="1">
    <qtext>What does KB stand for?</qtext>
    <choices>
      <choice>Kilo Bits</choice>
      <choice>Key Board</choice>
      <choice>Kilo Bytes</choice>
      <choice>None</choice>
    </choices>
    <answer>3</answer>
  </question>
  <question id="2">
    <qtext>CPU stands for</qtext>
    <choices>
      <choice>Central Processing Unit</choice>
      <choice>Central Power Unit</choice>
      <choice>Core Processing Unit</choice>
      <choice>Core Power Unit</choice>
    </choices>
    <answer>1</answer>
  </question>
  <question id="3">
    <qtext>1 KB equals</qtext>
    <choices>
      <choice>1000 Bytes</choice>
      <choice>1024 Bytes</choice>
      <choice>1000 Bits</choice>
      <choice>1024 Bits</choice>
      <choice>Nothing</choice>
    </choices>
    <answer>2</answer>
  </question>
  <question id="4">
    <qtext>RAM is </qtext>
    <choices>
      <choice>Random access Modifier</choice>
      <choice>Primary Memory</choice>
      <choice>Secondary Memory</choice>
      <choice>Read And Modify</choice>
    </choices>
    <answer>2</answer>
  </question>
  <question id="5">
    <qtext>Hard Disk is </qtext>
    <choices>
      <choice>Hard to break</choice>
      <choice>Primary Memory Storage</choice>
      <choice>Temporary Memory Storage</choice>
      <choice>Secondary Memory Storage</choice>
    </choices>
    <answer>4</answer>
  </question>
  <question id="6">
    <qtext>Computer Monitor is used </qtext>
    <choices>
      <choice>To monitor activities</choice>
      <choice>To control Computer</choice>
      <choice>As display unit</choice>
      <choice>None</choice>
    </choices>
    <answer>3</answer>
  </question>
  <question id="7">
    <qtext>XML stands for</qtext>
    <choices>
      <choice>Extended Markup Language</choice>
      <choice>Extended Model Language</choice>
      <choice>Extensible Markup Language</choice>
      <choice>Extensible Model Language</choice>
    </choices>
    <answer>3</answer>
  </question>
  <question id="8">
    <qtext>ASP stands for</qtext>
    <choices>
      <choice>Active Server Page</choice>
      <choice>application Service Provision</choice>
      <choice>As Soon as Possible</choice>
      <choice>All</choice>
    </choices>
    <answer>1</answer>
  </question>
</data>



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
国语自产精品视频在线看抢先版图片| 国产精品久久久久久中文字| 另类图片亚洲另类| 欧洲精品久久久| 亚洲精品福利视频| 久久中国妇女中文字幕| 国产日韩精品在线| 综合国产在线观看| 国产精品99久久久久久久久久久久| 国产在线不卡精品| 欧美理论电影在线观看| 欧美一级大片在线免费观看| 亚洲精品视频播放| 一区二区三区视频观看| 欧美精品999| 欧美激情精品久久久久久黑人| 51视频国产精品一区二区| 91sa在线看| 国产精品欧美日韩| 亚洲精品第一页| 最新日韩中文字幕| 国产精品第一视频| 成人字幕网zmw| 成人羞羞国产免费| 亚洲国产欧美自拍| 久久亚洲精品毛片| 国产中文欧美精品| 91亚洲国产成人久久精品网站| 久久av在线看| 久久久久久久久久久网站| 国产精品青草久久久久福利99| 欧美日韩在线视频一区二区| 日韩有码片在线观看| 尤物九九久久国产精品的分类| 国产精品视频久久久| 欧美日韩成人在线播放| 久久久久久一区二区三区| 国产精品久久久久久久久男| 久久综合国产精品台湾中文娱乐网| 亚洲第一视频网站| 亚洲国产精品悠悠久久琪琪| 欧美电影在线免费观看网站| 国产精品亚洲片夜色在线| 国产91在线播放精品91| 精品久久久一区二区| 国产精品欧美日韩| 尤物yw午夜国产精品视频| 欧美诱惑福利视频| 亚洲精品一区二三区不卡| 精品中文字幕在线观看| 超碰精品一区二区三区乱码| 国产精品xxx视频| 亚洲午夜精品视频| 欧美自拍视频在线| 午夜精品99久久免费| 久久久亚洲福利精品午夜| 日韩欧美在线观看视频| 欧美乱大交做爰xxxⅹ性3| 亚洲缚视频在线观看| 欧美一级黄色网| 欧美在线视频一二三| 欧美成aaa人片免费看| 2018中文字幕一区二区三区| 国产一区红桃视频| 美女久久久久久久| 国产91在线高潮白浆在线观看| 国内外成人免费激情在线视频网站| 国产在线精品一区免费香蕉| 国产精品久久久久久久久久东京| 免费91在线视频| 在线观看欧美日韩| 成人有码在线视频| 亚洲春色另类小说| 亚洲乱码一区av黑人高潮| 5566成人精品视频免费| 亚洲风情亚aⅴ在线发布| 久久夜色精品国产| 久久久综合av| 国产日韩欧美在线观看| 黄色成人在线免费| 日韩av三级在线观看| 国产极品精品在线观看| 亚洲欧美在线一区二区| 国产精品久久久久久久久久新婚| 成人xvideos免费视频| 国产精品视频最多的网站| 亚洲成年人影院在线| 亚洲精品久久久久中文字幕欢迎你| 亚洲精品免费av| 久久伊人色综合| 国产这里只有精品| 欧美午夜视频一区二区| 久久天堂av综合合色| 一区三区二区视频| 色悠久久久久综合先锋影音下载| 精品国产乱码久久久久久婷婷| 日韩精品中文字幕在线观看| 久久久亚洲国产| 久久久久久久久久久免费| 这里精品视频免费| 成人欧美一区二区三区黑人孕妇| 91禁国产网站| 日韩高清中文字幕| 538国产精品一区二区免费视频| 国产97色在线|日韩| 国产欧美日韩亚洲精品| 日韩欧美中文第一页| 日本精品久久中文字幕佐佐木| 午夜精品久久久久久久白皮肤| 日韩av中文字幕在线播放| 日韩电视剧在线观看免费网站| 欧美乱人伦中文字幕在线| 欧美一级大片在线观看| 亚洲欧美成人精品| 国产精品99久久久久久久久| 欧美激情乱人伦| 亚洲91av视频| 午夜剧场成人观在线视频免费观看| 欧美日韩福利视频| 国产精品入口夜色视频大尺度| 国产精品91久久| 亚洲黄色在线看| 国产美女主播一区| 国产成人在线亚洲欧美| 国产一区二区三区视频免费| 欧美国产在线电影| 欧美国产亚洲视频| 欧美精品在线免费观看| 成人中文字幕+乱码+中文字幕| 国产精品白嫩美女在线观看| 亚洲国产精品va在线看黑人| 日韩在线一区二区三区免费视频| 亚洲欧美制服另类日韩| 国产精品∨欧美精品v日韩精品| 国产精品激情自拍| 欧美黑人一级爽快片淫片高清| 69影院欧美专区视频| 97久久精品人人澡人人爽缅北| 久久成人在线视频| 久久精品亚洲94久久精品| 国内精品久久久久久久久| 久久久精品一区| 亚洲激情视频在线播放| 4438全国成人免费| 亚洲国产一区二区三区在线观看| 欧美在线视频免费播放| 国a精品视频大全| 亚洲色图av在线| 欧美成人手机在线| 美日韩丰满少妇在线观看| 2019亚洲男人天堂| 国产精品久久久久久久电影| 一本色道久久综合狠狠躁篇怎么玩| 大胆人体色综合| 日韩av在线影院| 国产精品亚洲欧美导航| 久久久国产一区二区| 亚洲精品一区二区三区不| 欧美在线日韩在线| 国产成人亚洲综合| 正在播放国产一区| 国产精品爱啪在线线免费观看| 日本不卡高字幕在线2019| 国产精品视频免费观看www|