Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HTML
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="include/test_connect.asp" -->
<%
Query = "select * FROM questions WHERE test_name = '" + Request.QueryString("test") + "'"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open Query, test_connector, 3, 3
  questions_total=0
  While (Not RS.EOF)
    questions_total = questions_total + 1
    RS.MoveNext
  Wend

  ' reset the cursor to the beginning
  If (RS.CursorType > 0) Then
    RS.MoveFirst
  Else
    RS.Requery
  End If
%>
<html>
<head>
<title>Questions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="aliceblue">
<table width="100%">
  <tr> 
    <td height="520" valign="top"><!--#include file="test_menu.asp" --><br>
    </br></td>
	<td width="100%" valign="top"><table width="100%">
        <tr>
          <td width="100%" height="520" valign="top">
<div align="center"><br>
  <table width="80%">
    <form name="form1" method="post" action="<%= "test_grade.asp?test=" & Request.QueryString("test") & "&questions=" &  Request.QueryString("questions")%>">
      <% 
             
While (NOT RS.EOF) 
qnum = qnum + 1
answer_num = 0
if RS.Fields.Item("a1").Value = true then
   answer_num = answer_num + 1
end if
if RS.Fields.Item("a2").Value = true then
   answer_num = answer_num + 1
end if
if RS.Fields.Item("a3").Value = true then
   answer_num = answer_num + 1
end if
if RS.Fields.Item("a4").Value = true then
   answer_num = answer_num + 1
end if
if RS.Fields.Item("a5").Value = true then
   answer_num = answer_num + 1
end if
%>
<% If answer_num < 2 then %>
      <tr> 
        <td>
          <%=( qnum & ") " & RS.Fields.Item("question").Value)%></td>
      </tr>
      <% if not (RS.Fields.Item("answer1").Value = "n/a") then %>
      <tr> 
        <td>A) 
            <input type="radio" name="<%= "question" & (RS.Fields.Item("id").Value) %>" value="<%= "question" & (RS.Fields.Item("id").Value) & "a" %>">
            <%=(RS.Fields.Item("answer1").Value)%> 
            <% 'if (RS.Fields.Item("a1").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer2").Value = "n/a") then %>
      <tr> 
        <td>B) 
            <input type="radio" name="<%= "question" & (RS.Fields.Item("id").Value) %>" value="<%= "question" & (RS.Fields.Item("id").Value) & "b" %>">
            <%=(RS.Fields.Item("answer2").Value)%> 
            <% 'if (RS.Fields.Item("a2").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer3").Value = "n/a") then %>
      <tr> 
        <td>C) 
            <input type="radio" name="<%= "question" & (RS.Fields.Item("id").Value) %>" value="<%= "question" & (RS.Fields.Item("id").Value) & "c" %>">
            <%=(RS.Fields.Item("answer3").Value)%> 
            <%'if (RS.Fields.Item("a3").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer4").Value = "n/a") then %>
      <tr> 
        <td>D) 
            <input type="radio" name="<%= "question" & (RS.Fields.Item("id").Value) %>" value="<%= "question" & (RS.Fields.Item("id").Value) & "d" %>">
            <%=(RS.Fields.Item("answer4").Value)%> 
            <% 'if (RS.Fields.Item("a4").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer5").Value = "n/a") then %>
      <tr> 
        <td> <p>
          E) 
            <input type="radio" name="<%= "question" & (RS.Fields.Item("id").Value) %>" value="<%= "question" & (RS.Fields.Item("id").Value) & "e" %>">
            <%=(RS.Fields.Item("answer5").Value)%> 
            <% 'if (RS.Fields.Item("a5").Value) then Response.Write(" (correct)")%>
            </p></td>
      </tr>
      <% end if %>
      <tr> 
        <td> <p> </p></td>
      </tr>
<% 
else %>
      <tr> 
        <td>
          <%=( qnum & ") " & RS.Fields.Item("question").Value)%></td>
      </tr>
      <% if not (RS.Fields.Item("answer1").Value = "n/a") then %>
      <tr> 
        <td>A) 
            <input type="checkbox" name="<%= "question" & (RS.Fields.Item("id").Value) & "a" %>" value="True">
            <%=(RS.Fields.Item("answer1").Value)%> 
            <% 'if (RS.Fields.Item("a1").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer2").Value = "n/a") then %>
      <tr> 
        <td>B) 
            <input type="checkbox" name="<%= "question" & (RS.Fields.Item("id").Value) & "b" %>" value="True">
            <%=(RS.Fields.Item("answer2").Value)%> 
            <% 'if (RS.Fields.Item("a2").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer3").Value = "n/a") then %>
      <tr> 
        <td>C) 
            <input type="checkbox" name="<%= "question" & (RS.Fields.Item("id").Value) & "c" %>" value="True">
            <%=(RS.Fields.Item("answer3").Value)%> 
            <%'if (RS.Fields.Item("a3").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer4").Value = "n/a") then %>
      <tr> 
        <td>D) 
            <input type="checkbox" name="<%= "question" & (RS.Fields.Item("id").Value) & "d" %>" value="True">
            <%=(RS.Fields.Item("answer4").Value)%> 
            <% 'if (RS.Fields.Item("a4").Value) then Response.Write(" (correct)")%>
          </td>
      </tr>
      <% end if %>
      <% if not (RS.Fields.Item("answer5").Value = "n/a") then %>
      <tr> 
        <td> <p>
          E) 
            <input type="checkbox" name="<%= "question" & (RS.Fields.Item("id").Value) & "e" %>" value="True">
            <%=(RS.Fields.Item("answer5").Value)%> 
            <%' if (RS.Fields.Item("a5").Value) then Response.Write(" (correct)")%></p>
            </td>
      </tr>
      <% end if %>
      <tr> 
        <td> <p> </p></td>
      </tr> <%
end if
  RS.MoveNext()

Wend
%>
      <tr> 
        <td><input type="submit" name="Submit" value="Grade Test"></td>
      </tr>
      <input type="hidden" name="test_to_take" value=" ">
    </form>
  </table>
</br></div></td></tr></table></td></tr></table>
</body>
</html>
<%
RS.Close()
%><!--#include file="test_close.asp" -->
Posted
Updated 6-Sep-11 2:20am
v2
Comments
LittleYellowBird 6-Sep-11 8:40am    
I think you need to add more information. You have explained, a little, what you want to do but not why you are having a problem doing it.
sathish659341 9-Sep-11 7:25am    
Dear Sir,
on the particular page - all question to display in single page, now the requirement is one question on one page/per min than click next button togo to next page/next question. On the particular page only check box and radio option only but the requirement is also text box for short answer.
Thank for the replay and please help me on the online exam project please

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900