#!/usr/local/bin/perl -wT use strict; my $template_file="../go/class/quiz/quiz.tmpl"; my $quiz_data_file="./quizes/70-215-1.txt"; #********** # quiz.pl # dan@ltc.org #********** use CGI; my $q=new CGI; print $q->header(); open(FH,$quiz_data_file) or die"$! couldn't open quiz.txt\n"; my @lines=; close(FH) or die"$! couldn't close quiz.txt"; my @quiz=(); my @answers=(); my $question_count=0; my $numElements=0; for ($question_count=0;$question_count<@lines;$question_count++){ my @fields=split('\t',$lines[$question_count]); my $a={}; #answer $numElements+=(@fields-2); $a->{'answer'}=shift(@fields); $a->{'answer_id'}='"q'.$question_count.'"'; push @answers,$a; my $q={}; #question $q->{'question'}=shift(@fields); $q->{'image_name'}="q$question_count".'_image'; my $choice_count=0; my $c=[]; my $letter='a'; while(@fields){ my $choice_items={}; $choice_items->{'choice_name'}="q$question_count"; $choice_items->{'choice_value'}=$letter++; $choice_items->{'choice_text'}=shift(@fields); push (@$c,$choice_items); } $q->{choices}=$c; push @quiz,$q; } use HTML::Template; my $t=HTML::Template->new(filename=>$template_file); $t->param(QUIZ=>\@quiz); $t->param(ANSWERS=>\@answers); $t->param(numElements=>$numElements, numQues=>$question_count); print $t->output(); #################################################### #################################################### Quiz
  1. " align="top">
    1. " value="">

Score =

################################################ ################################################ // dan@ltc.org // quiz.js // // Except for the bits that change the image // and the bits that allow variable number of // choices, this script is lifted straight from // from Charity Kahn's builder.com // quizbuilder script. var wrongImage = new Image(78,26); wrongImage.src = "/go/class/quiz/wrong.gif" var blankImage = new Image(78,26); blankImage.src = "/go/class/quiz/blank.gif" function getScore(form) { var score = 0; var c; var imageName; var prev=0; var cur=0; var isBlank; while(cur