#! /usr/bin/perl
# Copyright 2001-2009 Leslie Richardson
# This file is part of Open Admin for Schools.
# Open Admin for Schools is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# Outline: Print the report cards for a single grade or homeroom.
# Customizations: Note ANY customizations for this school here
# along with line numbers and/or markers to find them...
my %lex = ('Report Card Generation' => 'Report Card Generation',
'Main' => 'Main',
'Report Card' => 'Report Card',
'teacher' => 'teacher',
'principal' => 'principal',
'combo' => 'combo',
'No grade found or Periods per day not set in admin.conf' =>
'No grade found or Periods per day not set in admin.conf',
'Cannot open term file' => 'Cannot open term file',
'View/Download/Print Report Cards' => 'View/Download/Print Report Cards',
'View Log File' => 'View Log File',
'Report to Parents' => 'Report to Parents',
'Grade' => 'Grade',
'Homeroom Teacher(s)' => 'Homeroom Teacher(s)',
'Evaluation and Comment Key' => 'Evaluation and Comment Key',
'Class Average' => 'Class Average',
'Attendance' => 'Attendance',
'Days Open' => 'Days Open',
'Days Enrolled' => 'Days Enrolled',
'Days Absent' => 'Days Absent',
'Periods Late' => 'Periods Late',
'Additional Comments' => 'Additional Comments',
'Term' => 'Term',
'Teacher' => 'Teacher',
'Principal' => 'Principal',
'Please tear off this portion and return it to the school' =>
'Please tear off this portion and return it to the school',
'in the report envelope with any comments and your signature' =>
'in the report envelope with any comments and your signature',
'Parent/Guardian Signature' => 'Parent/Guardian Signature',
'Student' => 'Student',
'Date' => 'Date',
'Comments' => 'Comments',
'Days per Month Override' => 'Days per Month Override',
'Student Group' => 'Student Group',
'Homeroom' => 'Homeroom',
'Days Open' => 'Days Open',
'Month' => 'Month',
'Continue' => 'Continue',
'Duplicate Evaluation records for student' =>
'Duplicate Evaluation records for student',
'Average' => 'Average',
'Final' => 'Final',
'No Quality Score for' => 'No Quality Score for',
'Error' => 'Error',
'Printed' => 'Printed',
'Override Term Days' => 'Override Term Days',
'Font Size' => 'Font Size',
'One Student per File' => 'One Student per File',
'GPA' => 'GPA',
'Current Year GPA' => 'Current Year GPA',
'Phone' => 'Phone',
'Fax' => 'Fax',
'Absent' => 'Absent',
'Late' => 'Late',
'Alternate Report Card System' => 'Alternate Report Card System',
'Student Name' => 'Student Name',
'Date of Birth' => 'Date of Birth',
'Teacher Name' => 'Teacher Name',
'Principal' => 'Principal',
'Vice-Principal' => 'Vice-Principal',
'Period(s)' => 'Period(s)',
'Evaluation Key' => 'Evaluation Key',
'Select Subjects' => 'Select Subjects',
'For Duplexing/Stapling' => 'For Duplexing/Stapling',
'Show Withdrawn Students' => 'Show Withdrawn Students',
'Please Log In' => 'Please Log In',
'Pre-kindergarten Class' => 'Pre-kindergarten Class',
'Subject' => 'Subject',
'Mark' => 'Mark',
'Effective Date' => 'Effective Date',
'Absent' => 'Absent',
'Late' => 'Late',
'Letter' => 'Letter',
'Legal' => 'Legal',
'A4' => 'A4',
'Paper Size' => 'Paper Size',
'Start Term' => 'Start Term',
'End Term' => 'End Term',
'Blank=All' => 'Blank=All',
);
use DBI;
use CGI;
use CGI::Session;
use Date::Business;
use Cwd;
use Number::Format format_number;
# To Do: fix the ppd override for teacher mode.
# $r_AverageWeight{ $termPattern } = ( 1 => 0.30, 2 => 0.35, 3 => 0.35 ) ;
# termPattern is starterm-endterm.
# These new config values control whether the subject printing will
# have empty cells before or after in situation where the current term
# is later, and for a second semester class it will produce blank
# cells before the current subject while for a first semester subject
# (already done), it will show blanks after.
# $r_TermDisplayLeading = 1;
# Allows current later starting subjects to display back to start (with blanks)
# $r_TermDisplayTrailing = 1; # effectively sets ending display term to current term
# Allows completed subjects to extend to current term (with blanks)
# ----------------------------
# More global repcard.conf to fix: $markfield
# This is no longer optional, and is wired to the first field (a1) for
# all numeric entries.
# Set Sizes for text area for each paper size.
# $r_a4paper_textwidth = '184mm';
# $r_a4paper_textheight = '272mm';
# $r_letterpaper_textwidth = '190mm';
# $r_letterpaper_textheight = '250mm';
# $r_legalpaper_textwidth = '190mm';
# $r_legalpaper_textheight = '325mm';
my $self = 'rptrepcard.pl';
# Get current dir so know what path for config files.
my $configpath;
my $teachermode;
if ( getcwd() =~ /tcgi/ ){ # we are in tcgi
$teachermode = 1;
$configpath = '..'; # go back one to get to etc.
} else {
$configpath = '../..'; # go back two to get to etc.
}
# main config file
eval require "$configpath/etc/admin.conf";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
# report card config file
eval require "$configpath/etc/repcard.conf";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
if ( $r_TeacherModeOverride ) {
$teachermode = 0;
}
# filter latex function
eval require "$configpath/lib/liblatex.pl";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
# attendance library functions
eval require "$configpath/lib/libattend.pl";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
if ( $teachermode ) { # Load Teacher overrides
eval require "$configpath/etc/repcardOVR.conf";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
}
# Get current dir so know what CSS to display;
if (getcwd() =~ /tcgi/){ # we are in tcgi
$css = $tchcss;
}
my $q = new CGI;
my %arr = $q->Vars;
my $dsn = "DBI:$dbtype:dbname=$dbase";
$dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
my $session;
if ( $teachermode ) { # we are running in teacher site.
# Get Session
$session = new CGI::Session("driver:$dbtype;serializer:FreezeThaw",
undef,{Handle => $dbh}) or die CGI::Session->errstr;
if ( not $session->param('logged_in') ){
$userid = $session->param('userid');
print $q->header( -charset, $charset );
print "