#!/var/local/couch/bin/perl 
use CGI qw/:standard/;
&header;
open (FILE, "quiz.txt");
@quiz_info = <FILE>;
close (FILE);
print "Name:<br>\n";  
$numQuestions= $quiz_info[0];
$form = CGI::new();
print $form->startform(-action=>'quizscore.cgi', -method=>'POST');
print $form->textfield(-name=>'Name', -size=>'20');
for ($i=0;$i<$numQuestions;$i++)
{
  $question = $quiz_info[$i * 6 + 1];
  $option1 = $quiz_info[$i * 6 + 2];
  $option2 = $quiz_info[$i * 6 + 3];
  $option3 = $quiz_info[$i * 6 + 4];
  $option4 = $quiz_info[$i * 6 + 5];
  $option5 = $quiz_info[$i * 6 + 6];
  @values = ("a", "b", "c", "d", "e");
  %labels = ("a"=>$option1, "b"=>$option2, "c"=>$option3, "d"=>$option4, "e"=>$option5);
  print "<p> $question <br>\n";
  print $form->radio_group(-name=>"question$i", -values=>\@values, -labels=>\%labels);
 }
 print $form->submit();
 print $form->reset();
 print $form->endform();
 &footer;
 exit(0);
 
 sub header
 {# print the header for the HTML page
    print "Content-type: text/html", "\n\n";
    print "<HTML><HEAD><TITLE></TITLE></HEAD>\n";
    print "<BODY BGCOLOR = 'red' text = 'black'>\n";
}

 sub footer
 {# print the footer for the html page
   print "</BODY></HTML>";
}
