--- loncom/interface/groupsort.pm 2013/01/08 03:51:06 1.68.6.4
+++ loncom/interface/groupsort.pm 2014/12/11 00:31:05 1.74
@@ -2,7 +2,7 @@
# The LON-CAPA group sort handler
# Allows for sorting prior to import into RAT.
#
-# $Id: groupsort.pm,v 1.68.6.4 2013/01/08 03:51:06 raeburn Exp $
+# $Id: groupsort.pm,v 1.74 2014/12/11 00:31:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@ sub update_actions_hash {
$ac++;
}
# sorting through the actions and changing the global database hash
- foreach my $key (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {
+ foreach my $key (sort {$achash{$a}<=>$achash{$b}} (keys(%ahash))) {
if ($ahash{$key} eq '1') {
$hash->{'store_'.$hash->{'pre_'.$key.'_link'}}=
$hash->{'pre_'.$key.'_title'};
@@ -152,17 +152,22 @@ sub readfromfile {
&Apache::lonnet::filelocation('',$env{'form.readfile'}));
} else {
my $parser = HTML::TokeParser->new(\$cont);
- my ($token,$donechk,%allmaps);
+ my ($token,$donechk,$allmaps);
+ $allmaps = {};
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; }
if ($token->[2]->{'src'} =~ /\.(page|sequence)$/) {
- unless ($donechk) {
- $donechk = &get_allmaps(\%allmaps);
+ if (($env{'request.course.id'}) &&
+ ($env{'form.readfile'} =~ m{/default(|_\d+)\.(page|sequence)$})) {
+ unless ($donechk) {
+ $allmaps = &Apache::loncommon::allmaps_incourse();
+ $donechk = 1;
+ }
}
- if ($allmaps{$token->[2]->{'src'}}) { next; }
+ if ($allmaps->{$token->[2]->{'src'}}) { next; }
}
} else {
if ($token->[2]->{'type'} eq 'zombie') { next; }
@@ -187,35 +192,6 @@ sub readfromfile {
}
}
-sub get_allmaps {
- my ($allmaps) = @_;
- return unless (ref($allmaps) eq 'HASH');
- if (($env{'form.recover'}) &&
- ($env{'request.course.id'}) &&
- ($env{'form.readfile'} =~ m{/default(|_\d+)\.(page|sequence)$})) {
- my $cid = $env{'request.course.id'};
- my $cdom = $env{'course.'.$cid.'.domain'};
- my $cnum = $env{'course.'.$cid.'.num'};
- my $chome = $env{'course.'.$cid.'.home'};
- my $lastchange =
- &Apache::lonnet::get_coursechange($cdom,$cnum);
- if ($lastchange > $env{'request.course.tied'}) {
- my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
- unless ($ferr) {
- &Apache::loncommon::update_content_constraints($cdom,$cnum,
- $chome,$cid);
- }
- }
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (defined($navmap)) {
- foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) {
- $allmaps->{$res->src()} = 1;
- }
- }
- }
- return 1;
-}
-
# ---------------------------------------------------------------- Main Handler
sub handler {
my $r = shift;
@@ -363,8 +339,8 @@ END
if ($env{'form.recover'}) {
$r->print(<