Developing test database and online examination system with ASP (8)
Source: Internet
Author: User
Appendix: List of Source programs
Due to the wide range of source code, limited to space, can not enumerate, now only part of the code, specific to the system in kind. Here are the entry questions. asp files:
<script language= "VBScript" >
!--' written by Hekai 2001
Function Datacheck () ' ensures that the foreground input data is legitimate
Dim Errflag, Msg
Errflag = True
If Len (Trim (luru.xzsj.value)) = 0 Then
Focusto (1); Errflag = false; msg= "Please enter ' select from book name '"
ElseIf Len (Trim (luru.stnr.value)) = 0 Then
Focusto (9); Errflag = false; msg= "' Question content '?"
ElseIf Len (Trim (Luru). A.value) = 0 Then
Focusto (10); Errflag = false; msg= "' Answer _a '?"
┋┋┋
ElseIf Len (Trim (Luru). F.value) = 0 Then
Focusto (15); Errflag = false; Msg= "Please revert to default value"
End If
If (Errflag = False) Then
msg = msg & VbCRLF
MsgBox MSG, 64, "hint"
Exit Function
End If
Datacheck = Errflag; Luru. Submit
End Function
Sub focusto (x) ' locates the mouse at the wrong place
Document.luru.elements (x). focus ()
End Sub
--> </script>
Here are the entry questions. inc Files:
<script language= "VBScript" runat= "Server"
Function Check_pass () ' Checks if this data is already in the library
KMXXMC = Request.Form ("KMXXMC")
STBH = Request.Form ("stbh") Stnr = Request.Form ("Stnr")
SQLSTR = "SELECT * from" & KMXXMC & "where stbh=" & "" & Stbh & ""
Sqlstr = sqlstr & "or tmnr=" & "" & Stnr & ""
Set Adocon=server.createobject ("ADODB. Connection ")
ADOcon. Open "Zxtest"
Set Sa1=adocon. Execute (SQLSTR)
If SA1. EOF Then
Check_pass = False
Else
Check_pass = True
End If
SA1. Close ADOcon. Close
End Function
Sub add_comment () ' starts inserting data and displaying it
Dim Kmxxmc,xzsj,tmlx,nycd,jxyq,stbh,stnr
Dim A,b,c,d,e,f,bzda,lrz,picstr,sqlstr,lr_date,zhang,jie
KMXXMC = Request.Form ("KMXXMC") XZSJ = Request.Form ("XZSJ")
┋┋┋
Bzda = Request.Form ("Bzda") Zhang = Request.Form ("Zhang")
Set Adocon=server.createobject ("ADODB. Connection ")
ADOcon. Open "Zxtest"
Sqlstr = "INSERT INTO" & KMXXMC & "(XZSJ,TMLX,TMND,JXYQ,STBH,TMNR, Bxda_a,"
Sqlstr = Sqlstr & ", Jie,lrz) VALUES (" & "" & Xzsj & "," & "'" & Tmlx & "", "
┋┋┋
Sqlstr = sqlstr & "," & "" & Date & "'," & "'" & Zhang & "," & "'" & Jie & "," Sqlstr = sqlstr & "'" & Lrz & "')"
Set SA1 = ADOcon. Execute (SQLSTR)
picstr= "Response.Write "Congratulations! This is the question that <i> & Lrz & </i> just entered.
Response.Write Picstr & "question number:" & STBH
Response.Write "Question content:" & Stnr & "<br>"
Response.Write "Answer _a:" & A & "<br>"
┋┋┋
ADOcon. Close
End Sub
Sub Register ()
If Check_pass () Then ' if there are already in the library, give a hint
Show_warning ()
Else ' otherwise ' added in
Add_comment ()
End If
End Sub
Sub show_warning () ' Provides a function for prompting information
Response.Write ("<p>")
Response.Write ("<center> Sorry <p>")
Response.Write ("There is already this question number or question content in the library, please return to the previous page modification!") ")
Response.Write ("</center>")
Response.Write ("Made by Hekai himself in 2001")
End Sub
</script>
This is the program code for "Retrieving questions":
<script language= "VBScript" runat= "Server"
Function Adjust_sql (ADJ_STR)
' Purpose---Convert special characters in query strings to SQL directives
Dim final_str, I ' WRITE by HEKAI2001
Adj_str = Trim (ADJ_STR)
Final_str = "" ' Every time a character is taken from the string being passed in and judged to be one of the following three characters: the filter symbol for DOS "|", the Left bracket "[" and the single quotation mark "" "
If Len (ADJ_STR) > 0 Then
For i = 1 to Len (ADJ_STR)
Select Case Mid (Adj_str, I, 1)
Case "[": Final_str = final_str & "[[]]
Case "|": Final_str = final_str & "[{-}]"
Case "": Final_str = final_str & "[&-()"
Case Else: ' All the above are not doing anything!
Final_str = final_str & Mid (Adj_str, I, 1)
End Select
Next
End If
Adjust_sql = Final_str
End Function
Sub Output_shiti ()
Dim Kmxxmc,xzsj,stbh,zhang,jie,tmlx,nycd,jxyq,lrz,stnr,cond_count, Picstr
Dim sqlstr,mf,zhangfw,jiefw,stbhfw,nycdfw,lr_datefw,lr_date
' Record the total number of fields in the specified condition
Cond_count = 10; MF = "%"
picstr= "' Get the form field content
KMXXMC = Request.Form ("KMXXMC")
STBH = Request.Form ("STBH")
┋┋┋
STNR = Request.Form ("Stnr")
' Adjust specific characters in SQL directives
KMXXMC = Adjust_sql (KMXXMC)
STBH = Adjust_sql (STBH)
┋┋┋
STNR = Adjust_sql (STNR)
If Len (XZSJ) = 0 Then Cond_count = cond_count-1
If Len (STBH) = 0 Then Cond_count = cond_count-1
┋┋┋
If Len (STNR) = 0 Then Cond_count = cond_count-1
SQLSTR = "SELECT * from" & KMXXMC & "where"
If Len (STBH) > 0 Then
Sqlstr = sqlstr & "STBH" & Stbhfw & "" & Stbh & ""
If Cond_count > 1 Then
Sqlstr = sqlstr & "and"
Cond_count = cond_count-1
End If
End If
┋┋┋
If Len (STNR) > 0 Then
Sqlstr = sqlstr & "Tmnr like" & "" & MF & STNR & MF & ""
If Cond_count > 1 Then
Sqlstr = sqlstr & "and"
Cond_count = cond_count-1
End If
End If
Sqlstr = Sqlstr & "ORDER by Lr_date DESC"
Set Adocon=server.createobject ("ADODB. Connection ")
ADOcon. Open "Zxtest"
Set SA1 = ADOcon. Execute (SQLSTR)
If SA1. EOF Then
Response.Write "<br> <center>"
Response.Write "sorry! <p>"
Response.Write "Didn't find the question,"
Esponse. Write "Please try again!" </center> <p> "
Response.Write "Else
i = 0
Response.Write "Response.Write "Eligible questions related to the content is as follows:"
Response.Write "While not SA1. Eof
i = i + 1
Response.Write "<i> & I &" </i> title number: <i> & SA1 ("STBH") & "</i> <br>"
Response.Write "Question content:" & SA1 ("TMNR") & "<br>"
┋┋┋
Response.Write "Answer a:" & SA1 ("Bxda_a") & "<br>"
SA1. MoveNext
Wend
ADOcon. Close
End If
End Sub
</script>
<% ' Retrieve quiz paper ' Query Way source code
mf= "%"
Select Case Request ("Findfs")
Case "SJBH"
Sqlstr= "SELECT * from Tbsjxx WHERE" & "SJBH"
Sqlstr=sqlstr & "'" & MF & Request ("Findfsz") & MF & "' ORDER by KSRQ DESC"
┋┋┋
Case "Lr_date"
Sqlstr= "SELECT * from Tbsjxx WHERE" & "Lr_date"
Sqlstr=sqlstr & "'" & MF & Request ("Findfsz") & MF & "' ORDER by KSRQ DESC"
Case Else
Sqlstr= "SELECT * from Tbsjxx ORDER by Ksrq DESC"
End Select%>
The following is the examination of the Time Automatic control program (for the demonstration only set for 60 seconds, the actual application should be the system to pull out the examination paper exam time!)! ):
<script language=javascript>
!--Write by Hekai for Testtimecontorl
var Timerid = Null;var Timerrunning = False
var stardate = new Date (); var startime = Gettotalsecond (stardate)
var totaltime = 60; var Lasttime;var FaceTime
function Stepclock () {
HK made by himself
if (timerrunning)
Cleartimeout (Timerid)
Timerrunning = False}
function Startclock () {
Stepclock (); Showtime ()}
function Gettotalsecond (getdate) {
var hours = getdate.gethours ()
var minutes = getdate.getminutes (); var seconds = Getdate.getseconds ()
var gettotalsecond = seconds + minutes * + hours * 3600
Return (Gettotalsecond)}
function Showtime () {
var now = new Date (), var timevalue = Gettotalsecond (now)
Document.clock.face.value = Timevalue-startime
FaceTime = Document.clock.face.value;lasttime = Totaltime-facetime
Document.clock.sytime.value = Lasttime
Timerid = settimeout ("Showtime ()", 1000)
Timerrunning = True
if (Lasttime = = 20) {
for (i=1;i<=3;i++) {
Alert (' Exam time is only 20 seconds left! ')}}
if (Lasttime = = 0) {
for (i=1;i<=5;i++) {
Alert (' Time to finish! Please quickly handing in your papers!! ')}}
if (Lasttime = = 10) {
for (i=1;i<=10;i++) {
Alert (' Test time is over 10 seconds, close this window! ')}}
}//-->
</SCRIPT>
Eight, PostScript
This system from the research design to the actual application lasted 4 months, through a number of meticulous testing and identification, proving that the system is fully feasible and scalable, on the recent news, the system has been the Hunan Provincial Science and Technology Department of general acclaim. In addition, the system has yet to be further upgraded, and will realize the subjective part of the test paper and multimedia paper. Therefore, a great deal of work still needs to be carried out. If there is an unknown or improper, please use the application and make good comments and suggestions.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service