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.

80 lines
1.9 KiB

#!/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'}="<OPTION VALUE=\"New\"$bselected> New\n";
for (0 .. $#pagenos) {
$bselected = ($FORM{'page'} eq $pagenos[$_]) ? " SELECTED" : "";
$FORM{'pagenos'}= join('',$FORM{'pagenos'},"<OPTION VALUE=\"$pagenos[$_]\"$bselected> $pagenos[$_]\n");
}
if ($FORM{'page'} eq 'New') {
$FORM{'html'}="<HTML>
<HEAD>
<TITLE>$TEST{'desc'} Worksheet $pageno</TITLE>
</HEAD>
<BODY>
<CENTER>
$TEST{'desc'} Worksheet 1<BR>
for use with questions (1-?)<BR>
</CENTER>
</BODY>
</HTML>
";
} else {
$FORM{'html'} = &get_test_worksheet($TEST{'id'},$CLIENT{'clid'},$FORM{'page'});
}
}
sub delete_worksheet_page() {
return 1;
}