#!/usr/bin/perl
# Copyright 2001-2020 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.
# Passed Values: Subject/Section value (passed as subjsec).
# change right side values for alternate languages, let me know of any mistakes
my %lex = ('All' => 'All',
'All Groups' => 'All Groups',
'All Terms' => 'All Trm',
'Please Log In' => 'Please Log In',
'No User Id' => 'No User Id',
'No Password' => 'No Password',
'Select Subject' => 'Select Subject',
'Delete' => 'Delete',
'Edit' => 'Edit',
'Add' => 'Add',
'Assessment Item' => 'Assessment Item',
'Del/Ed Item' => 'Del/Ed Item',
'Reports' => 'Reports',
'Rpt' => 'Rpt',
'Adjust the weights of individual assessment items' =>
'Adjust the weights of individual assessment items',
'Weight Item' => 'Weight Item',
'Adjust the weightings of groups of assessment items' =>
'Adjust the weightings of groups of assessment items',
'Weight Grp' => 'Weight Grp',
'Post (copy) student averages to the report card system' =>
'Post (copy) student averages to the report card system',
'Post' => 'Post',
'Export these grades to a CSV file' =>
'Export these grades to a CSV file',
'Exp' => 'Exp',
'Maintenance: Sortorder, Withdraw, etc' =>
'Maintenance: Sortorder, Withdraw, etc',
'Mtce' => 'Mtce',
'Edit multiple scores at the same time' =>
'Edit multiple scores at the same time',
'MultiEdit' => 'MultiEdit',
'No Maximum Score for Test' => 'No Maximum Score for Test',
'Main' => 'Main',
'Search' => 'Search',
'Error' => 'Error',
'Log Out' => 'Log Out',
'Assessments' => 'Assessments',
'Test Weight' => 'Test Weight',
'Test Average' => 'Test Average',
'Avg' => 'Avg',
'Version' => 'Version',
'Gradebook' => 'Gradebook',
'NA' => 'NA',
'No Tests Found' => 'No Tests Found',
);
my $self = 'gbmain.pl';
my $version = '2018-11-15';
my $specchar = '*'; # causes this test to be skipped in calculating avg.
my $minimumtime = 1; # Minimum time for cookie duration.
my $maximumtime = 60; # Max cookie time.
my $defaulttime = 30; # Default cookie time.
my $altcolor = '#3B7'; #1B6 Complement to the 063 green of teacher site.
my $maincolor = '#063';
use DBI;
use CGI::Session;
use CGI qw/:escape unescape/;
use Number::Format qw(round);
my $q = CGI->new;
my %arr = $q->Vars; # Get passed values
my $showwithdrawn = $arr{showwithdrawn};
delete $arr{showwithdrawn};
# only for testing.
# print $q->header( -charset, $charset );
eval require "../../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@
\n";
}
eval require "../../etc/gbook.conf";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@
\n";
}
eval require "../../lib/libsession.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@
\n";
}
# calcAverage and mkstudnum
eval require "./libgbook.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@
\n";
}
# needed to $additionalcomments subject so that it can be skipped.
eval require "../../etc/repcard.conf";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@
\n";
}
my $dbtype = 'mysql';
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
my ($sec, $min, $hour, $mday, $mon, $year, $wday,
$yday, $iddst) = localtime(time);
$year = $year + 1900;
$mon++;
$wday++;
$currdate = "$dow[$wday], $month[$mon] $mday, $year";
# Define Userid
my $userid;
if ($arr{userid}) {
$userid = $arr{userid};
}
# define term. This will pass through session setup and be defined in
# session if it exists, and otherwise will be read from session. If it
# doesn't exist in the session, it will be set to the $lex{'All Terms'}
# value.
my $term; # current term
if ( $arr{term} ) {
$term = $arr{term};
}
# Define View and Subview
my ($view, $subview);
if ($arr{vw} and $arr{subview}){
$view = $arr{vw};
$subview = $arr{subview};
} elsif ($arr{vw}) { # only is defined, split it.
my ($g,$sg) = split(/:/,$arr{vw});
if ($sg){ # vw contains a subgroup...
$subview = $sg;
$view = $g;
} else { # no subgroup
$view = $arr{vw};
$subview = $lex{All};
}
}
# Define $subjsec
my $subjsec;
if ($arr{subjsec}){
$subjsec = $arr{subjsec};
}
my $session = new CGI::Session("driver:$dbtype;serializer:FreezeThaw",
undef,{Handle => $dbh}) or die CGI::Session->errstr;
# Check for Logout
if ($arr{logout}){
$session->delete;
$session->flush;
print $q->header( -charset, $charset );
login( $lex{'Please Log In'} );
print qq{