#! /usr/bin/perl # Copyright 2001-2011 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. my %lex = ('Report' => 'Report', 'Main' => 'Main', 'Transcript' => 'Transcript', 'Transcripts' => 'Transcripts', 'Edit' => 'Edit', 'Transcript of Marks' => 'Transcript of Marks', 'No Quality Score for' => 'No Quality Score for', 'Report Card' => 'Report Card', 'Term' => 'Term', 'Credits Earned' => 'Credits Earned', 'Credits Attempted' => 'Credits Attempted', 'Reqd' => 'Reqd', 'Earned' => 'Earned', 'Total' => 'Total', 'Approved by' => 'Approved by', 'Transcript is official when sealed' => 'Transcript is official when sealed', 'Phone' => 'Phone', 'Fax' => 'Fax', 'Requirements Complete' => 'Requirements Complete', 'Printed' => 'Printed', 'No Records Found' => 'No Records Found', 'No Records Selected' => 'No Records Selected', 'Entry Error' => 'Entry Error', 'No Student(s) Found' => 'No Student(s) Found', 'Graduation~Requirements' => 'Graduation~Requirements', 'Semester GPA' => 'Semester GPA', 'Cum GPA' => 'Cum GPA', 'Diploma Awarded on' => 'Graduation date:', 'View/Download' => 'View/Download', 'View Log File' => 'View Log File', 'Grade' => 'Grade', 'Homeroom' => 'Homeroom', 'DOB' => 'DOB', 'Lastname/Lastname,Firstname/Initials/StudentNumber' => 'Lastname/Lastname,Firstname/Initials/StudentNumber', 'Select Student' => 'Select Student', 'Select Group' => 'Select Group', 'Continue' => 'Continue', 'Code' => 'Code', 'Subject' => 'Subject', 'Credit' => 'Credit', 'Area' => 'Area', 'Error' => 'Error', 'Letter' => 'Letter', 'Legal' => 'Legal', 'A4' => 'A4', 'Paper Size' => 'Paper Size', 'Not Found' => 'Not Found', ); my $self = 'rpttranscript.pl'; # Configuration Format Variables my $blockwidth = '70mm'; # 2.5in my $col1 = '15mm'; # '0.60in'; my $col2 = '37mm'; # '1.45in'; my $col3 = '9mm'; #'0.35in'; my $col4 = '5.1mm'; #'0.20in'; $grayscale = '0.93'; my $maxlines = 35; # begin splitting into separate tables after this... my $voffset = '-18mm'; my $hoffset = '-18mm'; use DBI; use CGI; use Number::Format qw(:subs); # Read config variables eval require "../../etc/admin.conf"; if ( $@ ) { print $lex{Error}. ": $@
\n"; die $lex{Error}. ": $@\n"; } #eval require "../../etc/transcript.conf"; #if ( $@ ) { # print $lex{Error}. ": $@
\n"; # die $lex{Error}. ": $@
\n"; #} # filter latex function eval require "../../lib/liblatex.pl"; if ( $@ ) { print $lex{Error}. ": $@
\n"; die $lex{Error}. ": $@\n"; } my $q = new CGI; print $q->header( -charset, $charset ); my %arr = $q->Vars; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); $dbh->{mysql_enable_utf8} = 1; # Get transcript values from configuration system my $sth = $dbh->prepare("select datavalue from conf_system where filename = 'transcript'"); $sth->execute; while ( my $datavalue = $sth->fetchrow ) { eval $datavalue; if ( $@ ) { print "$lex{Error}: $@
\n"; die "$lex{Error}: $@\n"; } } # Set Paper Size, text width and height my ( $papersize, $textwidth, $textheight ); if ( $arr{papersize} eq $lex{Legal} ) { $papersize = 'legalpaper'; $textwidth = $g_legalpaper_textwidth; $textheight = $g_legalpaper_textheight; } elsif ( $arr{papersize} eq $lex{A4} ) { $papersize = 'a4paper'; $textwidth = $g_a4paper_textwidth; $textheight = $g_a4paper_textheight; } else { # default to Letter paper. $papersize = 'letterpaper'; $textwidth = $g_letterpaper_textwidth; $textheight = $g_letterpaper_textheight; } # print "Papersize: $papersize TW: $textwidth TH: $textheight
\n"; my $fmt = new Number::Format(-decimal_fill => '1', -decimal_digits => '2'); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $iddst) = localtime(time); $year = $year + 1900; $mon++; $wday++; my $currdate = "$dow[$wday], $month[$mon] $mday, $year"; my $shortname = "transcript$$"; my $filename = "$shortname.tex"; my $logfile = "pdflog$$.txt"; if ( not $arr{page} ) { $offset = 2; } elsif ( $arr{page} == 1 ) { $offset = 1; } my $title = "$lex{Transcript} $lex{Report}"; print "$doctype\n$title \n"; print "\n"; print "$chartype\n\n"; print "[ $lex{Main} |\n"; print "$lex{'Report Card'} |\n"; print " $lex{Edit} $lex{Transcripts} ]\n"; print "

$title

\n"; if ( not $arr{page} ) { showStartPage(); } elsif ( $arr{page} == 1 ) { delete $arr{page}; processSearch(); } elsif ( $arr{page} == 2 ) { delete $arr{page}; delete $arr{papersize}; printTranscriptsHTML(); printTranscriptsPDF(); } #---------------- sub showStartPage { #---------------- # print sortorder and selection input form. print "
\n"; print "\n"; print "
"; print $lex{'Lastname/Lastname,Firstname/Initials/StudentNumber'}. "
\n"; print "\n"; print "
\n"; print "
"; print "\n"; print "\n"; print "
\n"; # Paper Size print "
"; $defaultpapersize =~ s/paper//; # strip out word paper so lex works; from admin.conf my $defpaper = ucfirst( $defaultpapersize ); print $lex{'Paper Size'}; print "
\n"; print "\n"; exit; } #---------------- sub processSearch { #---------------- # Passed: student, group, select #foreach my $key ( sort keys %arr ) { print "K:$key V:$arr{$key}
\n"; } my @students = (); print "

\n"; if ( $arr{student} ) { # We are looking for a single student... my $student = $arr{student}; # Setup the Search if ($student =~ /\d+/) { # we have a student number push @students, $student; } else { # we have words hopefully with a comma my ($lastname,$firstname) = split /\,/, $student; $firstname =~ s/^\s*//; $lastname =~ s/^\s*//; if ($lastname and $firstname){ # both entered. $sth = $dbh->prepare("select studnum from tscriptident where lastname = ? and firstname = ?"); $sth->execute( $lastname, $firstname ); } elsif ($lastname and not $firstname){ # only lastname (no comma) if (length($lastname) == 2){ # search by initials: fi, li. my $fi = substr($lastname,0,1). '%'; my $li = substr($lastname,1,1). '%'; $sth = $dbh->prepare("select studnum from tscriptident where lastname $sql{like} ? and firstname $sql{like} ?"); $sth->execute( $li, $fi ); } else { $sth = $dbh->prepare("select studnum from tscriptident where lastname = ? order by firstname"); $sth->execute( $lastname ); } } else { # print an error.... print '

'. $lex{'Entry Error'}. ': '. $lex{'No Student(s) Found'}; print ".

\n"; print "\n"; exit; } } # Last Else if ( $sth ) { # if text we should have a statement handle (sth) if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } $rows = $sth->rows; if ($rows < 1) { print '

'. $lex{'No Student(s) Found'}. ".

\n"; print "\n"; exit; } while ( my $studnum = $sth->fetchrow ) { push @students, $studnum; } } } elsif ( $arr{groupvalue} ) { # We have a group selected; select from student table my $select; if ( $arr{groupname} eq $lex{Grade} ) { $select = 'where grade = ?'; } elsif ( $arr{groupname} eq $lex{Homeroom} ) { $select = 'where homeroom = ?'; } else { print $lex{'No Records Selected'}; print "\n"; exit; } $sth = $dbh->prepare("select studnum from studentall $select order by lastname, firstname"); $sth->execute( $arr{groupvalue} ); if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } while ( my $studnum = $sth->fetchrow ) { push @students, $studnum; } } if ( not @students ) { print $lex{'No Records Found'}; print "\n"; exit; } # Now print the form... print "
\n"; print "\n"; print "\n"; print "\n"; # display found students, if any... $sth1 = $dbh->prepare("select lastname, firstname from tscriptident where studnum = ?"); $sth2 = $dbh->prepare("select lastname, firstname from studentall where studnum = ?"); my $checked; if ( $arr{groupvalue} ) { # check group by default only. $checked = 'checked'; } foreach my $studnum ( @students ) { $sth1->execute( $studnum ); my ($lastname, $firstname) = $sth1->fetchrow; if ( not $lastname ) { $sth2->execute( $studnum ); my ($lastname, $firstname) = $sth2->fetchrow; print ""; } else { print ""; print ""; print "\n"; } } print "\n"; print "\n"; exit; } #----------------------- sub printTranscriptsHTML { #----------------------- #foreach my $key (keys %arr ) { print "K:$key V:$arr{$key}
\n"; } if ( not %arr ){ print '

'. $lex{'No Records Found'}. ".

\n"; print "\n"; halt; } my $sth = $dbh->prepare("select id, subjectcode, subjecttext, subjectarea, score_mark, score_letter, score_diff, schoolyear, credit, term, term_desc from tscriptdata where studnum = ? order by schoolyear, term, subjecttext"); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } my $sth1 = $dbh->prepare("select lastname, firstname, birthdate from tscriptident where studnum = ?"); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } # Main Loop - once for each student. foreach my $studnum ( keys %arr ) { # totalCredits include Pass/Fail Subjects my ($totalCredits, $totalGPQuality, $totalGPCredits); # process transcript data $sth->execute( $studnum ); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } # Fetch Student's Info $sth1->execute( $studnum ); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } my ($lastname, $firstname, $birthdate) = $sth1->fetchrow; print "

$firstname $lastname ($studnum) - $birthdate

\n"; my $currdesc = -1; my $prevdesc; my $currschoolyear = -1; my $prevschoolyear; # Outer Table print "
$firstname $lastname ($studnum) "; print $lex{'Not Found'}. "
$firstname $lastname ($studnum)
\n"; print "\n\n"; } else { print "\n\n"; } print "
\n"; # Inner Table print "\n"; print ""; print "\n"; my $first = 1; my $colcounter = 1; my ( $semesterGPCredits, $semesterGPQuality, $semesterAttempts, $semesterCredits ); # Loop through all transcript records. while ( my ( $id, $subjectcode, $subjecttext, $subjectarea, $score_mark, $score_letter, $score_diff, $schoolyear, $credit, $term, $term_desc ) = $sth->fetchrow ) { $score_mark =~ s/%//; # strip percents. $prevdesc = $currdesc; $currdesc = $term_desc; $prevschoolyear = $currschoolyear; $currschoolyear = $schoolyear; if ( $currdesc ne $prevdesc or $currschoolyear ne $prevschoolyear ) { if ( not $first ) { my ($gpa, $cumgpa); if ($semesterGPCredits) { $gpa = $fmt->format_number( $semesterGPQuality / $semesterGPCredits, 4 ); } else { $gpa = 0; } if ( $totalGPCredits ) { $cumgpa = $fmt->format_number( $totalGPQuality / $totalGPCredits, 4 ); } else { $cumgpa = 0; } my $gpa = $fmt->format_number( $gpa , 4); my $cumgpa = $fmt->format_number( $cumgpa, 4); print ""; print "\n"; $semesterAttempts = $fmt->format_number( $semesterAttempts, 2); # attempted $semesterCredits = $fmt->format_number( $semesterCredits, 2); # earned print ""; print "\n"; print "
$lex{Code}$lex{Subject}$lex{Area}$lex{Credit}$lex{Grade}
". $lex{'Semester GPA'}. ": $gpa\n"; print $lex{'Cum GPA'}. ": $cumgpa
$lex{'Credits Attempted'} $semesterAttempts\n"; print "$lex{'Credits Earned'} $semesterCredits
\n"; if ( $colcounter % 2 ) { print "\n\n
\n"; # new cell... } else { print "\n\n
\n"; # new row } $colcounter++; $semesterGPQuality = 0; $semesterGPCredits = 0; $semesterCredits = 0; $semesterAttempts = 0; print "\n"; print "\n"; } else { $first = 0; } print "
"; print "$schoolyear - ". $lex{Term}. " $term - $currdesc
\n"; } # letterToQual hash in transcript.conf; add up quality scores and credit counts. # Check for missing Quality value in transcript.conf if ( ( not defined $letterToQual{ $score_letter } ) and ($score_letter ne $passletter ) ) { # thus unknown score print $lex{'No Quality Score for'}. " $score_letter
\n"; next; # skip } # Update Attempts $semesterAttempts += $credit; # Now do Pass Letter settings. my $quality = 0; if ( $score_letter eq $passletter ) { $semesterCredits += $credit; $totalCredits += $credit; } elsif ( $score_letter eq $failletter ) { # No additions to credits, GP credits increase to bring down avg. $totalGPCredits += $credit; $semesterGPCredits += $credit; } else { # calculate passing grade settings. $quality = $letterToQual{ $score_letter }; if ( $quality ) { # if we have a nonzero value, add in difficulty score. $quality += $score_diff; # difficulty factor } # Update Quality scores for weighted average. $semesterGPQuality += $quality * $credit; $totalGPQuality += $quality * $credit; # Update GP Credit totals for weighted average. $totalGPCredits += $credit; $semesterGPCredits += $credit; # Update the credits $semesterCredits += $credit; $totalCredits += $credit; } $credit = $fmt->format_number( $credit, 2); print ""; print ""; if ( $t_showMark ) { # from transcript.conf print "\n"; } else { print "\n"; } } # Print the last GPA value... if ( not $first ) { my ($gpa, $cumgpa); if ($semesterGPCredits) { $gpa = $fmt->format_number( $semesterGPQuality / $semesterGPCredits, 4 ); } else { $gpa = 0; } if ( $totalGPCredits ) { $cumgpa = $fmt->format_number( $totalGPQuality / $totalGPCredits, 4 ); } else { $cumgpa = 0; } $gpa = $fmt->format_number( $gpa, 2 ); $cumgpa = $fmt->format_number( $cumgpa, 2 ); print ""; print "\n"; $semesterAttempts = $fmt->format_number( $semesterAttempts, 2); # attempted $semesterCredits = $fmt->format_number( $semesterCredits, 2); # earned print ""; print "\n"; $semesterGPQuality = 0; $semesterGPCredits = 0; $semesterCredits = 0; $semesterAttempts = 0; } print "
$lex{Code}$lex{Subject}"; print "$lex{Area}"; print "$lex{Credit}$lex{Grade}
$subjectcode$subjecttext$subjectarea$credit$score_mark ($quality)
$score_letter ($quality)
$lex{'Semester GPA'}: $gpa\n"; print "$lex{'Cum GPA'}: $cumgpa
$lex{'Credits Attempted'} $semesterAttempts\n"; print "$lex{'Credits Earned'} $semesterCredits
\n"; # finish off last inner table. # Finish off outer table. print "\n"; if ( $colcounter % 2 ) { print "\n
\n"; } # End of Main Student Loop print "

\n"; } #-------------- sub prTexHeader { #-------------- # $papersize, $textwidth and $textheight set above. print TEX "\\documentclass[10pt,$papersize]{article}\n"; print TEX "\\usepackage{ array, colortbl, multicol, helvet, pifont, fancyhdr, inputenc}\n"; print TEX "$a_latex_header\n"; print TEX "\\setlength{\\textwidth}{$textwidth}\n \\setlength{\\textheight}{$textheight}\n"; print TEX "\\setlength{\\hoffset}{$hoffset}\n\\setlength{\\voffset}{$voffset}\n"; print TEX "\\setlength{\\evensidemargin}{0in}\n\\setlength{\\oddsidemargin}{0in}\n"; #print TEX "\\setlength{\\extrarowheight}{2pt}\n print TEX "\\setlength{\\parindent}{0pt}\n"; print TEX "\\setlength{\\topskip}{0pt}\n"; print TEX "\\setlength{\\headsep}{6pt}\n"; print TEX "\\renewcommand{\\familydefault}{\\sfdefault}\n"; print TEX "\\pagestyle{fancy}\n \\rfoot{". $lex{Printed}. ": $currdate }\n"; print TEX "\\cfoot{ }\n"; print TEX "\\begin{document}\n"; } #---------------------- sub printTranscriptsPDF { #---------------------- # foreach my $key (keys %arr ) { print "K:$key V:$arr{$key}
\n"; } my $pagecount = 1; if ( not %arr ){ print '

'. $lex{'No Records Found'}. ".

\n"; print "\n"; halt; } # Setup Tex File open(TEX,">$filename") || die "Cannot open tex file"; prTexHeader(); # print TeX file header defaults. # Setup selects for transcript data and student name my $sth = $dbh->prepare("select id, subjectcode, subjecttext, score_mark, score_letter, score_diff, schoolyear, credit, term, term_desc from tscriptdata where studnum = ? order by schoolyear, term, subjecttext"); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } # Get Student Name my $sth1 = $dbh->prepare("select lastname, firstname, middlename, birthdate, graddate from tscriptident where studnum = ?"); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } # Main Loop - once for each student. foreach my $studnum ( keys %arr ) { # totalCredits include Pass/Fail Subjects my ($totalCredits, $totalGPQuality, $totalGPCredits); # process transcript data $sth->execute( $studnum ); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } # Fetch Student's Info $sth1->execute($studnum); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } my ( $lastname, $firstname, $middlename, $birthdate, $graddate ) = $sth1->fetchrow; $globalGradDate = $graddate; if ( $pagecount != 1 ) { # start a new page. print TEX "\\newpage\n"; } print TEX "\\setcounter{page}{1}\n"; #print TEX "\\{$schoolname -- $schoolyear \\hfill "; print TEX "\\rhead{$firstname $middlename $lastname -- Page \\thepage}\n"; # Print School Info print TEX "{\\Large $schoolname} \\hfill {\\Large "; print TEX $lex{'Transcript of Marks'}. "} \\hfill ". $lex{Phone}. " $schoolphone \n\n"; print TEX "$schooladdr1 $schooladdr2 $schoolcity, $schoolprov $schoolpcode\\hfill "; print TEX $lex{Fax}. " $schoolfax \n\n"; print TEX "\n\\bigskip\n\n"; # Print Student Info print TEX "{\\Large\\bf $firstname $middlename $lastname} "; print TEX "\\quad{\\it\\bf ". $lex{DOB}. ":} $birthdate \n\n"; print TEX "\\begin{tabular}[t]{|p{ $blockwidth }|p{ $blockwidth }|}\\hline\n"; my $currdesc = -1; my $prevdesc; my $currschoolyear = -1; my $prevschoolyear; my $first = 1; my $colcounter = 1; my $colorcounter = 1; my ($linecounter, $blockcounter); # needed to count how far down until splitting the table. my ( $semesterGPCredits, $semesterGPQuality, $semesterAttempts, $semesterCredits ); # Loop through all transcript records. while ( my ( $id, $subjectcode, $subjecttext, $score_mark, $score_letter, $score_diff, $schoolyear, $credit, $term, $term_desc ) = $sth->fetchrow ) { $score_mark =~ s/%//; # strip percents. # remove section text if value set in transcript.conf if ( $t_TruncateSection ) { my ($tmp, @rest) = split /-/, $subjectcode; $subjectcode = $tmp; } $blockcounter++; # LaTeX filter possible fields with problems for LaTeX. ( $subjecttext ) = latex_filter( $subjecttext ); ( $score_mark ) = latex_filter( $score_mark ); ( $term_desc ) = latex_filter( $term_desc ); # In case... ( ) = latex_filter( ); $prevdesc = $currdesc; $currdesc = $term_desc; $prevschoolyear = $currschoolyear; $currschoolyear = $schoolyear; # if starting a new block, finish current totals, end table, start a new table. if ( $currdesc ne $prevdesc or $currschoolyear ne $prevschoolyear ) { if ( not $first ) { my ($gpa, $cumgpa); if ($semesterGPCredits) { $gpa = $fmt->format_number( ($semesterGPQuality / $semesterGPCredits), 4 ); } else { $gpa = 0; } if ( $totalGPCredits ) { $cumgpa = $fmt->format_number( ($totalGPQuality / $totalGPCredits), 4 ); } else { $cumgpa = 0; } $gpa = $fmt->format_number( $gpa, 2 ); $cumgpa = $fmt->format_number( $cumgpa, 2 ); print TEX " \\multicolumn{4}{\@{}l}{\\rule{0pt}{12pt}\\it\\small "; print TEX $lex{'Semester GPA'}. ": {\\bf $gpa} \\quad "; print TEX $lex{'Cum GPA'}. ": {\\bf $cumgpa}}\\\\\n"; $semesterAttempts = $fmt->format_number( $semesterAttempts, 2 ); # attempted $semesterCredits = $fmt->format_number( $semesterCredits, 2 ); # earned print TEX " \\multicolumn{4}{\@{}l}{\\it\\small ". $lex{'Credits Attempted'}; print TEX ": {\\bf $semesterAttempts} \\quad "; print TEX $lex{'Credits Earned'}. ": {\\bf $semesterCredits} }\\\\\n"; $semesterGPQuality = 0; $semesterGPCredits = 0; $semesterCredits = 0; $semesterAttempts = 0; print TEX "\\end{tabular}\n"; # end this (inner) table. if ( $colcounter % 2 ) { $blockCountA = $blockcounter; $blockcounter = 0; print TEX " & \n"; } else { # we are at the end of a block line print TEX " \\\\ \\hline\n"; # Now add up the lines $blockCountB = $blockcounter; $blockcounter = 0; if ( $blockCountA > $blockcounB ) { $linecounter += $blockCountA; } else { $linecounter += $blockCountB; } $linecounter += 4; # add 4 for a new block #print "LC:Block $linecounter
\n"; # Put in Split here for the if ( $linecounter > $maxlines ) { print TEX "\\end{tabular}"; if ( not $splitflag ) { # print Right Hand Column: Grad Requirements, etc. printRightColumn( $studnum ); $splitflag = 1; $linecounter = 0; } else { print TEX "\n"; } print TEX "\\begin{tabular}[t]{|p{ $blockwidth }|p{ $blockwidth }|}\\hline\n"; } # End of Splitter to fix formatting. } $colcounter++; $colorcounter = 1; } else { $first = 0; } # set tabular column layout for next block print TEX "\\begin{tabular}[t]{\@{\\hspace{1pt}}p{ $col1 }\@{\\hspace{2pt}}p{ $col2 }"; print TEX "\@{\\hspace{5pt}}p{ $col3 }\@{\\hspace{1pt}}p{ $col4 }\@{\\hspace{1pt}}}\n"; print TEX "\\multicolumn{4}{l}{\\rule{0pt}{12pt}\\bf $schoolyear - $currdesc}\\\\\n"; print TEX "\\multicolumn{4}{\@{}l}{\\it\\small\ " . $lex{Code}; print TEX " \\hspace{0.5in} ". $lex{Subject}; print TEX " \\hspace{0.7in} ". $lex{Credit}. " ". $lex{Grade}. "}\\\\ \n"; } # letterToQual hash in transcript.conf; add up quality scores and credit counts. # Check for missing Quality value in transcript.conf if ( not defined $letterToQual{ $score_letter } and $score_letter ne $passletter ) { print $lex{'No Quality Score for'}. " $score_letter
\n"; next; # skip } # Update Attempts $semesterAttempts += $credit; my $quality = 0; # Now do Pass Letter settings. if ( $score_letter eq $passletter ) { $semesterCredits += $credit; $totalCredits += $credit; } elsif ( $score_letter eq $failletter ) { # No additions to credits, GP credits increase to bring down avg. $totalGPCredits += $credit; $semesterGPCredits += $credit; } else { # calculate passing grade settings. $quality = $letterToQual{ $score_letter }; if ( $quality ) { # if we have a nonzero value, add in difficulty score. $quality += $score_diff; # difficulty factor } # Update Quality scores for weighted average. $semesterGPQuality += $quality * $credit; $totalGPQuality += $quality * $credit; # Update GP Credit totals for weighted average. $totalGPCredits += $credit; $semesterGPCredits += $credit; # Update the credits $semesterCredits += $credit; $totalCredits += $credit; } $credit = $fmt->format_number( $credit, 2); if ( $colorcounter % 2 ) { print TEX "\\rowcolor[gray]{ $grayscale }\n"; } $colorcounter ++; print TEX "\\small $subjectcode& \\raggedright\\small $subjecttext & "; print TEX "\\small $credit & \\small "; if ( $t_showMark ) { # set in transcript.conf print TEX "$score_mark \\\\ \n"; } else { print TEX "$score_letter \\\\ \n"; } } # Print the last GPA value... if ( not $first ) { my ($gpa, $cumgpa); if ($semesterGPCredits) { $gpa = $fmt->format_number( ( $semesterGPQuality / $semesterGPCredits ), 4 ); } else { $gpa = 0; } if ( $totalGPCredits ) { $cumgpa = $fmt->format_number( ( $totalGPQuality / $totalGPCredits ), 4 ); } else { $cumgpa = 0; } $gpa = $fmt->format_number( $gpa, 2 ); $cumgpa = $fmt->format_number( $cumgpa, 2 ); print TEX " \\multicolumn{4}{\@{}l}{\\rule{0pt}{12pt}\\it\\small "; print TEX $lex{'Semester GPA'}. ": {\\bf $gpa} \\quad "; print TEX $lex{'Cum GPA'}. ": {\\bf $cumgpa}}\\\\\n"; $semesterAttempts = $fmt->format_number( $semesterAttempts, 2); # attempted $semesterCredits = $fmt->format_number( $semesterCredits, 2); # earned print TEX " \\multicolumn{4}{\@{}l}{\\it\\small ". $lex{'Credits Attempted'}; print TEX ": {\\bf $semesterAttempts} \\quad "; print TEX $lex{'Credits Earned'}. ": {\\bf $semesterCredits} }\\\\\n"; print TEX "\\end{tabular}\n"; $semesterGPQuality = 0; $semesterGPCredits = 0; $semesterCredits = 0; $semesterAttempts = 0; } if ( $colcounter % 2 ) { print TEX " & \n"; } print TEX "\\\\ \\hline\\end{tabular}\n"; # print Right Hand Column: Grad Requirements, etc. if ( not $splitflag ) { # we haven't printed the right column yet... printRightColumn( $studnum ); } $pagecount++; } # End of Main Student Loop print TEX "\\end{document}\n"; close TEX; system("$pdflatex $filename >$logfile"); system("mv $shortname.pdf $downloaddir"); system("mv $logfile $downloaddir"); system("rm -f $shortname.*"); print "

\n"; print $lex{'View/Download'}. ' '. $lex{'Transcripts'}; print "

\n[ ". $lex{Main}. " |\n"; print "". $lex{'View Log File'}; print " ]"; print "\n"; exit; } #------------------- sub printRightColumn { # print the grad requirements, etc in right most col of pdf version #------------------- my $studnum = shift; # Now print the right hand column print TEX "\\raggedbottom\\parbox[t]{2in}{\n"; my $requiredTotal; my $earnedTotal; my $sth4 = $dbh->prepare("select id, score_letter, credit from tscriptdata where studnum = ? and subjectarea = ?"); if ( %gradRequirements ) { # if none defined in transcript.conf, don't print. print TEX "\\vspace{0.3in}{\\bf\\small\\quad "; print TEX $lex{'Graduation~Requirements'}. "\n\n"; print TEX "\\begin{tabular}{r\@{ \\hspace{4pt} }r\@{ \\hspace{4pt} }r\@{ \\hspace{2pt} }l}\n"; print TEX "\\it\\bf\\small ". $lex{'Subject'}. q{ }. $lex{'Area'}. "& \\it\\bf\\small "; print TEX $lex{Reqd}. "& \\it\\bf\\small ". $lex{Earned}. "& \\\\ \\hline \n"; foreach my $key (sort keys %gradRequirements ) { if ( $gradRequirements{$key} ) { # Any 0 credit elective is supressed... # Find courses for this subject area. $sth4->execute($studnum, $key); if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; } my $creditTotal = 0; # total credits for this area. while (my ( $id, $scoreletter, $credit ) = $sth4->fetchrow ) { if ( $scoreletter ne $failletter ) { $creditTotal += $credit; } } $earnedTotal += $creditTotal; $requiredTotal += $gradRequirements{$key}; print TEX "\\it\\small $key & \\it\\small ". $fmt->format_number( $gradRequirements{$key}, 2 ); print TEX "&\\it\\small ". $fmt->format_number( $creditTotal, 2); if ( $creditTotal >= $gradRequirements{$key} ) { print TEX "& \\ding{52} "; } else { print TEX "& "; } print TEX "\\\\ \n\n"; } # end of IF } # end of ForEach print TEX "\\hline\n"; # put in line separator between these 2 sections. # Now do the zero credit versions... normally only 'Other'. foreach my $key (sort keys %gradRequirements ) { if (not $gradRequirements{$key} ) { # Any 0 credit elective # Find courses for this subject area. $sth4->execute($studnum, $key); if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } my $creditTotal = 0; # total credits for this area. while (my ( $id, $scoreletter, $credit ) = $sth4->fetchrow ) { if ( $scoreletter ne $failletter ) { $creditTotal += $credit; } } $earnedTotal += $creditTotal; $requiredTotal += $gradRequirements{$key}; print TEX "\\it\\small $key & \\it\\small ". $fmt->format_number( $gradRequirements{$key}, 2 ); print TEX "&\\it\\small ". $fmt->format_number( $creditTotal, 2). " \\\\ \n\n"; # print TEX "\\it\\small $key & \\it\\small "; # print TEX $fmt->format_number( $gradRequirements{$key}, 2 ); # print TEX "&\\it\\small \\\\ \n\n"; } } print TEX "\\hline\n"; print TEX "\\it\\scriptsize ". $lex{Total}. "& \\it\\scriptsize "; print TEX $fmt->format_number( $requiredTotal, 2 ); print TEX "&\\it\\scriptsize "; print TEX $fmt->format_number( $earnedTotal, 2). " \\\\ \n\n"; print TEX "\\end{tabular}} \n\n"; print TEX "\\begin{center}\\it\\footnotesize \\ding{52} = "; print TEX $lex{'Requirements Complete'}. "\n\n"; print TEX "{\\tiny $section1}\n"; print TEX "\\end{center}\n"; if ( $globalGradDate ) { print TEX "\\vspace{0.5in}\n"; # Removed and replaced with below: print TEX "\\quad\\underline{\\hspace{2in}}\n\n"; print TEX "\\quad\\small ". $lex{'Diploma Awarded on'}. " $globalGradDate\n\n"; } } # end of If GradRequirements exist. print TEX "\\vspace{0.3in}\n"; print TEX "\\quad\\underline{\\hspace{2in}}\n\n\\quad\\small ". $lex{'Approved by'}. "\n\n"; print TEX "\\vspace{0.5in}\\begin{center}"; print TEX $lex{'Transcript is official when sealed'}. "\\end{center}\n\n"; print TEX "}\n\n\n"; # end of the right side... 3 CR at end are important. } # End of printRightColumn