Questions about random question Extraction

Source: Internet
Author: User

Newid of the SQL2000 database

Recently, I was working on an online examination system and encountered a random question extraction problem. The difficulty was that I had to randomly select questions from the database and asked me to randomly select 10 questions from the database, and each question is different.

It is better to use the newid () of the MS SQL2000 database.

recently, I used Asp.net as an examination system, but I encountered some trouble when dealing with random questions.
the plan is to set parameters for each question (including multiple-choice questions, empty-filling questions, question answering questions, and question answering questions) as follows: Chapter, knowledge point, Difficulty coefficient, and whether it is a key chapter.
How should I judge the random number used for random question extraction?
for example, when the instructor specifies the exam parameters, the instructor selects 20 multiple-choice questions, 15 key chapters, 5 other chapters, and 5 more difficult chapters, generally, 10 is required, and 5 is easy to use. (You may need to have questions about a specific chapter, for example, several questions about a specific chapter ). Then, how should we deal with the Program on these basis ????
Other blank questions, closed questions, and Q & A settings are similar to those of the preceding multiple choice questions.
Thank you for your advice. If you are interested, let's talk about it ~~~~~~~~ '
select top 5 * from question where difficulty = 'ture' order by newid ()
Union
select top 25 * From where is not difficult = 'ture 'order by newid ()
Union
select top 55 * from question where easily = 'ture 'order by newid ()

Select top 1 * from Table order by newid ()

The number next to the top is the number of data records to be searched immediately.

This method applies only to SQL Server

 

Select Top 4 * from Table order by RND (ID)

This sentence applies to access. For more information, see

 

Select * From table_name order by rand () [limit num];
MySQL random query statement.

 

With the development of Internet technology, online teaching will become the main form of re-education and lifelong education. In online schools, people can choose any course from anywhere anytime, regardless of their time and space. The Development of Online schools puts forward urgent requirements for the development of online examinations. Here is an online examination system I implemented using ASP and access database. When a user logs on with the user name and password, the system first checks whether the user has taken the test. If not, the system queries the score. If not, it extracts questions from the question library for the user to answer. After the user submits the answer, the system scores and registers the score into the database.
I. 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. Storage Username

Field name: passwd; field type: text; field size: 20. Store user passwords

Field name: score; field type: Number; field size: integer. Store user scores
The test table has five fields:
Field name: question; field type: text; field size: 255. Storage 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. Store answer for Option B

Field name: C; field type: text; field size: 100. Store the answer to option C

Field name: D; field type: text; field size: 100. Store the answer to option D

Field name: ans; field type: text; field size: 2. Store correct answers
Ii. Original procedureCode
The following are three core original programs in the system. We hope that readers who develop similar systems can learn from them. Readers can also improve these programs to adapt to their own systems.

'Login. ASP source code to check whether the user is legal
<% @ Language = VBScript %>
<%
Name = trim (Request ("name "))
Passwd = trim (Request ("passwd "))
'Check whether the user has entered the 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 validity of the user
Set rs = conn. Execute (SQL)
If not (Rs. EOF) then
Check whether the user has taken the test,
If yes, query the score.
If RS ("score") <> 0 then
Response. Write RS ("user ")&
"The score is" & RS ("score ")
Else
Session ("pass") = 1
Session ("user") = Name
Response. Redirect "test. asp"
End if
Else
Response. Write "sorry,
Incorrect user or password !!! "
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, which extracts questions from the question library for answers
<% @ 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 question
SQL = "select * from test"
Set rs = conn. Execute (SQL)
%>
'Timing Functions
<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">
</Head>
<Body onload = "startit ()" bgcolor = "ffffff">
<Center>
'Call the timer function to display the time
<Table border = 2>
<Tr>
<TD> time </TD> <TD> hour </TD> <TD> min
</TD> <TD> sec </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 questions for answers
<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>

'Result. asp Source program, score users' answers,
And record the score to the database.
<% @ Language = VBScript %>
<HTML>
<Head>
<Meta name = "generator" content = "Microsoft
Visual maxcompute 6.0 ">
</Head>
<Body>
<P> </P>
<%
Name = SESSION ("user ")
Dim score
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver =
{Microsoft Access Driver (*. mdb)}; DBQ ="
& Server. mappath ("exercise. mdb ")
SQL = "select ans from test"
Set rs = conn. Execute (SQL)
Ycorrect = 0
Rscount = 0
'Give the correct answer and score
Response. Write "correct answer :"
Do while not Rs. EOF
Response. Write RS ("Ans ")
Rscount = rscount + 1
If request. Form (rscount) = RS ("Ans") then
Ycorrect = ycorrect + 1
End if
Rs. movenext
Loop
Response. Write "<br> your answer :"
Score = int (ycorrect/rscount * 100)
For I = 1 to request. Form. Count-1
Response. Write Request. Form (I)
Next
Response. Write "<br>"
Response. Write "your score:" & score
If score <60 then response. Write "you fail! "&" <Br>"
Else if score> = 60 response. Write "pass" & "<br>"
Else response. Write "Excellent! "
'Register the score to the database.
Strsql = "insert into user (result) values (" & score &")
Where user = '"& name &"'"
Conn.exe cute (strsql)
%>
</Body>
</Html>

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.