#! /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 = ('Assessment Entry' => 'Assessment Entry',
'No Subject Enrollment records found!' => 'No Subject Enrollment records found!',
'Main' => 'Main',
'System Disabled. Please contact the secretary.' =>
'System Disabled. Please contact the secretary.',
'Mark' => 'Mark',
'Move between fields using the Tab and Shift-Tab keys' =>
'Move between fields using the Tab and Shift-Tab keys',
'It is faster!' => 'It is faster!',
'Term' => 'Term',
'Save Assessments' => 'Save Assessments',
'Trm' => 'Trm',
'Objective' => 'Objective',
'Comment' => 'Comment',
'Previous' => 'Previous',
'Your assessments are now stored in the database' =>
'Your assessments are now stored in the database',
'There was an error storing your data' => 'There was an error storing your data',
'Please contact' => 'Please contact',
'Please record' => 'Please record',
'Enter More Assessments' => 'Enter More Assessments',
'Please Log In' => 'Please Log In',
'Error' => 'Error',
'Current Evaluation' => 'Current Evaluation',
);
my $self = 'markadd1.pl';
use DBI;
use CGI;
use CGI::Session;
eval require "../../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. " $@ \n";
die $lex{Error}. " $@\n";
}
eval require "../../etc/repcard.conf";
if ( $@ ) {
print $lex{Error}. " $@ \n";
die $lex{Error}. " $@\n";
}
my $q = new CGI;
my %arr = $q->Vars;
my $subjsec = $arr{subjsec}; # passed in...
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
# Get Session Information...
my $session = new CGI::Session("driver:mysql;serializer:FreezeThaw",
undef,{Handle => $dbh}) or die CGI::Session->errstr;
my $userid;
if ( not $session->param('logged_in') ){
$userid = $session->param('userid');
print $q->header;
print "$doctype\n
\n";
if ( $userid and $arr{writeflag} ) { # update records if user exists and writeflag set.
delete $arr{writeflag};
updateRecords();
print $lex{'Please Log In'};
die;
} else {
print $lex{'Please Log In'};
print "
\n";
die;
}
}
# Ok, we have a login. Values below we have in environment.
$userid = $session->param('userid');
$duration = $session->param('duration');
if (not ($duration =~ m/\+/)) {
$duration = '+'. $duration. 'm';
}
$session->expire('logged_in',$duration);
print $session->header;
print "$doctype\n". $lex{'Assessment Entry'}. "\n";
print "\n";
print "\n";
# Some Javascript here for resizing...
print "\n";
print "$chartype\n\n";
# End of HTML Head section.
# Get Subject Info: Description, Grade
my $sth = $dbh->prepare("select description, grade from subject where subjsec = ?");
$sth->execute($subjsec);
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr;}
my ($description, $grade) = $sth->fetchrow;
my $acMode = 0; # Additional Comments don't have any values but a comment...
if ( $description eq $additionalcomments ) { # $additionalcomments set in admin.conf
$acMode = 1;
}
my $subjectname;
if ($description =~ m/$grade/) {
$subjectname = $description;
} else {
$subjectname = "$description $grade";
}
# Get Subject Objectives and Put in @qstarray
$sth = $dbh->prepare("select * from subject where subjsec = ?");
$sth->execute($subjsec);
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr;}
my @subject = $sth->fetchrow;
my @qstarray;
# Stuff questions into the array.
for ($a = 10;$a<=29; $a++) {
if ($subject[$a]) { push @qstarray, $subject[$a]; }
}
if ( not $subject[10] ) { # blank qstarray
# We must put in one question.
push @qstarray, $lex{Mark};
}
# Read in the term(s)
my ($term, @terms, %terms);
open(TERM, "../../etc/term") || die "Can't open the term file!"; # slurp file
my $data;
{ local $/; $data = ; close FH;}
my @terms = split /\n/, $data;
$term = $terms[0];
# multiTrack variable is set in the admin.conf file.
if ($multiTrack) { # Are we in multiTrack mode? If so, reset term.
for my $t (1..$#terms) {
my ($key, $val) = split /:/, $terms[$t];
$terms{$key} = $val; # Form is e:3 (elementary: term 3)
}
my $grp = $g_termtype{$grade};
if ( $terms{$grp} ) {
$term = $terms{$grp};
}
}
# Check if disabled...
if ($term == 0) {
print " ". $lex{'System Disabled. Please contact the secretary.'}. "\n";
print "\n";
die;
}
# Update Records
if ( $arr{writeflag} ) {
delete $arr{writeflag};
updateRecords();
}
# Get the students in this subjsect, in name order.
$sth = $dbh->prepare("select distinct eval.studnum from eval, student
where eval.subjcode = ?
and eval.studnum = student.studnum and eval.term = ?
order by student.lastname, student.firstname ");
$sth->execute($subjsec, $term);
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; }
my @students;
while (my $studnum = $sth->fetchrow ) {
push @students, $studnum;
}
if ( not @students ) {
print "
". $lex{'No Subject Enrollment records found!'}. "