With the popularization of computer networks, the database-based B/S online examination system has been widely used. Now we use ASP.net (C #) + SQL server (or ACCESS) for example, describe how to develop an online examination system.
I. Database Design:
Create a database netexam, add StuInfo to the database, and create the following fields: Examination ID (c) (Primary Key), Name (c), and whether to log on to LogYn (c), Score (c), randomly generated Question Answer mca (c) (Note: here we use multiple choice questions as an example. The same applies to single choice questions and complex questions ). Add the multi-choice question bank table mc and create the following fields: question (c), four choices choice1 (c), choice2 (c), choice3 (c), choice4 (c) answer (c ).
Ii. Login of candidates:
Insert the examinee information to the StuInfo table here to prevent repeated logins! Specify a unique question mark and set the question mark field ExamId (c) as the primary key. When you log on again, Catch the error and give the corresponding prompt. Some codes are as follows (login. aspx ):
Private void ButOk_Click (object sender, System. EventArgs e)
{
...
SqlConnection StuConn = new SqlConnection ("Data Source = localhost; Integrated Security = SSPI;
Initial Catalog = netexam ");
SqlCommand LoginCmd = StuConn. CreateCommand (); // You can select different database connections based on different situations.
...
LoginCmd. commandText = "Insert into StuInfo (ExamId, Name) values ('" + TxtId. text. trim () + "','" + TxtName. text. trim () + "')";
// Insert the test number and name into the corresponding fields. TxtId and TxtName are the text boxes that enter the test number and name respectively.
Try
{
...
Session ["Id"] = TxtId. Text. Trim ();
StuConn. Open ();
LoginCmd. ExecuteReader ();
Response. Redirect ("test. aspx ");
}
Catch (Exception) // catch the corresponding error
{
Response. Write ("<script language =" javascript ">" + "");