--- loncom/interface/groupsort.pm 2007/07/12 00:27:13 1.57 +++ loncom/interface/groupsort.pm 2007/11/02 21:08:45 1.61 @@ -2,7 +2,7 @@ # The LON-CAPA group sort handler # Allows for sorting prior to import into RAT. # -# $Id: groupsort.pm,v 1.57 2007/07/12 00:27:13 albertel Exp $ +# $Id: groupsort.pm,v 1.61 2007/11/02 21:08:45 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,7 @@ use GDBM_File; use Apache::loncommon; use Apache::lonlocal; use Apache::lonnet; -use LONCAPA(); +use LONCAPA; my $iconpath; # variable to be accessible to multiple subroutines my %hash; # variable to tie to user specific database @@ -45,14 +45,15 @@ my %hash; # variable to tie to user spec sub update_actions_hash { my ($hash) = @_; + # be careful in here, there is also a global %hash my $acts=$env{'form.acts'}; my @Acts=split(/b/,$acts); my %ahash; my %achash; - my $ac=0; # some initial hashes for working with data + my $ac=0; foreach (@Acts) { - my ($state,$ref)=split(/a/); + my ($state,$ref)=split(/a/); $ahash{$ref}=$state; $achash{$ref}=$ac; $ac++; @@ -60,15 +61,16 @@ sub update_actions_hash { # sorting through the actions and changing the global database hash foreach my $key (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) { if ($ahash{$key} eq '1') { - $hash->{'store_'.$hash{'pre_'.$key.'_link'}}= + $hash->{'store_'.$hash->{'pre_'.$key.'_link'}}= $hash->{'pre_'.$key.'_title'}; - $hash->{'storectr_'.$hash{'pre_'.$key.'_link'}}= + $hash->{'storectr_'.$hash->{'pre_'.$key.'_link'}}= $hash->{'storectr'}+0; $hash->{'storectr'}++; } if ($ahash{$key} eq '0') { - if ($hash->{'store_'.$hash{'pre_'.$key.'_link'}}) { - delete($hash->{'store_'.$hash{'pre_'.$key.'_link'}}); + if ($hash->{'store_'.$hash->{'pre_'.$key.'_link'}}) { + delete($hash->{'store_'.$hash->{'pre_'.$key.'_link'}}); + delete($hash->{'storectr_'.$hash->{'pre_'.$key.'_link'}}); } } } @@ -160,7 +162,6 @@ sub readfromfile { if ($token->[2]->{'type'} eq 'zombie') { next; } } - my $url=$token->[2]->{'src'}; my $name=$token->[2]->{'title'}; $name=~s/ \[\((\d+)\,($LONCAPA::username_re)\,($LONCAPA::domain_re)\)\]$//; my $note; @@ -170,9 +171,10 @@ sub readfromfile { &Apache::lonlocal::locallocaltime($1); } $name=~s/\&colon\;/\:/g; - push(@{$resources}, {'url' => $url, + push(@{$resources}, {'url' => $token->[2]->{'src'}, 'title' => $name, - 'note' => $note, }); + 'note' => $note, + 'id' => $token->[2]->{'id'},}); } } } @@ -227,8 +229,9 @@ function finish_import() { for (var num=0; numprint(&movers($clen,$ctr)); } } - $r->print(&hidden($ctr-1,$resource->{'title'},$resource->{'url'})); + $r->print(&hidden($ctr-1,$resource->{'title'},$resource->{'url'}, + $resource->{'id'})); if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { $r->print(""); unless (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { @@ -425,12 +430,13 @@ END # --------------------------------------- Hidden values (returns scalar string) sub hidden { - my ($sel,$title,$filelink) = @_; - my $string = ''; + my ($sel,$title,$filelink,$id) = @_; + my $string = ''; $filelink=~s|^/ext/|http://|; $string .= ''; + &escape($filelink).'" />'; + $string .= ''; return $string; }