#!/usr/bin/perl
# Copyright 2001-2021 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',
'Error' => 'Error',
'Edit' => 'Edit',
'Name' => 'Name',
'Update' => 'Update',
'Score' => 'Score',
'Test Date' => 'Test Date',
'No Blanks Allowed' => 'No Blanks Allowed',
'No User Id' => 'No User Id',
'No Password' => 'No Password',
'Please Log In' => 'Please Log In',
'Record(s) Updated' => 'Record(s) Updated',
'Edit not allowed' => 'Edit not allowed',
'Raw Score' => 'Raw Score',
'Continue' => 'Continue',
'Standard Score' => 'Standard Score',
'Confidence' => 'Confidence',
'Interval' => 'Interval',
'Percentile' => 'Percentile',
'Normal Curve Equivalent' => 'Normal Curve Equivalent',
'Stanine' => 'Stanine',
'Growth Scale Value' => 'Growth Scale Value',
'Age' => 'Age',
'Equivalent' => 'Equivalent',
'Period' => 'Period',
'Score' => 'Score',
'Math' => 'Math',
'Scores' => 'Scores',
'Date' => 'Date',
'Close' => 'Close',
);
use DBI;
use CGI;
use CGI::Session;
my $self = 'mathTestEdit.pl';
# NOW in config file math.conf
# my @phases = qw(Emergent Matching Quantifying Partitioning Factoring Operating);
# my @seasons = qw(Sep-2012 Nov-2012 Apr-2013 Sep-2013 Nov-2013 Apr-2014 Sep-2014 Nov-2014);
# Configuration Settings -----------------------
my $allow_author = 1; # allow author to edit
my $allow_fsim = 1; # allow user with math access code to edit
#-----------------------------------------------
my $q = new CGI;
my %arr = $q->Vars;
my @time = localtime(time);
my $year = $time[5] + 1900;
my $month = $time[4] + 1;
my $currdate = "$year-$month-$time[3]";
eval require "../../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. " $self: $@
\n";
die $lex{Error}. "$self: $@\n";
}
eval require "./fsim.conf";
if ( $@ ) {
print $lex{Error}. " $self: $@
\n";
die $lex{Error}. "$self: $@\n";
}
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
# Session Setup Here
my $session = new CGI::Session("driver:mysql;serializer:FreezeThaw",
undef,{Handle => $dbh}) or die CGI::Session->errstr;
# Get/Set Session Values (a defined userid means it was passed)
if ( $arr{userid} ){ # we want to login, passed userid/password pair.
# Check password/userid against database (-1 no user, -2 wrong password);
my $error = checkPassword($arr{userid}, $arr{password}, $dbh);
if ($error == -1){ print $q->header( -charset, $charset ); login($lex{'No User Id'}); }
if ($error == -2){ print $q->header( -charset, $charset ); login($lex{'No Password'}); }
$cookietime = checkCookieTime( $arr{duration} );
# Set values for userid and logged_in in session
$session->param( 'logged_in','1');
$session->expire( 'logged_in', $cookietime );
$session->param( 'userid',$arr{userid} );
$session->param( 'duration',$cookietime );
$userid = $arr{userid};
} else { # check logged_in value in session
if ( not $session->param('logged_in') ){
$userid = $session->param('userid');
print $q->header( -charset, $charset );
print qq{$lex{'Please Log In'}