发新话题
打印

如何设置考试答题时的答案选项的选择

如何设置考试答题时的答案选项的选择

处理答题的情况是,在答题页列出了所有的试题以及对应的答案,试题使用试题表news,答案使用答案表anwer,两表通过stid相关联,即news中的id与answer中的stid是一对多的关系,现在在答题页test.asp中每个答案的前面加一个radio,为了在处理页能顺利获得每道题提交的答案信息,这里的radio该如何设置它的id和name,一方面可以确保每道题可以做一个选择(因为是单选题),另一方面可以在处理页do.asp中顺利的把这些题的选择答案信息依次插入到答题表grade中去呢,我该在处理页do.asp中如何获得每道题的答案信息(试题号\试题类型\所得分)批量处理,插入到grade中去?该用数组还是变量呢?

我用以下代码来实现列出所有试题以及对应的答案,
<%
While ((Repeat1__numRows <> 0) AND (NOT cate.EOF))
%>
        <table width="750" height="80" border="0" align="center" cellpadding="5" cellspacing="0">
          <tr>
            <td colspan="2" valign="top" bgcolor="#EAEAEA"><%=(cate.Fields.Item("title").Value)%><strong><br>
              </strong><%= DoWhiteSpace(cate.Fields.Item("content").Value)%></td>
          </tr>
          <tr>
            <td width="85" valign="top" bgcolor="#CCCCCC"></td>
            <td width="645" height="1" valign="top" bgcolor="#CCCCCC"></td>
          </tr>
          <tr>
            <td valign="top" bgcolor="#FFFFFF"></td>
            <td height="1" valign="top" bgcolor="#FFFFFF"></td>
          </tr>
          <%
FilterParam=cate.Fields.Item("id").Value
subcate.Filter="stid="&FilterParam
While (NOT subcate.EOF)
%>
          <tr>
            <td height="10" colspan="2" valign="top" bgcolor="#FAFAFA"></td>
          </tr>
          <tr>
            <td valign="top" bgcolor="#FAFAFA"><div align="right">
                <input type="radio" name="id" id="radio<%=(subcate.Fields.Item("id").Value)%>" value="<%=(subcate.Fields.Item("id").Value)%>" onclick="document.form1.submit();javascript:location='do.asp'" <% if subcate.fields.item("selected").value=("1") then%> checked<% end if%>>
              </div></td>
            <td valign="top" bgcolor="#FAFAFA"><%=(subcate.Fields.Item("subject").Value)%>  <font color="#666666">
              <input name="stid" type="hidden" id="stid" value="<%=(subcate.Fields.Item("stid").Value)%>" size="4">
              <input name="score" type="hidden" id="score" value="<%=(subcate.Fields.Item("score").Value)%>" size="4">
              <input name="item" type="hidden" id="item" value="<%=(subcate.Fields.Item("item").Value)%>" size="4">
              <input name="class" type="hidden" id="class" value="<%=(subcate.Fields.Item("class").Value)%>" size="4">
              </font></td>
          </tr>
          <%
subcate.MoveNext()
Wend
%>
          <tr>
            <td height="10" colspan="2" valign="top" bgcolor="#FAFAFA"></td>
          </tr>
        </table>
        <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  cate.MoveNext()
Wend
%>
在对某题的答案进行选择,点它前面的单选按牛时把这个id棒定的值传递到处理页面,插入到grade表中,然后在返回这个页,但是有这样的问题存在:
整个页面就算对所有题进行了答案选择,也只有一个答案前的radio保持被选中的状态,该如何解决?
我想在这个答题页对所有试题进行了答案选择后才提交到处理页,在处理页进行这些答案的入表处理,那在提交页和处理页该分别如何实现?

试题类别表classlist的结构说明:
id          int
title       nvarchar 试题类别
depth       int
rootid      int
parent      int

试题表news
id          int           
title       nvachar         试题内容
class       int             试题类别,对应classlist中的id
tjnews      int             1为选择题,0为问答题
hotnews     int             试题期数

答案表answer
id          int
subject     nvachar         答案选项内容
stid        int             对应试题题号
score       decimal         本选项分值

答题记录表grade
id          int
username    nvarchar        答题人
stid        int             试题题号,对应news表中id
anid        int             选择项,对应amswer表中id,
score       decimal         本选择的得分
class       int             试题类别,对应classlist中id
item        int             试题期数,对应news表中hotnews

这个问题困绕我很久了,不知道该如何解决!

TOP

发新话题