You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
325 lines
9.7 KiB
325 lines
9.7 KiB
4 months ago
|
#!/usr/bin/perl
|
||
|
#
|
||
|
# $Id: tadmin.pl,v 1.10 2006/08/21 20:13:44 psims Exp $
|
||
|
#
|
||
|
# Source File: tadmin.pl
|
||
|
|
||
|
# Get config
|
||
|
require 'sitecfg.pl';
|
||
|
require 'testlib.pl';
|
||
|
require 'sbalib.pl';
|
||
|
|
||
|
&app_initialize;
|
||
|
|
||
|
print "Content-Type: text/html\n\n";
|
||
|
|
||
|
if (&get_session($FORM{'tid'})) {
|
||
|
&LanguageSupportInit();
|
||
|
# warn "dbop is $FORM{'dbop'} " ;
|
||
|
&get_client_profile($SESSION{'clid'});
|
||
|
$isregistrar = &get_a_key("cnd.$SESSION{'clid'}", $SESSION{'uid'}, "registrar");
|
||
|
if ($FORM{'dbop'} eq 'tnew') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Define New Test");
|
||
|
@lines = &get_template("tdef");
|
||
|
&test_new_response;
|
||
|
} elsif ($FORM{'dbop'} eq'tdel') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Delete Test $FORM{'tstid'}");
|
||
|
#hkh 03/04 get date&time stamp - bug#103
|
||
|
$deltime = &format_date_time("yymmddhhnnss", "2", "0");
|
||
|
&test_delete_response($SESSION{'clid'}, $FORM{'tstid'}, $deltime);
|
||
|
&test_files_delete($SESSION{'clid'}, $FORM{'tstid'}, $deltime);
|
||
|
&complete_inprog_pending_test_del($SESSION{'clid'}, $FORM{'tstid'}, $deltime);
|
||
|
&show_template("tdefframe");
|
||
|
} elsif ($FORM{'dbop'} eq 'tupd') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Edit Test $FORM{'tstid'}");
|
||
|
@lines = &get_template("tdef");
|
||
|
&test_update_response($SESSION{'clid'}, $FORM{'tstid'});
|
||
|
} elsif ($FORM{'dbop'} eq 'cnew') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "New Candidate");
|
||
|
if ($isregistrar eq "Y") {
|
||
|
$SESSION{'registrar'} = "Y";
|
||
|
}
|
||
|
@lines = &get_template("addcnd");
|
||
|
&candidate_new_response;
|
||
|
} elsif ($FORM{'dbop'} eq 'cdel') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Delete Candidate $FORM{'cndid'}");
|
||
|
#hkh 03/04 get date&time stamp - bug#103
|
||
|
$deltime = &format_date_time("yymmddhhnnss", "2", "0");
|
||
|
&candidate_delete_response($SESSION{'clid'}, $FORM{'cndid'}, $deltime);
|
||
|
&complete_inprog_pending_cand_test_del($SESSION{'clid'}, $FORM{'cndid'}, $deltime);
|
||
|
$filterbydate = $FORM{'filterbydate'};
|
||
|
$FORM{'dtl'} = 8; #I have no idea why this must be set, but it needs to be
|
||
|
$FORM{'filterbydate'} = "Y";
|
||
|
$filterbydate = $FORM{'filterbydate'};
|
||
|
$day_filter = $FORM{'day_filter'};
|
||
|
$date_filter = $FORM{'date_filter'};
|
||
|
$cnd1_filter = $FORM{'cnd1'};
|
||
|
$cnd2_filter = $FORM{'cnd2'};
|
||
|
$cnd3_filter = $FORM{'cnd3'};
|
||
|
$cnd4_filter = $FORM{'cnd4'};
|
||
|
$CANDIDATE{'registrar'} = $isregistrar;
|
||
|
&show_template("maintcnd");
|
||
|
} elsif ($FORM{'dbop'} eq 'cupd') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Edit Candidate $FORM{'cndid'}");
|
||
|
if ($isregistrar eq "Y") {
|
||
|
$SESSION{'registrar'} = "Y";
|
||
|
}
|
||
|
@lines = &get_template("addcnd");
|
||
|
&candidate_update_response($SESSION{'clid'}, $FORM{'cndid'});
|
||
|
} elsif ($FORM{'dbop'} eq 'gnew') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "New Group Registration");
|
||
|
@lines = &get_template("grpdef");
|
||
|
&group_new_response;
|
||
|
} elsif ($FORM{'dbop'} eq 'gdel') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Delete Group Registration $FORM{'grpid'}");
|
||
|
&group_delete_response($SESSION{'clid'}, $FORM{'grpid'});
|
||
|
$showmessage = "Group $FORM{'grpid'} has been deleted.";
|
||
|
&show_message_with_close($showmessage);
|
||
|
} elsif ($FORM{'dbop'} eq 'gupd') {
|
||
|
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Edit Group Registration $FORM{'grpid'}");
|
||
|
@lines = &get_template("grpdef");
|
||
|
&group_update_response($SESSION{'clid'}, $FORM{'grpid'});
|
||
|
} else {
|
||
|
&show_illegal_access_warning;
|
||
|
}
|
||
|
} else {
|
||
|
warn "Missing Session id in FORM " ;
|
||
|
&show_illegal_access_warning;
|
||
|
}
|
||
|
|
||
|
sub test_new_response {
|
||
|
$FORM{'newtest'} = "Y";
|
||
|
$TEST{'seq'} = $FORM{'seq'};
|
||
|
if ( ! setup_avail_settings(\%TEST ) ) {
|
||
|
&logger::logerr("Unable to setup availability window");
|
||
|
}
|
||
|
foreach $line (@lines) {
|
||
|
$line=&xlatline($line);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub candidate_new_response {
|
||
|
$FORM{'new'} = "Y";
|
||
|
$FORM{'prevenb'} = 0;
|
||
|
$FORM{'nxtenb'} = 0;
|
||
|
foreach $line (@lines) {
|
||
|
$line=&xlatline($line);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub group_new_response {
|
||
|
$FORM{'new'} = "Y";
|
||
|
foreach $line (@lines) {
|
||
|
$line=&xlatline($line);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub test_update_response {
|
||
|
$TEST{'new'} = "N";
|
||
|
&get_test_profile($_[0], $_[1]);
|
||
|
$SUBJAREA{'subjskillcgt'}=&get_subjskill_cntgrdtbl($SESSION{'clid'}, $TEST{'id'}, "");
|
||
|
foreach $line (@lines) {
|
||
|
$line=&xlatline($line);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub candidate_update_response {
|
||
|
my $cndid;
|
||
|
my $prevenb;
|
||
|
my $nxtenb;
|
||
|
$FORM{'new'} = "N";
|
||
|
($cndid,$prevenb,$nxtenb)=&get_candidate_list_nav($_[0],$_[1],'nop',$FORM{'sortedkey'});
|
||
|
$FORM{'prevenb'} = $prevenb unless $isregistrar eq 'Y';
|
||
|
$FORM{'nxtenb'} = $nxtenb unless $isregistrar eq 'Y';
|
||
|
&get_candidate_profile($_[0], $_[1]);
|
||
|
foreach $line (@lines) {
|
||
|
$line=&xlatline($line);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub group_update_response {
|
||
|
$FORM{'new'} = "N";
|
||
|
&get_candidate_profile($_[0], $_[1]);
|
||
|
foreach $line (@lines) {
|
||
|
$line=&xlatline($line);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub test_delete_response {
|
||
|
@trecs = &get_test_list($_[0]);
|
||
|
#hkh 03/04 write test file to recycle dir before deleting test record - bug#103
|
||
|
$testfile = "tests.$clid";
|
||
|
$oldfile = join($pathsep, $dataroot, $testfile);
|
||
|
my $newfile = join($pathsep, $recydataroot, "$testfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
|
||
|
foreach $trec (@trecs) {
|
||
|
chop ($trec);
|
||
|
($id, $trash) = split(/\&/, $trec);
|
||
|
if ($_[1] ne $id) {
|
||
|
push @newtests, $trec;
|
||
|
}
|
||
|
}
|
||
|
@trecs = @newtests;
|
||
|
&save_test_list($_[0]);
|
||
|
}
|
||
|
|
||
|
#hkh 03/04 write custom/mtx/question/logo etc. to recycle dir before deleting -
|
||
|
# bug#103
|
||
|
sub test_files_delete {
|
||
|
if ( ! opendir(DIR, $questionroot) ) {
|
||
|
return 0;
|
||
|
}
|
||
|
my $regex = "^$_[1]".'\.'."$_[0]".'(.*)$';
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir(DIR);
|
||
|
foreach my $srcfile ( @filenames ) {
|
||
|
if ( $srcfile =~ /^$_[1].$_[0](.*)$/ ) {
|
||
|
$oldfile = join($pathsep, $questionroot, $srcfile);
|
||
|
my $newfile = join($pathsep, $recyquestionroot, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
# print "$oldfile deleted $! ...<BR>\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# delete logo files
|
||
|
if ( ! opendir(DIR, $testgraphic) ) {
|
||
|
return 0;
|
||
|
}
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir(DIR);
|
||
|
my $regex = "^$_[0]".'\.'."$_[1]".'(.*)$';
|
||
|
foreach my $srcfile ( @filenames ) {
|
||
|
if ( $srcfile =~ /^$_[0].$_[1].0(.*)$/ ) {
|
||
|
$oldfile = join($pathsep, $testgraphic, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestgraphic, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
# print "$oldfile deleted $! ...<BR>\n";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#hkh 03/04 write completed/inprog/pending files for the deleted test to recycle
|
||
|
# directory before deleting - bug#103
|
||
|
sub complete_inprog_pending_test_del {
|
||
|
opendir(DIR, $testcomplete);
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir DIR;
|
||
|
foreach $srcfile (@filenames) {
|
||
|
if ($srcfile =~ /^$clid\./ ) {
|
||
|
if (($srcfile =~ /\.$_[1]/) || ($srcfile =~ /\.$_[1].tim/)) {
|
||
|
$oldfile = join($pathsep, $testcomplete, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestcomplete, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
opendir(DIR, $testinprog);
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir DIR;
|
||
|
foreach $srcfile (@filenames) {
|
||
|
if ($srcfile =~ /^$clid\./ ) {
|
||
|
if (($srcfile =~ /\.$_[1]/) || ($srcfile =~ /\.$_[1].tim/)) {
|
||
|
$oldfile = join($pathsep, $testinprog, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestinprog, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
opendir(DIR, $testpending);
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir DIR;
|
||
|
foreach $srcfile (@filenames) {
|
||
|
if ($srcfile =~ /^$clid\./ ) {
|
||
|
if (($srcfile =~ /\.$_[1]/) || ($srcfile =~ /\.$_[1].tim/)) {
|
||
|
$oldfile = join($pathsep, $testpending, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestpending, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
sub candidate_delete_response {
|
||
|
# &remove_pending_tests($_[0], $_[1]);
|
||
|
#hkh 03/04 write candidate file to recycle dir before deleting cand record - bug#103
|
||
|
$srcfile = "cnd.$_[0]";
|
||
|
$oldfile = join($pathsep, $dataroot, $srcfile);
|
||
|
my $newfile = join($pathsep, $recydataroot, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
|
||
|
@crecs = &get_data("cnd.$_[0]");
|
||
|
$trash = join( $pathsep, $dataroot, "cnd.$_[0]");
|
||
|
open (TSTFILE, ">$trash");
|
||
|
foreach $crec (@crecs) {
|
||
|
($clid, $trash) = split(/\&/, $crec);
|
||
|
if ($_[1] ne $clid) {
|
||
|
print TSTFILE "$crec";
|
||
|
}
|
||
|
}
|
||
|
close TSTFILE;
|
||
|
}
|
||
|
|
||
|
sub complete_inprog_pending_cand_test_del {
|
||
|
#hkh 03/04 write completed/inprog/pending files for the deleted cand. to recycle
|
||
|
# directory before deleting - bug#103
|
||
|
opendir(DIR, $testcomplete);
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir DIR;
|
||
|
foreach $srcfile (@filenames) {
|
||
|
if ($srcfile =~ /^$_[0].$_[1]\./ ) {
|
||
|
$oldfile = join($pathsep, $testcomplete, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestcomplete, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
opendir(DIR, $testinprog);
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir DIR;
|
||
|
foreach $srcfile (@filenames) {
|
||
|
if ($srcfile =~ /^$_[0].$_[1]\./ ) {
|
||
|
$oldfile = join($pathsep, $testinprog, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestinprog, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
opendir(DIR, $testpending);
|
||
|
@filenames = readdir(DIR);
|
||
|
closedir DIR;
|
||
|
foreach $srcfile (@filenames) {
|
||
|
if ($srcfile =~ /^$_[0].$_[1]\./ ) {
|
||
|
$oldfile = join($pathsep, $testpending, $srcfile);
|
||
|
my $newfile = join($pathsep, $recytestpending, "$srcfile.$_[2]");
|
||
|
cpbin("$oldfile", "$newfile", 1);
|
||
|
$cnt = unlink $oldfile;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
sub group_delete_response {
|
||
|
# &remove_pending_tests($_[0], $_[1]);
|
||
|
# @crecs = &get_data("cnd.$_[0]");
|
||
|
# $trash = join( $pathsep, $dataroot, "cnd.$_[0]");
|
||
|
# open (TSTFILE, ">$trash");
|
||
|
# foreach $crec (@crecs) {
|
||
|
# ($clid, $trash) = split(/\&/, $crec);
|
||
|
# if ($_[1] ne $clid) {
|
||
|
# print TSTFILE "$crec";
|
||
|
# }
|
||
|
# }
|
||
|
# close TSTFILE;
|
||
|
}
|