#!/usr/bin/perl
#
# $Id: tworksheet.pl,v 1.3 2006/01/23 21:39:30 ddoughty Exp $
#
# Source File: tworksheet.pl
# Get config
require 'sitecfg.pl';
&app_initialize;
print "Content-Type: text/html\n\n";
if (&get_session($FORM{'tid'})) {
&LanguageSupportInit();
&get_client_profile($SESSION{'clid'});
&get_test_profile($SESSION{'clid'}, $FORM{'tstid'});
if ($FORM{'Save'} ne '') {
&save_worksheet();
&get_test_profile($SESSION{'clid'}, $FORM{'tstid'});
} elsif ($FORM{'Delete'} ne '') {
&delete_worksheet_page();
&get_test_profile($SESSION{'clid'}, $FORM{'tstid'});
$FORM{'page'} = "";
}
&set_form_variables();
&show_template("tworksheet");
}
sub save_worksheet {
@pages = split(/\./, $TEST{'Ins'});
if ($FORM{'page'} eq 'New') {
if ($#pages == -1) {
$pageno = "001";
} else {
$x = int($pages[$#pages])+1;
$temp = "00000";
$y = 3 - length("$x");
$pageno = substr($temp,0,$y);
$pageno = join('', $pageno, "$x");
}
} else {
$pageno = $FORM{'page'};
}
$saveok = &put_test_worksheet($TEST{'id'},$CLIENT{'clid'},$pageno,$FORM{'wrkshthtml'});
if ($saveok) { $FORM{'page'} = $pageno;}
return $saveok;
}
sub set_form_variables {
@pagenos = split(/\./,$TEST{'Ins'});
$bselected = ($#pagenos == -1) ? " SELECTED" : "";
if ($FORM{'page'} eq '') { $FORM{'page'} = ($#pagenos != -1) ? $pagenos[0] : "New";}
$FORM{'pagenos'}="