<%@ Language=VBScript %>
<%option explicit
%><!-- #INCLUDE FILE = "connect_ama.asp" --><%
dim myrs
set myrs = server.createobject("ADODB.recordset")
myrs.open "select * from all_exams where ExamName ='" & Request.Form ("start") & "'" ,myconn
''''''''''''''''''''''''''''''''''''''''''''''''''
dim q_id1, q_id2, code, totaltime, ppercent, totalq, expire, examname
q_id1 = myrs("sq_id")
q_id2 = myrs("eq_id")
totaltime = myrs("totalTime")
totalq = myrs("totalQuestions")
examname = myrs("ExamName")
ppercent = myrs("ppercentage")
code = myrs("code")
expire = myrs("expireDate")
myrs.Close
session("totalquestions")=totalq
''''''''''''''''''''''''''''''
myrs.open "select * from q_bank where q_id between " & q_id1 & " and " & q_id2 ,myconn,3
'3=adOpenStatic,then only myrs.recordcount will work
''''''''''''''''''''''''''''''
dim totalrec
totalrec = myrs.RecordCount
session.Contents("ExamName")=Request.Form ("start")
'Response.Cookies("totaltime")= cstr(totaltime)
'if myrs.Fields("ExpireDate") < Date then
'Response.Write "<h5>EXPIRED ''''''''<H5>"
'end if
' Response.Write "total time=" & totaltime & "<hr> total q=" & totalq & "<hr> total rec=" & totalrec &"<hr>"
Dim num(),k,i,x,j,ans()
redim num (totalq)
redim ans (totalq)
k = 1
Randomize
For i = 1 To totalq
x = Round(Rnd * totalrec)
'give record count
For j = 1 To k
If num(j) = x Then
i = i - 1
Exit For
End If
Next
If j > k Then
num(k) = x
k = k + 1
End If
Next
'''''''''''''''''''''''''''''''''''
for i=1 to totalq
ans(i)="Not Attempted"
'Response.Write i & " | " &num(i)& " | "
myrs.MoveFirst
myrs.Move num(i)-1
num(i)=myrs("q_id")
'Response.Write num(i) & " |<br> "
Next
Session("Questions")=num
Session("Answers")=ans
Session("Counter")=1
Session("examover")=0
Session ("examname")= examname
Session("ppercentage")= ppercent
'''''''''''''''''''''''''''''''''
'closing order important'''''''''
myrs.close
myconn.close
set myconn=nothing
set myrs=nothing
'''''''''''''''''''''''''''''''''
'Response.Redirect "exam_paper.asp"
Response.Cookies(examname & "totaltime")= cstr(totaltime)
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<form name=examform action="exam_paper.asp" method=post>
<input type=hidden name=qno value=1>
<input type=hidden name=totalq value=<%=totalq%>>
</form>
<script language="JavaScript">
document.examform.submit()
</script>
</BODY>
</HTML>