Protoype Question With Help on Wrong Student Answer
Notice that there is only one line changed here, relative to the
original prototype.
#!/usr/local/bin/perl -- -*- C -*-
use CGI;
$query = new CGI;
print $query->header;
print $query->start_html("q1.pl, Help Example");
print $query->start_form;
$ans = 5280;
print "<P> How many feet are there in a mile?",
$query->textfield('stu_ans','',10,30);
print "<P> Is the above answer correct?",$query->submit("Send Answer in For Grading");
print $query->reset;
print $query->end_form;
$returned_ans = $query->param('stu_ans');
if ( $query->param('stu_ans') ne '')
{
print "<em>Student_answer, </em>$returned_ans";
$returned_ans =~ s/\\//gi;
$returned_ans =~ s/\$//gi;
$returned_ans =~ s/\#//gi;
$returned_ans =~ s/\~//gi;
$stu_ans = eval($returned_ans);
if ( (($stu_ans - $ans)**2 ) ge 0.01 )
{print "<em>, was WRONG!</EM>
<a href=./q1_help.pl> Do you want help?</a>
<IMG SRC=../icons/checkno.gif>"}
else {print "<em>, was RIGHT! </EM>
<IMG SRC=../icons/check.gif>"};
};
print $query->end_html;
and that line is:
<a href=./q1_help.pl> Do you want help?</a>
which is in the WRONG side of the IF statement.
This is a `hot-link' to another Perl program, `q1_help.pl' which contains
whatever message you want it to contain.
Here is our help file:
#!/usr/local/bin/perl -- -*- C -*-
use CGI;
$query = new CGI;
print $query->header;
print $query->start_html("q1.pl, Help Example");
print "There are 5,280 feet in one mile";
print "<br><a href=./q1.pl>Back to Original Question</a>";
print $query->end_html;
Click Here to see how this works
and don't forget to input a WRONG answer.