#! /usr/bin/perl
# Copyright 2001-2019 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 = ('Generate' => 'Generate',
'Main' => 'Main',
'Report Cards' => 'Report Cards',
'Report Card' => 'Report Card',
'Cannot open term file' => 'Cannot open term file',
'View/Download/Print' => 'View/Download/Print',
'View Log File' => 'View Log File',
'Report to Parents' => 'Report to Parents',
'Grade' => 'Grade',
'Teacher(s)' => 'Teacher(s)',
'Evaluation and Comment Key' => 'Evaluation Key',
'Class Average' => 'Class Average',
'Attendance' => 'Attendance',
'Days Open' => 'Days Open',
'Days Enrolled' => 'Days Enrolled',
'Days Absent' => 'Days Absent',
'Periods Late' => 'Periods Late',
'General Comments' => 'General 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 Record' =>
'Duplicate Evaluation Record',
'Average' => 'Average',
'No Quality Score' => 'No Quality Score',
'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',
'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',
'Printing Date' => 'Printing 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',
'Periods per Day' => 'Periods per Day',
'Rank' => 'Rank',
'Demerits' => 'Demerits',
'Skipping' => 'Skipping',
'Undefined Value' => 'Undefined Value',
'Missing' => 'Missing',
'Value' => 'Value',
'Track' => 'Track',
'Only' => 'Only',
'Not Found' => 'Not Found',
'Picture' => 'Picture',
'Email' => 'Email',
'Address' => 'Address',
'Select' => 'Select',
'Post' => 'Post',
'Complete' => 'Complete',
'OR' => 'OR',
'Form' => 'Form',
);
use DBI;
use CGI;
use CGI::Session;
use Cwd;
use Number::Format qw(:all);
use Carp;
use Time::JulianDay;
my $deleteTeX = 1;
my $showEmailOption = 0;
# Non School Day Grades
my %nonschoolgrades = ('K' => 1,'PK' => 1,'P3' => 1);
# Email Configuration Values
my $r_MailServer = 'richtech.ca';
my $r_NoReplyName = 'OpenAdmin Messaging System';
my $r_NoReplyEmail = 'no-reply@yoursite.net';
my $message = "Dear Parents of <\@firstname\@> <\@lastname\@>,
Attached is a copy of the report card for <\@firstname\@>.
Sincerely,
<\@r_Principal\@>
<\@schoolname\@>
<\@schooladdr1\@>
<\@schooladdr2\@>
";
# 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)
# ----------------------------
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";
}
my $schoolmode;
if ( $g_BritishSchoolMode ) {
$schoolmode = 1; # will there be a mode 2?
}
my $dsn = "DBI:$dbtype:dbname=$dbase";
$dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
# populate jdclosed with dates from dates table; used by calcTermDays;
my %jdclosed;
my $sth = $dbh->prepare("select date, dayfraction from dates
where date is not NULL and date != ''");
$sth->execute;
if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; }
while ( my ( $date, $dayfraction ) = $sth->fetchrow ) {
my $jd = julian_day( split( '-', $date ) );
$jdclosed{$jd} = $dayfraction;
}
# load report card configuration
my $sth = $dbh->prepare("select id, datavalue from conf_system where filename = 'repcard'
order by dataname");
$sth->execute;
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
while ( my ($id, $datavalue) = $sth->fetchrow ) {
eval $datavalue;
if ( $@ ) {
print "$lex{Error}: $@
\n";
die "$lex{Error}: $@\n";
}
}
# LaTeX filter 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";
}
# Get current dir so know what CSS to display and shift to teacher settings.
if ( getcwd() =~ /tcgi/ ) { # we are in tcgi
$css = $tchcss;
$homepage = $tchpage;
$downloaddir = $tchdownloaddir;
$webdownloaddir = $tchwebdownloaddir;
$reppage = $tchpage;
}
my $q = new CGI;
my %arr = $q->Vars;
print $q->header( -charset, $charset );
if ( not $r_TeacherModeOverride and $teachermode ) { # not allowed to print from teacher site
print qq{