#!/usr/bin/perl
# Copyright 2001-2008 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 = ('Main' => 'Main',
'No student found' => 'No student found',
'Missing master evaluation record id' => 'Missing master evaluation record id',
'or' => 'or',
'Missing student number' => 'Missing student number',
'Missing category number' => 'Missing category number',
'Edit Master Evaluation' => 'Edit Master Evaluation',
'Edit/Delete Other Evaluation Masters' => 'Edit/Delete Other Evaluation Masters',
'Dependent evaluation records exist' => 'Dependent evaluation records exist',
'If you change or delete objectives for this subject/category' =>
'If you change or delete objectives for this subject/category',
'please update any dependent records' => 'please update any dependent records',
'Update Record' => 'Update Record',
'Student' => 'Student',
'Subject Number' => 'Subject Number',
'Method' => 'Method',
'Responsible' => 'Responsible',
'Long Term Objective' => 'Long Term Objective',
'Objective' => 'Objective',
'There was an error storing your data' => 'There was an error storing your data',
'Contact' => 'Contact',
'Your update is now stored' => 'Your update is now stored',
);
my $self = 'evalmsted0.pl'; # drop zero later.
use DBI;
use CGI;
my $q = new CGI;
print $q->header;
my %arr = $q->Vars;
eval require "ppp.conf";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
my $dsn = "DBI:mysql:$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
# passed record to edit (recnum) or studnum and catnum
if ( $arr{recnum} ){
$sth = $dbh->prepare("select * from evalmst where id = ?");
$sth->execute( $arr{recnum} );
} elsif ($arr{studnum} and $arr{catnum} ) {
$sth = $dbh->prepare("select * from evalmst
where studnum = ? and subnum = ?");
$sth->execute( $arr{studnum}, $arr{catnum} );
} else { # We have an error!
print $lex{'Missing master evaluation record id'}. q{ };
print $lex{'or'}. q{ };
print $lex{'Missing student number'}. q{ }. $lex{or}. q{ };
print $lex{'Missing category number'}. "
\n";
die;
}
if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; }
my @arr = $sth->fetchrow;
# Get Student Name
my $sth1 = $dbh->prepare("select lastname,firstname from special where studnum = ?");
$sth1->execute( $arr[1] );
if ($DBI::errstr) { print $DBI::errstr;die $DBI::errstr; }
my ($lastname,$firstname) = $sth1->fetchrow;
if (not $lastname){ $lastname = $lex{'No student found'};}
# Get Category Description (ie. category)
$sth1 = $dbh->prepare("select category from subject where catnum = ?");
$sth1->execute( $arr[2] );
if ($DBI::errstr) { print $DBI::errstr;die $DBI::errstr; }
my $category = $sth1->fetchrow;
# Get Dependent Record(s) count (in eval table)
$sth1 = $dbh->prepare("select count(*) from eval where studnum = ? and subnum = ?");
$sth1->execute( $arr[1], $arr[2] );
if ($DBI::errstr) {print $DBI::errstr;die;}
my $evalcount = $sth1->fetchrow;
# Print Top of Page
print "$doctype\n
[ ". $lex{Main}. " |\n"; print "". $lex{'Edit/Delete Other Evaluation Masters'}. " ]\n"; print "