http://www.perlmonks.org?node_id=312723

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Simple Quiz Maker (yet again)
by shockme (Chaplain) on Dec 06, 2003 at 04:44 UTC
    Referencing this node, this node, and this node, it looks as though you received some very good feedback, but have provided very little regarding any further attempts.

    What does your code look like now, and what specific problems are you experiencing? What have you learned thus far? Given the quality replies you have been given, combined with the minimal feedback on your part, I'm afraid you're going to find that this 4th thread receives very little attention.

    Perhaps you should spend a little time focusing on the resources given in the prior responses. Once you've digested that, the "direness" of your request should diminish considerably.

    Update: Made links more site-friendly and added a little whomp-ass.

    If things get any worse, I'll have to ask you to stop helping me.
Re: Simple Quiz Maker (yet again)
by duff (Parson) on Dec 06, 2003 at 05:07 UTC

    Let me try to give you some ideas ...

    It seems that you want your program to do at least 4 things:

    1. Create a quiz,
    2. store it some where
    3. let someone take a stored quiz, and
    4. display the results
    so make up a parameter (probably hidden) that gets passed to your CGI program that tells it what action you intend. Maybe even call that parameter "action". Then the main part of your program could look something like this:

    #!/usr/bin/perl use CGI qw(:standard); my $action = param('action'); $action ||= 'TakeQuiz'; if ($action eq 'CreateQuiz') { CreateQuiz(); } elsif ($action eq 'StoreQuiz' ) { StoreQuiz(); } elsif ($action eq 'ShowResults') { ShowResults(); } else { TakeQuiz(); } # default action exit;

    CreateQuiz() would present the user with a form that allows them to enter questions and answers (much the same as the code you currently have). A hidden action parameter on this form would have a value of "StoreQuiz" so that the StoreQuiz() routine can be called when you submit the form. StoreQuiz() would put the results in a file or a database or something for retrieval later. When you want to take the quiz, don't provide an action parameter and let it execute the default TakeQuiz() routine. This routine would read from where ever you stored the questions and answers and display the questions for the user to answer. A hidden parameter named "action" would be set to 'ShowResults' so that when they submitted the form, it would execut the ShowResults() routine. The ShowResults() routine would read from where ever you have the questions and answers stored, read the form data that was submitted, and produce a report that shows the user's answers and the correct answers.

    That's a rough design outline (primitive but workable). Now as far as implementing this stuff, just read the documentation for the CGI module. It's got nifty routines for saving form data to and retrieving it from files. And obviously it's got routines for reading the form data submitted by the user.

A reply falls below the community's threshold of quality. You may see it by logging in.