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.

116 lines
3.0 KiB

#!/usr/bin/perl
#
# $Id: grplib.pl,v 1.1 2006/02/09 23:48:46 ddoughty Exp $
#
# Source File: grpdef.pl
#$SESSION{'clid'}, $FORM{'grpowner'}, $FORM{'grpid'})
sub delete_group {
($clid, $grpowner, $grpid) = @_;
#
# Delete the entry from the group file
#
$grpfile = join($pathsep, $dataroot, "groups.$clid");
@grps = &get_data("groups.$clid");
$grphdr = shift(@grps);
$grpmsk = join('&', $grpowner, $grpid, "");
open (TMPGRP, ">$grpfile");
print TMPGRP "$grphdr";
for (0 .. $#grps) {
$grprec = $grps[$_];
if ($grprec =~ /^$grpmsk/ ) {
next;
} else {
print TMPGRP "$grprec";
}
}
close TMPGRP;
#
# Delete the gradebook file for the owner
#
$gbkfile = join($pathsep, $dataroot, "gradebk.$clid.$grpowner.$grpid");
unlink($gbkfile);
}
sub update_group {
#
# create the group file for the client if it doesn't exist
#
$grpfile = join($pathsep, $dataroot, "groups.$_[0]");
unless (&file_exists($grpfile)) {
$grpheader = join($pathsep, $dataroot, "groups.std");
unless (&make_file( $grpfile, $grpheader, 1)) {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "3", "FC Error: $grpfile $grpheader");
return;
}
}
#
# create the gradebook file for the owner if it doesn't exist
#
$gbkfile = join($pathsep, $dataroot, "gradebk.$_[0].$FORM{'grpowner'}.$FORM{'grpid'}");
$gbkheader = join($pathsep, $dataroot, "gradebk.std");
unless (&file_exists($gbkfile)) {
unless (&make_file( $gbkfile, $gbkheader, 1)) {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "3", "FC Error: $gbkfile $gbkheader");
return;
}
}
#
# Update or add the entry to the group file
#
@grps = &get_data("groups.$_[0]");
$grphdr = $grps[0];
chop ($grphdr);
@grpflds = split(/&/, $grphdr);
for (0 .. $#grpflds) { $GROUP{$_} = $grpflds[$_];}
$newgrprec = $FORM{'grpowner'};
for (1 .. $#grpflds) {
$fldnme = $GROUP{$_};
if ($fldname = 'grplist') {
$FORM{'grplist'} = join(',', param('grplist'));
}
$newgrprec = join('&', $newgrprec, $FORM{$fldnme});
}
$grpmsk = join('&', $FORM{'grpowner'}, $FORM{'grpid'}, "");
$bFound = 0;
open (TMPGRP, ">$grpfile");
for (0 .. $#grps) {
$grprec = $grps[$_];
if ($grprec =~ /$grpmsk/ ) {
$grprec = "$newgrprec\n";
$bFound = 1;
}
print TMPGRP "$grprec";
}
unless ($bFound) {
print TMPGRP "$newgrprec\n";
}
close TMPGRP;
}
#$SESSION{'clid'}, $FORM{'idlist'}, $FORM{'tstid'})
sub update_group_registrations {
@rostermems = split(/\,/, $_[1]);
$grpauthtests = $_[2];
$grpauthtests =~ s/\,/\;/g;
foreach $rostermem (@rostermems) {
if ($rostermem ne '') {
$FORM{'cndid'} = $rostermem;
$FORM{'authtests'} = $grpauthtests;
&prepare_test($_[0], $FORM{'cndid'}, $FORM{'authtests'}, $FORM{'usetestform'});
print "$rostermem registered for $grpauthtests<BR>\n";
# sac - start addition for subject area percentage support
if ($SYSTEM{'testprepmsg'} ne "") {
print "WITH EXCEPTIONS:<br>$SYSTEM{'testprepmsg'}";
$SYSTEM{'testprepmsg'} = "";
}
# sac - end addition for subject area percentage support
}
}
print "\&nbsp;<BR><B>Requested Tests Registrations Completed</B><BR>\n";
}
1