--- loncom/interface/groupsort.pm 2005/06/09 22:06:09 1.33 +++ loncom/interface/groupsort.pm 2005/06/10 02:19:51 1.34 @@ -2,7 +2,7 @@ # The LON-CAPA group sort handler # Allows for sorting prior to import into RAT. # -# $Id: groupsort.pm,v 1.33 2005/06/09 22:06:09 www Exp $ +# $Id: groupsort.pm,v 1.34 2005/06/10 02:19:51 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -180,8 +180,7 @@ sub readfromdb { } } } else { - $r->print('Unable to tie hash to db file'); - return OK; + $r->print('Unable to tie hash to db file'); } untie %hash; return ($shash,$thash); @@ -198,12 +197,48 @@ sub cleanup { } } +# -------------------------------------------------------------- Read from file + +sub readfromfile { + my ($r,$shash,$thash)=@_; + my $cont=&Apache::lonnet::getfile + (&Apache::lonnet::filelocation('',$env{'form.readfile'})); + if ($cont==-1) { + $r->print('Unable to read file: '. + &Apache::lonnet::filelocation('',$env{'form.readfile'})); + } else { + my $parser = HTML::TokeParser->new(\$cont); + my $token; + while ($token = $parser->get_token) { + if ($token->[0] eq 'S') { + if ($token->[1] eq 'resource') { + if ($env{'form.recover'}) { + if ($token->[2]->{'type'} ne 'zombie') { next; } + } else { + if ($token->[2]->{'type'} eq 'zombie') { next; } + } + my $name=$token->[2]->{'title'}; + my $url=$token->[2]->{'src'}; + $name=~s/ \[\((\d+)\,(\w+)\,(\w+)\)\]$//; + if ($1) { + $name.='
'.&mt('Removed by '). + &Apache::loncommon::plainname($2,$3).', '. + &Apache::lonlocal::locallocaltime($1); + } + $r->print('
'.$name); + } + } + } + } + return ($shash,$thash); +} + # ---------------------------------------------------------------- Main Handler sub handler { my $r = shift; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['acts','catalogmode','mode']); + ['acts','catalogmode','mode','readfile','recover']); # color scheme my $fileclr = '#ffffe6'; my $titleclr = '#ddffff'; @@ -292,7 +327,11 @@ END my %shash; # sort order (key is resource location, value is sort order) my %thash; # title (key is resource location, value is title) - &readfromdb($r,\%shash,\%thash); + if ($env{'form.readfile'}) { + &readfromfile($r,\%shash,\%thash); + } else { + &readfromdb($r,\%shash,\%thash); + } my $ctr = 0; my $clen = scalar(keys %shash);