#!/usr/bin/perl ##################################################### # Script by MP.Prakash R.Lewis # # http://www.bestnetcraft.com # # This script is offered in the same terms as Perl. # # Comments and suggestions may be sent through # # http://www.bestnetcraft.com/contact.html # # No liability or damage will be accepted by the # # author under any circumstances. # ##################################################### # Check out the Readme File # Version 2 : Integrated module # needs external questions-answers text # Q & A text file's name needs to be passes as the query_string # set up a 12 element array using raw.pl and invoke this script passing the text name # as query_string # For a working example - check out : http://www.bestnetcraft.com/resource.html # Configuration - User defined variables $pro="quest.cgi"; $lin=1; $debug=0; $envy= $ENV{'QUERY_STRING'}; #parse the form read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split(/=/,$item,2); $content=~tr/+/ /; $content=~s/%(..)/pack("c",hex($1))/ge; $content =~ s///g; $fields{$key}=$content; $i++; $item{$i}=$key; $response{$i}=$content; } $envy =($envy ?$envy:$fields{'what'}); &nyet unless $envy; $marks =($fields{'total'}?$fields{'total'}:0); #&nyet unless $fields{'action'}; if ($fields{'action'} eq "indi") {&quest1;} &quest1 unless $fields{'action'}; #beginning of subs sub quest1 { print "Content-type: text/html\n\n"; print <Bestnetcraft -Test your Knowledge

eof if ($fields{'ans'} =~/correct/i) {$marks++;} $no=($fields{'number'}?$fields{'number'}:0); if ($debug eq "1") { print "Requested file: $envy
"; print " Question is :$ele[1]
"; print "Answer is : $fields{'ans'}
"; print "Number of Question: $no
"; print "marks scored is : $marks
"; } if ($fields{'ans'} ne "") {$no++;} print "Total Marks scored in this test : $marks

"; my $per=(($marks/31)*100); my $perc=sprintf "%.2f",$per; if ($perc >=75){ print < Please take a moment to fill up this form to help serve you better.

endo } #processing the input data open (FILE, $envy) || &nyet; if ($lin ==1){flock FILE, 2;} @data =; if ($lin ==1){flock FILE, 8;} close (FILE); $number =$#data; for ($i=0 ; $i<=$number ; $i++) { @ele = split(/\|/,@data[$i]); if ($ele[0] == $no){ #printing part print <Question $no : $ele[1]

$ele[2]

$ele[3]

eof if ($ele[10] == 4) { print <$ele[4]

$ele[5]

eof } print <

Finish the Test


© 2000/2001 Bestnetcraft.com.
eof last; } } } sub nyet { print "Content-type: text/html\n\n"; print < Bestnetcraft - Test your Knowledge

Quiz from Bestnetcraft.com


Bestnetcraft for Total web solutions

Finecrafts of the Net. For more of free CGI/Perl/server scripts click on the name "Bestnetcraft".

Note: The next few pages will take you through a series of questions. This is an Online Question- Answer Session. You have a running score visible always at the top. There is no time limit to this test. If you have succesfully completed this test you can move on to another test. Please complete the form at the end of the test which will enable us to serve you better.


© 2000/2001 Bestnetcraft.com. All rights Reserved.
eof exit; }