Exam System question implementation (single option)

Source: Internet
Author: User

Insus. NET has always wanted to write the idea of implementing Single-choice questions into blog posts. To implement Single-choice questions, you need to be clear about the following issues:
The first is the option content, which consists of several options: one, two, three, and four. The option content is A, B, C, or other content, is the Key value stored or the display value stored? Therefore, when designing these options, you can implement multiple radio options.

The second is the single-choice question, the title content, and a field to store the standard answer (this demonstration). You can also store the answer in another separate table.

Third, the answers provided by the examiner should be stored. You can change your answers within the exam time. Therefore, the fields in this table include the user ID, question ID, answer, and time. In fact, the real design may require you to consider how many times a user can take the exam and the selected question bank...

In this demonstration, only the test questions are displayed, the answers are stored by the tester, and reading functions are implemented. The test questions are created and generated, and are not demonstrated here.

First, create a table as the storage option type, mainly to solve the number of single-choice options, the content is different.

ANSI_NULLS QUOTED_IDENTIFIER .(,)()View Code


Single option table:

ANSI_NULLS QUOTED_IDENTIFIER .(,).((View Code

 
Single-choice questions:

ANSI_NULLS QUOTED_IDENTIFIER .(,)().(.())View Code


The following describes how to prepare the demo and create some option categories, options, and single option questions.
In the option category, Insus. NET creates four categories. Of course, these names can be used freely.

 
The content of each category option depends on the actual situation to set options.



Next, Insus. NET tries to add multiple choice questions.



Next, Insus. NET also designs a table to store the questions of each Examiner. The real examination should be the question bank number corresponding to the examiner, but now it is only a demonstration of single choice, so the choice of questions is stored directly. When the examiner enters the examination, he will copy the questions. The table structure is roughly as follows:

ANSI_NULLS QUOTED_IDENTIFIER .(,)().(View Code


After the user is successfully registered, the system needs to execute a stored procedure, create a user's questions, or log on to the examination system, you need to select a question.

.((..(,),.View Code


OK. When the tester ("EU_001") starts to answer the question, the exam must be displayed on the webpage.

. (, Q.,... q (t. q.View Code


The initial information of his exam in the database is as follows:


When the question is displayed, the choice is displayed.

.,,.View Code


For questions and options to be displayed on the web page, Insus. NET allows the web page to connect and communicate with data, that is, the objects at the logic layer.

{User_number = Parameter (, SqlDbType. VarChar,-objbusinimap4. GetDataToDataSet (, param). Tables [Test. cs

 

{_ Type = Parameter (, SqlDbType. TinyInt, objbusinimap4. GetDataToDataSet (, param). Tables [SingleChoose. cs

 

Answer the exam. Submit the exam after selecting all. For better interaction, Insus. NET separates questions from options and then combines them.

To solve the interactive communication between the webpage Page and the user control UserControl, Insus. NET writes two interfaces below:






Create an option user control:

Options. ascx


In the Options. ascx. cs code, you need to implement the above two interfaces:



When displaying questions, you must dynamically load user controls for each single-choice question. Therefore, Insus. NET has to design an interface:

The user control OPtions implements this interface again:



Ready, We will display single-choice questions and present them using the lightweight Repeater control.



There are two places on the top. One is the OnItemDataBound event, and the other is the PlaceHolder control, which is used to display options.



Is to find the PlaceHolder control of the Repeater control.
The serial number is used to dynamically load the user control and obtain the user control.
The serial number is used to dynamically set parameters for the user control.

The single-choice question displayed by the examiner is as follows:



We also need to store the candidates we choose. You need to create an updated stored procedure:

ANSI_NULLS QUOTED_IDENTIFIER ..View Code


Go to the test. cs category and add a public method:

 

Because the Repeater control does not have the DataKeyNames attribute such as the GridView, A HiddenField control should be placed and a button should be added to enable the user to hand in the action.

 

In "1", it is to get the primary key; serial number 2 is to get the selected user control; serial number 3 is to get the value selected by the user. In addition, when you design the exam, you should be unable to see the exam after submitting the exam. It should be a prompt that the exam has been handed in.
If the examinee makes the following choices:


Click the button to view the data stored in the data table:



Okay. The whole demonstration is complete. This will help you develop the application of the RadioButtonList control. This blog post involves databases, stored procedures, and user controls, focusing on interworking between webpages and user controls. This also involves interfaces for dynamic loading of user controls, how to obtain values in the Repeater control, such as primary keys, In the button event outside the repeater control.

In fact, as a better test design, the examiner should be able to view the corrected test paper. The system should automatically compare the standard answer to identify errors and errors.



Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.