Recommended: ASP 3.0 Advanced Programming (Thirty-six) Chapter 8 Basics of ADO In the first 7 chapters of this book, it has already talked about the content of ASP and how ASP brings dynamic content to the Web site. It has been seen that its scripting program allows custom web pages, allowing us to build more powerful ASP pages. Now, ASP will be studied
With the development of Internet technology, online teaching will become the main form of people's re-education and lifelong education. In online schools, people can choose any course anywhere, anywhere without being restricted by time and space. The development of online schools has put forward urgent requirements for the development of online examinations. Here is an online examination system I implemented using Asp and Access databases. When the user logs in with the user name and password, the system first checks whether the user has taken the exam. If so, conducts a score query. Otherwise, extract the test questions from the question bank for the user to answer. After the user submits the answer sheet, the system will score and register the results into the database.
one. Database Design
First, create a database exercise.mdb, which includes two tables: user and test. The user table contains three fields:
Field name: user; field type: text; field size: 20. Store username
Field name: passwd; Field type: text; Field size: 20. Store user password
Field name: score; Field type: number; Field size: integer. Store user results
There are five fields in the test table:
Field name: question; field type: text; field size: 255. Store exam questions
Field name: a; Field type: text; Field size: 100. Storage option A's answer
Field name: b; Field type: text; Field size: 100. Storage option B answer
Field name: c; Field type: text; Field size: 100. Storage option C answer
Field name: d; Field type: text; Field size: 100. The answer to storage option D
Field name: ans; field type: text; field size: 2. Store correct answers
two. Original program code
Below are three more core original programs in the system. I hope to take the role of stimulating readers who develop similar systems, and readers can also improve them to adapt to their own system.
| The following is the quoted content: 'Login.asp source program, verify whether the user is legal < %@ Language=VBScript %> < % name=trim(request(name)) passwd=trim(request(passwd)) 'Check whether the user enters information if name< > and passwd< > then Set conn = Server.CreateObject (ADODB.Connection) conn.Open driver={Microsoft Access Driver (*.mdb)};dbq= & 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 whether the user has taken the exam. If so, do a grade query 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 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> < /HEAD > < 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= Enter style=FONT-SIZE: medium; FONT-STYLE: normal; FONT-VARIANT: normal; FONT-WEIGHT: bold title= ></P > < P title= align=center > < /P > < /FORM > < /BODY > < /HTML > 'test.asp source program, extract test questions from the question bank for answering < %@ 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 test 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) ? pm : am; isn1=setTimeout(isnclock(),1000); isn2=true; } < /SCRIPT > < HTML > < HEAD > < META NAME=GENERATOR Content=Microsoft Visual Studio 6.0 > < /HEAD > < BODY onLoad=startit() BGCOLOR=FFFFFF > < center > 'Call the timing function to display 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 onSubmit=0 > < INPUT TYPE=text NAME=disp SIZE=2 VALUE = > < /FORM >< /TD > < TD VALIGN=TOP >< FORM NAME=clckm onSubmit=0 > < INPUT TYPE=text NAME=disp SIZE=2 VALUE = > < /FORM >< /TD > < TD VALIGN=TOP >< FORM NAME=clcks onSubmit=0 > < INPUT TYPE=text NAME=disp SIZE=2 VALUE = > < /FORM >< /TD > < TD VALIGN=TOP >< FORM NAME=clck onSubmit=0 > < INPUT TYPE=text NAME=disp SIZE=4 VALUE = > < /FORM >< /TD >< /TR > < /center > 'Show test questions for answering < FORM action=result.asp id=FORM1 method=post name=FORM1 > < P > < /P > < P > < % i=1 rs.movefirst do while not rs.eof% > < P > < %=rs(question)% >< /P > < TABLE align=center border=1 cellPadding=1 cellSpacing=1 width=80% > < TR > < TD style=WIDTH: 50% width=50% < INPUT name=ans< %=i% > type=radio value=A > < %=rs(a)% >< /TD > < TD >< INPUT name=ans< %=i% > type=radio value=B > < %=rs(b)% >< /TD >< /TR > < TR > < TD >< INPUT name=ans< %=i% > type=radio value=C > < %=rs(c)% >< /TD > < TD >< INPUT name=ans< %=i% > type=radio value=D > < %=rs(d)% >< /TD > < /TR > < /TABLE > < % i=i 1 rs.movenext loop % > < /P > < P > < /P > < P align=center >< INPUT id=submit1 name=submit1 type=submit value=Submit >< INPUT id=reset1 name=reset1 type=reset value=Reset >< /P >< /FORM > < /BODY > < /HTML > |
Share: ASP Advanced: Use ASP to make statistical pie charts, bar charts, etc. In our work, we often need to convert data into bar charts, pie charts, etc. to facilitate and intuitive analysis of data. Here I will introduce to you a component that makes pie charts and bar charts in ASP: csDrawGraph, csdgt.zip. Because it is a component, we need to use REGSV before using it.
2 pages in total Previous page 12 Next page