As requested, I ran perltidy on my script to see if I could make it  easier for 
somebody else to read. Perhaps a little explanation of how it  works would also 
be helpful:

Tutorial.cgi is triggered by a user  who wishes to enlarge his/her vocabulary 
of 
technical terms in a  certain field. The user sees an .html file that gives him 
a way to  select any of several categories for review, or to select a review 
that  includes all categories at once. The SEND button addresses the script  
with a line including CATEGORY=, which signals that this is a new  tutorial so 
the script doesn't look for cookies. The script reads a  database containing 
hundreds of terms with their associated categories,  definitions, and 
vignettes. 
Using this info, the script composes a  simple multiple choice question, 
composes a web page  on the fly, and sends this back to the user. It also sets 
several  cookies containing the state of the tutorial. It should then run out 
of  
instructions and die.

The user clicks on a button ("A" or "B"),  which fires back a string that 
reawakens the script and shows it what  answer the user chose. The script 
inspects the cooky-jar to determine  the state of the script, compares the 
user's selection with its  expectation, and fires back one of two new web 
pages. 
If the user chose  the right answer, he gets congratulations and a new problem. 
If it was a  wrong answer, he gets a correction, which includes the correct 
term,  definition, vignette, and a sound-file with pronunciation of the term.  
Then the user has to click to continue the tutorial. That click sends a  string 
that re-awakens the script and cues it to send a new question.

The  state of the tutorial includes a score that reflects the user's  
cumulative 
progress on the tutorial. As the score  mounts, the script progressively 
increases the difficulty of the  questions. At the highest difficulty level, 
the 
user has to read either  the definition or the vignette and respond by typing 
the correct term in  a text box. There is no real endpoint to the tutorial: the 
user decides  when he has had enough. Any given tutorial can be interrupted and 
 
resumed within 24 hours, after which the cookies expire.

To avoid  repetition of previous discussions, let me remind everybody that this 
 
script works perfectly every time as far as I can tell. That is to say,  it 
never hangs and always gives the expected result. Also, with all the  
error-checking turned on, no error appears on the server log. The  mysterious 
problem is that the script apparently doesn't terminate as  expected. Although 
opportunities for mischief abound in any 500-line  script, they all appear 
BEFORE the output stage. Since the output is as  expected, I'm having trouble 
imagining what would cause  the script to fail to terminate.

I'm sure this script isn't up  to professional standards, and becoming an IT 
professional is not among  my ambitions. I'm offering the script free to users 
as a public service,  and I just want to find a way to do that without crashing 
Hostmonster's  servers. Your assistance will be sincerely appreciated.

Script follows in part 2 because of space limitations.

 John M Rathbun MD

Reply via email to