write form html from script

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
cago_post
Guest





PostPosted: Sat Jan 11, 2003 5:31 pm    Post subject: write form html from script Reply with quote

i have the following in html file


QUIZ.HTML
QUESTION NUMBER 2...<BR>
<INPUT TYPE="hidden" NAME="Q2" VALUE="QUESTION_NUMBER_2"><BR>
<INPUT TYPE=RADIO NAME="Q2" VALUE="Q2A">an answerl<BR>
<INPUT TYPE=RADIO NAME="Q2" VALUE="Q2B">an answer<BR>
<INPUT TYPE=RADIO NAME="Q2" VALUE="Q2C">an answer<br>


POST.CGI
this is in cgi script
print FILE "$FORM{'Q_1'}<P>\n";
if ($FORM{'correct'}) {
print FILE "CORRECT ANSWER\n";
}
if ($FORM{'wrong'}) {
print FILE "SORRY<br>\n";
print FILE "CORRECT ANSWER IS MIKE\n";
}

the cgi works for all other print FILE but the question which is hidden and the choice which user clicks on will not write to the file

ANSWER.HTML
the print FILE to html needs to be like this:

QUESTION 2 (printed to file)
SORRY (sorry printed to file)
CORRECT ANSWER IS MIKE (correct answer printed to file)


i am creating a quiz for students, when that take quiz, the answer they choose are written to a report card.html file so they can see the report card when they do the quiz.


any ideas? here
Back to top
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Jan 12, 2003 1:44 am    Post subject: Re: write form html from script Reply with quote

Have you initialized the CGI library correctly? Can you send us a more complete sample of your script and its related quiz HTML files so that we can check with you what's wrong?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
cago_post
Guest





PostPosted: Sun Jan 12, 2003 2:19 pm    Post subject: more information on script Reply with quote

i have it working kinda....

this script is an add bookmark pl script that i have changes and added so that it will do the quiz instead of creating a add bookmarks it writes to reportcard.html file for student test that they take, but i have to write eight test.html pages and use eight test.pl files, one for each test. can a standard test.pl be used? I would like a eight or ten lessons, but only use one test.pl script to write to reportcard.html.

You can see a working example here that I now have one done.

http://www.cvb.dns2go.com/gandm/school/bible/main.html




this is the html quesion layout: which i can change if one test.pl file can be used.


test.html (file)
<INPUT TYPE="hidden" NAME="QUIZ_2" VALUE=""><BR>
<DL>
<DT>1. question<BR>
<DD><INPUT TYPE="hidden" NAME="Q_1" VALUE="question"><BR>
<DD><INPUT TYPE=RADIO NAME="Q1A" VALUE="Q1A">answer <BR>
<DD><INPUT TYPE=RADIO NAME="Q1B" VALUE="Q1B">answer<BR>
<DD><INPUT TYPE=RADIO NAME="Q1C" VALUE="Q1C">amswer<BR>
</DL>

this is pl script: (addentry.html) it is a add bookmark script that i changed to fit and create and write to the reportcard.html file.

if ($FORM{'Q1A'}) {
print FILE "<font face=\"$font_face\" size=1>CORRECT ANSWER<br></FONT><p>\n";
}
if ($FORM{'Q1B'}) {
print FILE "<font face=\"$font_face\" size=1>SORRY<br>\n";
print FILE "<font face=\"$font_face\" size=1>CORRECT ANSWER IS </FONT><P>\n";
}
if ($FORM{'Q1C'}) {
print FILE "<font face=\"$font_face\" size=1>SORRY<br>\n";
print FILE "<font face=\"$font_face\" size=1>CORRECT ANSWER IS </FONT><P>\n";
}


I have this so it will work but it is double entry work.

this will write to file reportcard.html correctly but is their a way to make so
that pl script can be used in more then one quiz?

as in the test.html the class has eight lessons, so can the same pl script be used in a standard format for all lessons, as a lesson is taken, test1.html, then write to reportcard.html, then when test2.html taken write to reportcard.html

i need a standard so that same test.pl script when used will work and show correct answer or wrong answer and then show correct answer and write to reportcard.html file


at the present i have to create eight test.html files and eight addentry.pl files for this to work.
Back to top
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Jan 13, 2003 12:21 am    Post subject: Re: more information on script Reply with quote

Hmmm, seems that it is a programming question.
OK, we'll give just one idea. Create a table in Perl where you store the questions, theirs possible answers, and the correct answer. Then write a script that displays a page asking a question and providing all the possibilities. When the user answers, another script is invoked and it will test the validity of the answer. This can be even done by combining the two scripts in one and without even using separate HTML files containing the forms (they can be generated dynamically by the script.)

This is only a suggestion :D
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group