With the development of Internet technology, online teaching will become the main form for people to receive re-education and lifelong education. In online schools, people can choose to learn any course anywhere, anytime and anywhere, without the restriction of time and space. The development of the online school has put forward the urgent request to the development of the online examination. Here is an online exam system that I implemented using ASP and Access database. When the user login by user name and password, the system first check whether the user has participated in the examination, if the results of the query, if otherwise, from the question bank to extract the questions for the user to answer. After the user submits the answer sheet, the system scores and registers the results.
A Database design
First set up a database Exercise.mdb, which includes two tables: the user and Test,user tables include three fields:
Field name: User; field type: text; Field Size: 20. Store User Name
Field name: passwd; field type: text; Field Size: 20. Store user Password
Field name: Score; field type: number; Field size: integral type. Store user Scores
There are five fields in the test table:
Field name: Question; field type: text; Field Size: 255. Storing test questions
Field name: A; field type: text; field Size: 100. Answer to storage option A
Field name: b; field type: text; field Size: 100. The answer to storage option B
Field name: C; field type: text; field Size: 100. The answer to storage option C
Field Name: D; field type: text; field Size: 100. Storage Option D Answer
Field name: ans; field type: text; Field Size: 2. Store correct answers
Two Program Original Code
The following is the core of the system in the three section of the original program, hope that the development of similar systems readers to get the role of the reader can also be improved to adapt to their own system.
' Login.asp source program to verify the legality of the user
<%@ language=vbscript% >
<%
Name=trim (Request ("name"))
Passwd=trim (Request ("passwd"))
' Check if the user enters information
If name< > "" and passwd< > "" Then
Set conn = Server.CreateObject
("ADODB.") Connection ")
Conn. Open Driver={microsoft Access
Driver (*.mdb)};d bq= "&
Server.MapPath ("Exercise.mdb")
Set rs= Server.CreateObject ("Adodb.recordset")
Sql= "SELECT * from user where user= '" &name&
"' and Passwd= '" & passwd & "'"
' Check the legality of the user
Set rs= Conn. Execute (SQL)
If not (rs.eof) then
Check if the user has taken the exam,
If you have a performance check
If RS ("score") < >0 Then
Response.Write rs ("user") &
"The test score is" &rs ("score")
Else
Session ("Pass") =1
Session ("User") =name
Response.Redirect "Test.asp"
End If
Else
Response.Write "I'm sorry,
The user or password is incorrect!!! "
End If
Else
End If
% >
< HTML >
< head >
< META name= "generator"
Content= "Microsoft Visual Studio 6.0" >
< TITLE > User password check </title >
< BODY >
< FORM action= "Login.asp" Id=form1
Method=post Name=form1 >
< P title= "" > </p >
< P title= "" > </p >
< P title= "" Align=center > User:
< INPUT Id=text1 Name=name
Style= "HEIGHT:22PX; width:103px "></p >
< P title= "" Align=center > Password:
< INPUT id=password1 NAME=PASSWD
Style= "HEIGHT:23PX; Width:101px "
Type=password ></p >
< P title= "" Align=center >
< INPUT id=submit1 Name=submit1
Type=submit value= "into the style=" Font-size:
Medium Font-style:normal;
Font-variant:normal; Font-weight:
Bold "title=" ></p >
< P title= "" Align=center >
</p >
</form >
</body >
' test.asp source program, extract the questions from the question bank to answer
<%@ language=vbscript% >
<%
If session ("Pass") < >1 Then
Response.Redirect "Login.asp"
Else
End If
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open Driver={microsoft Access Driver
(*.mdb)}; Dbq= "&
Server.MapPath ("Exercise.mdb")
' Extract the questions
Sql= "SELECT * FROM Test"
Set RS = conn. Execute (SQL)
% >
' Timer function
< SCRIPT language= "JavaScript" >
var isn1=null;
var Isn2=false;
Today=new Date ();
function StoPit () {
if (ISN2) {
Cleartimeout (ISN1);
}
ISN2 = false;
}
function Startit () {
StoPit ();
Isnclock ();
}
function Isnclock () {
var now=new Date ();
var hrs=now.gethours ();
var min=now.getminutes ();
var sec=now.getseconds ();
Document.clckh.disp.value= "" + (hrs >12)?
hrs-12:hrs);
Document.clckm.disp.value= ((min< 10)? "0": "") +min;
Document.clcks.disp.value= ((sec< 10)? "0": "") +sec;
document.clck.disp.value= (hrs >=12)? "p.m.": "A.M";
Isn1=settimeout ("Isnclock ()", 1000);
Isn2=true;
}
</script >
< HTML >
< head >
< META name= "generator"
Content= "Microsoft Visual Studio 6.0" >
< body bgcolor= "FFFFFF" >
< Center >
' Call the timer function to show the time
< TABLE border=2 >
< TR >
< TD >Time</TD >< TD >Hour</TD >< TD >min
</td >< TD >Sec</td >< TD ></td >
</tr >
< TR >
< TD ></td >
< TD valign=top >< FORM name= "Clckh" >
< INPUT type= "text" name= "disp" size=2 VALUE = "" >
</form ></td >
< TD valign=top >< FORM name= "clckm" >
< INPUT type= "text" name= "disp" size=2 VALUE = "" >
</form ></td >
< TD valign=top >< FORM name= "Clcks" >
< INPUT type= "text" name= "disp" size=2 VALUE = "" >
</form ></td >
< TD valign=top >< FORM name= "Clck"
>
< INPUT type= "text" name= "disp" size=4 VALUE = "" >
</form ></td ></tr >