#!/usr/bin/perl # Reads in grades on exam problems and spits out stats formatted as an # html table. Each line consists of the grades for a single student (tab # separated). The first line consists of the headers; the second line is # the maximum score for each column. Use this by copying & pasting the # gradebook entries from Excel or OpenOffice into a textfile (it should # automatically tab-delimit them) and then pointing the script at the file. # This assumes you are storing each student as a row and each grade item # as a column. use lib "/home/math/gbutler/lib/perl5"; use Statistics::Descriptive; $indent = 4 x " "; $headerLine = <>; chomp($headerLine); @headerList = split(/\t/,$headerLine); $maxLine = <>; chomp($maxLine); @maxList = split(/\t/,$maxLine); @stud = (); while(<>) { chomp; @line = split(/\t/); push(@stud,[@line]); } @stat = (); @notAttempted = (); for($i = 0; $i <= $#headerList; $i++) { #assumes all lines have the same numer of fields, expect runtime errors otherwise @gradeCol = (); #list of all student's grades for a single gradebook entry $numNotSubmitted[$i] = 0; for($j = 0; $j <= $#stud; $j++) { if(defined($stud[$j][$i]) && $stud[$j][$i] ne "") { push(@gradeCol,$stud[$j][$i]); } else { $numNotSubmitted[$i]++; } } push(@stat,Statistics::Descriptive::Full->new()); $stat[$#stat]->add_data(@gradeCol); } print "
| Points Possible | A+ (>100) | A (90-100) | A- (87-89) | B+ (83-86) | B (80-82) | B- (77-79) | C+ (73-76) | C (70-72) | C- (67-69) | D+ (63-66) | D (60-62) | D- (57-59) | F (0-56) | Not Submitted | Mean | Standard Deviation | Max | Q3 | Median | Q1 | Min | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| " . $headerList[$i] . " | " . join(" | ",($maxList[$i],$numap,$numa,$numam,$numbp,$numb,$numbm,$numcp,$numc,$numcm,$numdp,$numd,$numdm,$numf,$numNotSubmitted[$i],sprintf("%.3lf",$stat[$i]->mean()),sprintf("%.3lf",$stat[$i]->standard_deviation()),$stat[$i]->max(),$p75,$stat[$i]->median(),$p25,$stat[$i]->min())) . " |