#!/usr/bin/perl use strict; ## ## REVISION HISTORY ## M. Gage (Rochester) and W.K. Ziemer (CSULB) Dec. 1999 ## M. Gage (Rochester) and A. Pizer (Rochester) Apr. 2000 ## ## ## This script parses results generated by the questionnaire_spring00.pg and summarizes them ## into an excel file and an essay file. Further it creates an html file which reproduces the ## original questionnaire together with a histogram of the results for each question. Each ## question is followed by a sumary of the responses to that question. The orginal files have ## the format described at the end of this file. ## The the required inputs are the html source of the questionnaire, a file containing all the ## email responses concatenated into one file, and a base file name [e.g. foo] (without an extension) ## for the three output files [the three output files will be e.g. foo.html, foo.xls, and foo.txt]. ## Usually this data will be kept on a course by course basis so all email esponses from a single ## course should be saved in one file. my ($questionnaire,$filename,@data,%results,$question,$numeric,$standardOutput,$ans0,$ans1,$ans2,$ans3,$ans4,$ans5,$ans6,$ans7,$ans8); my ($in, $psvn, $question_number, %question_response, %essay_response, $inpath); if(@ARGV==3){ $questionnaire = $ARGV[0]; $inpath = $ARGV[1]; $filename = $ARGV[2]; }else{ print "\nNote: the following items can be supplied as command line arguments.\n"; print "\nQuestionnaire HTML file is: "; chomp($questionnaire = ); print "\nFile of email responses to questionnaire.pg is: "; chomp($inpath = ); print "\nYou need to enter base file name (without an extension) to use for the output files.\n"; print " For example, if the base file name is MTH100_results, the output files will be\n"; print " MTH100_results.html, MTH100_results.xls, and MTH100_results.txt\n"; print "Enter the base file name: "; chomp($filename = ); }; my $outfile = "$filename".'.html'; ## html file summarizing non essay responses my $outpath1 = "$filename".'.xls'; ## tab delimited file of non essay responses my $outpath2 = "$filename".'.txt'; ## essay responses (questions 27, 28, 29) open(STDIN, "<$inpath") or die "Can't read file at: $inpath"; print "Reading input from $inpath\n"; my $counter=0; my %psvn_hash = (); my %histogram = (); while (<>) { $in = $_; # skip blank lines next unless $in =~ /\S/; # skip other lines next if $in =~/Delivered-To|To|X-Remote-Host|Subject|Date|From/; if ( $in =~ /^\s*(\d+)\-Problem\-\d\-Question\-([^\:]+):/ ) { $psvn = $1; $question_number = $2; $psvn_hash{$psvn}++; $counter++; } else { # text line chomp($in); if ( $question_number =~/27|28|29/ ) { # essay responses are accumulated $essay_response{"$psvn - $question_number"} .= $in; } else { # a new record entry is defined, unless a non-blank one has already been defined. # this means that the first non-blank or non-zero response is recorded. $question_response{"$psvn - $question_number"} = $in unless defined($question_response{"$psvn - $question_number"} and $question_response{"$psvn - $question_number"} =~ /\S/); } } } print "\n\n$counter Questions processed "; print "from ",scalar(keys %psvn_hash), " students\n"; open(OUT1, ">$outpath1") or die "Can't write to file at: $outpath1"; open(OUT2, ">$outpath2") or die "Can't write to file at: $outpath2"; print "Excel output sent to file $outpath1\n"; print "Essay questions sent to file $outpath2\n"; my ($key, $key1, $line,%count); # This is the list of question numbers in the order you want them printed out to the tab separated Excel file. my @key_list = qw ( A B C D D1 E E1 F F1 G G1 H H1 I J K K1 L M N O P P1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29); # Print the header for the excel file; print OUT1 "\t",join("\t",@key_list ),"\tnumber of replies", "\n"; foreach my $key (sort keys %psvn_hash ) { print OUT1 "$key\t"; # print the psvn key foreach my $key2 ( @key_list ) { print OUT1 $question_response{"$key - $key2"} if defined $question_response{"$key - $key2"}; print OUT1 "\t"; if ($question_response{"$key - $key2"} =~ /[0-9]+/){ ${$histogram{$key2}}[$question_response{"$key - $key2"}]++; $count{$key2}++; }; } print OUT1 "$psvn_hash{$key}\n"; # record the number of responses } foreach my $key2 ( @key_list ) { if ( defined $histogram{$key2}) { my $i=0; while( @{$histogram{$key2}} ){ $results{$key2}[$i++]=sprintf("%.1f",shift(@{$histogram{$key2}})/$count{$key2}*100); }; }; }; my @questions = qw (27 28 29); foreach my $key2 (@questions) { print OUT2 "\n\nQuestion: $key2\n\n"; foreach my $key (sort keys %psvn_hash ) { print OUT2 "psvn:$key\n\t"; print OUT2 $essay_response{"$key - $key2"} if defined $essay_response{"$key - $key2"}; print OUT2 "\n"; } } print "Questionnaire processed\n"; print "\nMaking $outfile...\n"; open(QUESTIONNAIRE, "<$questionnaire")||die "Can't read questionnaire $questionnaire, $!"; open(OUT, ">$outfile")||die "Can't write to $outfile, $!"; while(){ $line =$_; print OUT $line unless $line =~ /^


/; if($line =~ /^([A-Z])\./){$question = $1}; if($line =~ /^(\d+)\./){$numeric = $1}; next unless ($line =~ /^


/ or $line =~ /^\d+\./); if ($line =~ /^


/) { ($ans0, $ans1, $ans2, $ans3, $ans4, $ans5,$ans6,$ans7,$ans8) = @{$results{$question}}; $standardOutput = select OUT; # switch default output file handle to OUT $~ = "LETTEROUT"; # switch format for OUT to LETTEROUT write; print "\n


\n"; $~ = "OUT"; # restore to original format select($standardOutput); # restore original default file handle for output }elsif($numeric < 27){ ($ans0, $ans1, $ans2, $ans3, $ans4, $ans5) = @{$results{$numeric}}; print OUT "\n\n"; $standardOutput = select OUT; #switch default output file handle to OUT $~ = "NUMERICOUT"; # switch format for OUT to NUMERICOUT write; $~ = "OUT"; # restore format for OUT select($standardOutput); # restore default file handle for output }; }; close(QUESTIONNAIRE)||die "Can't close questionnaire $questionnaire, $!"; close(OUT)||die "Can't close the output file $outfile, $!"; print "Done\n"; format LETTEROUT = $ans1 $ans2 $ans3 $ans4 $ans5 $ans6 $ans7 $ans8 $ans0
Answer Percent
A @>>>
B @>>>
C @>>>
D @>>>
E @>>>
F @>>>
G @>>>
H @>>>
Other @>>>
. format NUMERICOUT = $ans5 $ans4 $ans3 $ans2 $ans1 $ans0
Answer Percent
5 @>>>
4 @>>>
3 @>>>
2 @>>>
1 @>>>
0 @>>>
. #Format being read: #Delivered-To: apizer@math.rochester.edu #Return-Path: webmaster@math.rochester.edu #Received: from webwork.math.rochester.edu (webwork.math.rochester.edu [128.151.231.2]) # by mail.math.rochester.edu (Postfix) with ESMTP id 4F17BB084 # for ; Fri, 14 Apr 2000 22:58:20 -0400 (EDT) #To: apizer@math.rochester.edu #X-Remote-Host: unknown host(128.151.239.38) #Subject: mth162 WeBWorK questionnaire #Message-Id: <20000415025820.4F17BB084@mail.math.rochester.edu> #Date: Fri, 14 Apr 2000 22:58:20 -0400 (EDT) #From: webmaster@math.rochester.edu #X-UIDL: 74188716e2fe2da6437961fc3b5a5636 # # # #64123-Problem-1-Question-A: # 7 #64123-Problem-1-Question-B: # 2 #64123-Problem-1-Question-C: # 1 #64123-Problem-1-Question-D: # 5 #64123-Problem-1-Question-D1: # #64123-Problem-1-Question-E: # 1 #64123-Problem-1-Question-E1: # #64123-Problem-1-Question-F: # 1 #64123-Problem-1-Question-F1: # #64123-Problem-1-Question-G: # 1 #64123-Problem-1-Question-G1: # #64123-Problem-1-Question-H: # 0 #64123-Problem-1-Question-H1: # Natural Sciences and Social Sciences #64123-Problem-1-Question-I: # 1 #64123-Problem-1-Question-J: # 1 #64123-Problem-1-Question-K: # 4 #64123-Problem-1-Question-K1: # #64123-Problem-1-Question-L: # 4 #64123-Problem-1-Question-M: # 2 #64123-Problem-1-Question-N: # 1 #64123-Problem-1-Question-O: # 1 #64123-Problem-1-Question-P: # 3 #64123-Problem-1-Question-P1: # #64123-Problem-1-Question-1: # 0 #64123-Problem-1-Question-2: # 5 #64123-Problem-1-Question-3: # 5 #64123-Problem-1-Question-4: # 5 #64123-Problem-1-Question-5: # 2 #64123-Problem-1-Question-6: # 2 #64123-Problem-1-Question-7: # 1 #64123-Problem-1-Question-8: # 2 #64123-Problem-1-Question-9: # 3 #64123-Problem-1-Question-10: # 5 #64123-Problem-1-Question-11: # 5 #64123-Problem-1-Question-12: # 5 #64123-Problem-1-Question-13: # 5 #64123-Problem-1-Question-14: # 5 #64123-Problem-1-Question-15: # 5 #64123-Problem-1-Question-16: # 5 #64123-Problem-1-Question-17: # 5 #64123-Problem-1-Question-18: # 5 #64123-Problem-1-Question-19: # 5 #64123-Problem-1-Question-20: # 5 #64123-Problem-1-Question-21: # 5 #64123-Problem-1-Question-22: # 5 #64123-Problem-1-Question-23: # 5 #64123-Problem-1-Question-24: # 5 #64123-Problem-1-Question-25: # 5 #64123-Problem-1-Question-26: # 5 #64123-Problem-1-Question-27: # Personally, I think WeBWorK is the greatest teaching tool created. 1) It allows me to know instantaneously # whether I got the right answer. 2) It forces me to learn the material at an earlier time as opposed to # right before the test. 3) Since you can also access other problems through other users (i.e., practice1, # practice2, etc.) it really prepares me well for tests. I don't know what I would do without it. I think # that without WeBWorK, I would not be doing as well as I am in the course (A+). Because WeBWorK problem # sets involve material that we have just covered in class, we are prepared very well. I thought I would # never see the day when Math would become my best class. Though, I firmly believe that my success is due # to the excellence of the teaching (Professor Benedetto is the best Math professor I've ever had) and # the WeBWorK program. #64123-Problem-1-Question-28: # WeBWork has come a long way since last semester. They've fixed the problems I had with it by making the # syntax easier to put in and the preview option. #64123-Problem-1-Question-29: # Refer to above.