#!/usr/bin/perl use strict; use CGI qw/:standard *table/; use CGI::Carp; my $qdata = '/vol/www/oefiles/quiz'; my $qhtml = '/vol/www/oefiles/data/quiz'; my $cgi = CGI->new(); my $quiz = $cgi->param('quiz') || 'quiz1'; open(QZ, "$qdata/$quiz/questions.txt"); print header, start_html(-title=>'Movie Quiz', -script=>{-language=>'JAVASCRIPT', -src=>'/quiz/quiz.js'}, -style=>'/quiz/quiz.css', -onLoad=>"gettotal('$quiz')"); while (my $line = ) { my ($id, @items) = split('::', $line); if ($id =~ /^q\d+$/) { my ($pic, $solution) = @items; print start_form(-onSubmit=>"return check('$quiz','$id')",-action=>''); print img({src=>"/quiz/$quiz/$pic", class=>'snap'}); print textfield(-id=>$id, -size=>50); print end_form; } elsif ($id eq 'h1') { my ($text) = @items; print h1($text); } elsif ($id eq 'h2') { my ($text) = @items; print h2($text); } elsif ($id eq 'p') { my ($text) = @items; print p($text); } } print end_table; print div({-id=>'score'},'Correct answers:', span({-id=>'correct'},0),' of ', span({-id=>'total'},0)); print end_html;