测验问题以获取不同的问题 [英] quiz problem to fetch different questions

查看:52
本文介绍了测验问题以获取不同的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生/女士



i开发一个测验网络应用程序。现在这是一个工作,没有两个学生有相同的问题谁坐在附近其他。

先生我的问题chane的代码如下所示,其中lbquescnt,lbmaxques是文本字段。

请帮我解决这个问题。



ques_change(Me.lbquescnt.Text + 1)



'重新更改

Dear Sir/Ma'am

i develop a quiz web application.Now here is a working that no two student have the same questions who are sitting near to each other.
sir my code for ques chane is given below in which lbquescnt,lbmaxques are the text field .
Please help me regarding this condition.

ques_change(Me.lbquescnt.Text + 1)

'Ques change

Public Sub ques_change(ByVal quesid As Integer)


        maxques = Val(lbmaxques.Text)


        If quesid >= 1 Then
            ImageButton1.Enabled = True
        Else
            ImageButton1.Enabled = False
        End If


        'if reaches maximum question
        If quesid = maxques Then
            ImageButton2.Enabled = False
        Else
            ImageButton2.Enabled = True

        End If

        get_ques(quesid)
        get_prev_ans(quesid)
    End Sub



'得到问题




'get Question

Public Sub get_ques(ByVal quesid As Integer)
        str = "select * from quizdetails where quiz_id = '" & quizid & "'"
        cmdly.rst1 = New DataTable
        cmdly.rst1 = cmdly.executenonquery(str)

        str = "select * from quizquestion where quiz_id = '" & quizid & "' and ques_id  = '" & quesid & "' order by ques_id"
        cmdly.rst2 = New DataTable
        cmdly.rst2 = cmdly.executenonquery(str)
        If cmdly.rst2.Rows.Count > 0 Then

            lbquescnt.Text = quesid
            lbques.Text = "Q. " & cmdly.rst2.Rows(0).Item("question").ToString

            cmdly.rst3 = New DataTable
            str = "select * from quizoption where quiz_id = '" & quizid & "' and ques_id  = '" & cmdly.rst2.Rows(0).Item("ques_id") & "'"
            cmdly.rst3 = cmdly.executenonquery(str)

            If cmdly.rst3.Rows.Count > 0 Then
                i = cmdly.rst3.Rows.Count
                c = 0
                quizlst.Items.Clear()

                While c < i
                    Dim qlist As New System.Web.UI.WebControls.ListItem
                    qlist.Text = cmdly.rst3.Rows(c).Item("optionVALUE").ToString
                    qlist.Value = cmdly.rst3.Rows(c).Item("option_id").ToString
                    quizlst.Items.Add(qlist)
                    c = c + 1
                End While
            End If
        End If
    End Sub
<pre>

推荐答案

使用ORDER BY NEWID()子句::



Use ORDER BY NEWID() clause::

str = "select * from quizquestion where quiz_id = '" & quizid & " and ques_id  = ( SELECT TOP 1 ques_id FROM quizquestion ORDER BY NEWID() )"





另请参阅我的答案(已解决):在sql表中随机播放一列值? [ ^ ]



参考:NEWID():: http://msdn.microsoft.com/en-us/library/aa276822(v = sql.80).aspx [ ^ ]


这篇关于测验问题以获取不同的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆