#!/usr/bin/perl
# Copyright 2001-2021 Leslie Richardson
# This file is part of Open Admin for Schools.
# Read Report - read all reading tests from all schools, calc the
# Equiv Grade and then compare to the actual grade and get a
# delta. Compile into per grade, per school and overall stats.
my %lex = ('Error' => 'Error',
'Main' => 'Main',
'Math' => 'Math',
'Start Date' => 'Start Date',
'End Date' => 'End Date',
'Date' => 'Date',
'Continue' => 'Continue',
'Schools' => 'Schools',
'Database' => 'Database',
'Reading' => 'Reading',
'Report' => 'Report',
'Global' => 'Global',
'Select' => 'Select',
'Split' => 'Split',
'Grade' => 'Grade',
'Current' => 'Current',
'Output' => 'Output',
'Combine failed on input' => 'Combine failed on input',
'Download CSV File' => 'Download CSV File',
'Test' => 'Test',
'Group' => 'Group',
'Division' => 'Division',
'Paper Size' => 'Paper Size',
'Letter' => 'Letter',
'Legal' => 'Legal',
'A4' => 'A4',
'Season' => 'Season',
'Seasons' => 'Seasons',
'Missing' => 'Missing',
'Weight' => 'Weight',
'Tests' => 'Tests',
);
my $self = 'mathRpt1.pl';
my $missing = qq{$lex{Missing}};
my @phases = qw(Emergent Matching Quantifying Partitioning Factoring Operating);
my %phaseval = qw(Emergent 1 Matching 2 Quantifying 3 Partitioning 4 Factoring 5 Operating 6);
# Maps Grades to Grade Divisions I, II, III, IV.
my %divmap = ( 'K' => 1, 1 => 1, 2 => 1, 3 => 1,
4 => 2, 5 => 2, 6 => 2,
7 => 3, 8 => 3, 9 => 3,
10 => 4, 11 => 4, 12 => 4 );
# use GD::Graph::bars;
# use GD::Graph::colour qw(:colours);
use DBI;
use CGI;
use Number::Format qw(:all);
use Time::JulianDay;
use Text::CSV_XS;
use Statistics::Basic qw(:all);
#use strict;
eval require "../../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
my @time = localtime(time);
my $year = $time[5] + 1900;
my $month = $time[4] + 1;
my $currdate = "$year-$month-$time[3]";
my $schyear = $year;
if ( $month < 7 ){ $schyear = $schyear - 1; }
my $prevyear = $schyear - 1;
my $q = CGI->new;
my %arr = $q->Vars;
print $q->header( -charset, $charset );
# Script Heading Descriptor
my $title = qq{$lex{Math} $lex{Report} 1};
# Print Page Heading
print qq{$doctype\n
}; print qq{ | Percentage of Students vs Math Level Category | }; print qq{|||||||
---|---|---|---|---|---|---|---|---|
$lex{Grade} | \n}; foreach my $phase ( @phases ) { print qq{$phase | }; } print qq{#$lex{Tests} | Avg | |||||
$lex{Weight} | \n}; foreach my $phase ( @phases ) { print qq{$phaseval{$phase} | }; } print qq{|||||||
$grade | }; my $total; foreach my $key ( keys %{ $seasondata{$grade} } ) { $total += $seasondata{$grade}{$key} } # Print Phases my $gradetotal; # for average calc; contains total of count * phase val for all phases foreach my $phase ( @phases ) { my $percent; if ( $total ) { $percent = $seasondata{$grade}{$phase} / $total * 100; $percent = round($percent, 2); $gradetotal += ( $seasondata{$grade}{$phase} * $phaseval{$phase}); # print qq{Phase:$phase Count:$seasondata{$grade}{$phase} };l # print qq{GradeTotal:$gradetotal$percent }; if ( $seasondata{$grade}{$phase} ) { print qq{ ($seasondata{$grade}{$phase})}; } print qq{ | \n}; } # Do EQ Grade Average my $avg; if ( $total ) { $avg = $gradetotal / $total; } else { $avg = 0; } $avg = round($avg, 2); print qq{$total | $avg | }; print qq{|||||
Division $division | }; my ($divtotal,$divavgtotal,%cols); # get total count, total weighted for my $grade ($startgrade..$endgrade) { foreach my $phase ( @phases ) { my $count = $seasondata{$grade}{$phase}; $divtotal += $count; $cols{$phase} += $count; $divavgtotal += ( $count * $phaseval{$phase} ); # print qq{Count:$count Tot:$divtotal AvgTot:$divavgtotal$percent}; if ( $cols{$phase} ) { print qq{ ($cols{$phase}) | }; } print qq{\n}; } # Do EQ Grade Average my $avg; if ( $divtotal ) { $avg = $divavgtotal / $divtotal; } else { $avg = 0; } $avg = round($avg, 2); print qq{$divtotal | $avg | }; print qq{|||||
Summary | }; my ($total,$avgtotal); # get total count, total weighted foreach my $key ( keys %colsummary ) { $total += $colsummary{$key}; $avgtotal += ( $colsummary{$key} * $phaseval{$key} ); } # Print Phases foreach my $phase ( @phases ) { my $percent; if ( $total ) { $percent = $colsummary{$phase} / $total * 100; $percent = round($percent, 2); } else { $percent = 0; } print qq{$percent}; if ( $colsummary{$phase} ) { print qq{ ($colsummary{$phase}) | }; } print qq{\n}; } # Do EQ Grade Average my $avg; if ( $total ) { $avg = $avgtotal / $total; } else { $avg = 0; } $avg = round($avg, 2); print qq{$total | $avg | }; print qq{