#!/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{'Edit Master Evaluation'}. "\n"; print "\n"; print "[ ". $lex{Main}. " | \n"; print "". $lex{'Edit/Delete Other Evaluation Masters'}. " ]\n"; print "

". $lex{'Edit Master Evaluation'}. "

\n"; if ( $arr{writeflag} ) { delete $arr{writeflag}; writeRecord(); } print "
$evalcount "; print $lex{'Dependent evaluation records exist'}; print ".\n". $lex{'If you change or delete objectives for this subject/category'}. q{, }; print $lex{'please update any dependent records'}. ".

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; for ( my $i=1;$i<=32;$i++) { my $index = $i + 2; my $name = "obj$i"; print "\n"; print "\n"; } print "
\n"; print "
$firstname $lastname
". $lex{'Subject Number'}. ""; print " $category
". $lex{Method}. "
". $lex{Responsible}. "
". $lex{'Long Term Objective'}. "
". $lex{Objective}. " $i\n"; print "
\n"; #-------------- sub writeRecord { #-------------- foreach my $key ( keys %arr ) { print "K:$key V:$arr{$key}
\n"; } die; foreach my $key (keys %arr ) { if ( $arr{$key} ) { $arr{$key} = $dbh->quote( $arr{$key} ); } else { $arr{$key} = $sql{default}; } } my $sth = $dbh->prepare("update evalmst set subnum=$arr{subject}, method=$arr{method}, responsible=$arr{responsible}, longtermobjective=$arr{longtermobjective}, obj1=$arr{obj1}, obj2=$arr{obj2}, obj3=$arr{obj3}, obj4=$arr{obj4}, obj5=$arr{obj5}, obj6=$arr{obj6}, obj7=$arr{obj7}, obj8=$arr{obj8}, obj9=$arr{obj9}, obj10=$arr{obj10},obj11=$arr{obj11}, obj12=$arr{obj12}, obj13=$arr{obj13}, obj14=$arr{obj14}, obj15=$arr{obj15}, obj16=$arr{obj16}, obj17=$arr{obj17}, obj18=$arr{obj18}, obj19=$arr{obj19}, obj20=$arr{obj20}, obj21=$arr{obj21}, obj22=$arr{obj22}, obj23=$arr{obj23}, obj24=$arr{obj24}, obj25=$arr{obj25}, obj26=$arr{obj26}, obj27=$arr{obj27}, obj28=$arr{obj28}, obj29=$arr{obj29}, obj30=$arr{obj30}, obj31=$arr{obj31}, obj32=$arr{obj32} where id = $arr{recnum}"); $sth->execute; if ( not $DBI::errstr ) { print "

". $lex{'Your update is now stored'}. ".

\n"; } else { print "

". $lex{'There was an error storing your data'}. ". \n"; print $lex{Contact}. " $adminname $adminemail\n"; print $lex{Error}. " :$DBI::errstr \n"; } print "

[ ". $lex{Main}. " |\n"; print "". $lex{'Edit/Delete Other Evaluation Masters'}. " ]\n"; print "\n"; exit; }