\n};
if ( not $arr{flag} ) {
showStartPage();
} elsif ( $arr{newgrp} and $arr{flag} != 2 ) {
delete $arr{flag};
getGroupPercent( $subjsec );
} else {
delete $arr{flag};
addRecord();
}
#----------------
sub showStartPage {
#----------------
# Get assessment groups and put into %group; not really needed??
my %group;
my $sth = $dbh->prepare("select distinct grp from gbtest
where subjsec = ? and grp != '' order by grp");
$sth->execute( $subjsec );
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; }
while ( my $grp = $sth->fetchrow ) {
$group{$grp} = 1;
}
# foreach my $key ( sort keys %group) {
# print qq{K:$key VAL:$group{$key} \n};
# }
# Load the markscheme field
$sth = $dbh->prepare("select markscheme from subject where subjsec = ?");
$sth->execute( $subjsec );
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; }
my $markscheme = $sth->fetchrow;
# print qq{Mark Scheme: $markscheme \n};
# add to the %group hash above; removing duplicates effectively.
my @fields = split (/[\n|\r]/, $markscheme); # separate into lines.
foreach my $fld (@fields) {
if ($fld) {
my ($grp, $percent) = split('=', $fld);
$group{$grp} = $percent;
}
}
# Test
# foreach my $grp ( sort keys %group ) {
# print qq{MS Grp:$grp Per:group{$grp} \n};
# }
# Get Subject-Section name.
$sth = $dbh->prepare("select description from subject where subjsec = ?");
$sth->execute( $subjsec );
if ($DBI::errstr){ print $DBI::errstr; die; }
my $description = $sth->fetchrow;
print qq{
$description ($subjsec)
\n};
# Print Start of Form.
print qq{\n};
print qq{\n};
print qq{\n};
exit;
} # end of showStartPage
#------------
sub addRecord {
#------------
# foreach my $key ( sort keys %arr ) { print qq{K:$key V:$arr{$key} \n}; }
my $subjsec = $arr{subjsec};
my $weight = $arr{weight};
# either weight or multiplier passed, not both. Depends on mode set.
if ( $arr{multiplier} ) {
# was: my $multiplier = $wtmult{$arr{multiplier}};
my $multiplier = $arr{multiplier};
$weight = $defaultItemWeight * $arr{multiplier};
# print qq{MULT: $multiplier WT: $weight \n};
}
# $weight is now set...
# check for missing fields.
if ( ( not $arr{grp} and not $arr{newgrp} ) or
not $arr{name} or not $arr{score} ){ # Fail!
print qq{