#!/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 = ('Please enter a Subject-Section code!' => 'Please enter a Subject-Section code!', 'Single Subject Enrollment' => 'Single Subject Enrollment', 'Main' => 'Main', 'Report Card' => 'Report Card', 'Subject not found' => 'Subject not found', 'Continue' => 'Continue', 'Students' => 'Students', 'Select' => 'Select', 'Error' => 'Error', ); use DBI; use CGI; eval require "../../etc/admin.conf"; if ( $@ ) { print $lex{Error}. " $@
\n"; die $lex{Error}. " $@\n"; } my $q = new CGI; print $q->header; my %arr = $q->Vars; print "$doctype\n". $lex{'Single Subject Enrollment'}; print "\n"; print "$chartype\n\n"; print "[ ". $lex{Main}. " | \n"; print "". $lex{'Report Card'}. " ]\n"; print "

". $lex{'Single Subject Enrollment'}. "

\n"; if (not $arr{subjsec}){ print "

". $lex{'Please enter a Subject-Section code!'}. "

\n"; print "\n"; die; } my $subjsec = $arr{subjsec}; my $checked = $arr{checked}; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); # First find the subject record of subject to add. $sth = $dbh->prepare("select description, subjsec, grade from subject where subjsec = ?"); $sth->execute($subjsec); if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } my $subjrows = $sth->rows; if ($subjrows < 1){ print "

". $lex{'Subject not found'}. "!

\n"; print "\n"; die; } my ($description,$subjsec,$grade) = $sth->fetchrow; # Loop through students identifying groups and assg subject,teacher. my $sth = $dbh->prepare("select lastname,firstname,initial,studnum from student order by lastname, firstname"); $sth->execute; if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } my $studrows = $sth->rows; print "

$description ($subjsec) ". $lex{Students}. ": $studrows

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; while( my ($lastname, $firstname, $middlename, $studnum) = $sth->fetchrow) { print "\n"; print "\n"; } print "
". $lex{Students}. "". $lex{Select}. "
$lastname, $firstname $middlename ($studnum)
\n"; print "\n"; print "
\n";