In article <#s**************@tk2msftngp13.phx.gbl>,
SP******************@inspire.net.nz says...
There are a number of ways you could do this. I used to separate out the
form page and the processor page because it seemed to keep the code more
distinct. Now I tend to post a form back to itself and then do whatever
validation or processing is necessary before Response.Redirecting to the
next page in the workflow. It's easier than having to come back to the form
page after doing the s-side validation in a separate processor script.
As an old real-time embedded software kind of guy, I attack this problem
as a classic state machine. It requires adding "state" and "event"
hidden variables to each displayed page, but I've found it to be pretty
robust.
The traditional "loop forever" construct is replaced by the
"request/response" mechanism.
I've built some fairly complex processing procedures around a construct
like this:
'~~~~~~~~~~~~~~~~~<State Variable Initialization>~~~~~~~~~~~~~~~~~~
'If these are null then it means we got here from outside the
'Test universe. We will count on the "else" cases in our
'Select statements to fill in the default.
myState = request("state")
myEvent = request("event")
'~~~~~~~~~~~~~~~~~~~~~~~Main Code Starts Here~~~~~~~~~~~~~~~~~~~~~~
' This is a state machine that processes the events:
' Done - User is done with test subsystem
' TakeTest - Take the test
' ViewTest - Look at the test (admin/instructor)
' GradeTest - Score the test
' Cancel - Back out of the current state
' Default - Initialization or an unknown event
'
' With respect to the following states:
' DisplayingGrade - Test grade is being displayed
' GradingTest - Processing student responses
' Opening - Are you sure you want to take this test?
' TakingTest - Student is taking the test
' ViewingTest - Admin/instructor is reviewing the test
'
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~ States ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
select case myEvent
case "Cancel"
Call returnToOpenpage(user.UserType)
case "Done"
Call returnToOpenpage(user.UserType)
case "TakeTest"
Select Case myState
Case "Opening"
Call testGiver(testId, user)
Case "DisplayingGrade"
Call returnToOpenpage(user.UserType)
Case Else
Call testAborted()
End Select
....
case else
Select Case myState
Case "Opening"
Call displayOpening(user)
Case Else
if initializeTest(testId) = False then
Response.Redirect("error.asp")
End If
Call displayOpening(user)
End Select
End Select