--- loncom/interface/groupsort.pm 2012/05/02 19:10:13 1.68.6.1
+++ 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.1 2012/05/02 19:10:13 raeburn Exp $
+# $Id: groupsort.pm,v 1.74 2014/12/11 00:31:05 raeburn 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 qw(:DEFAULT :match);
my $iconpath; # variable to be accessible to multiple subroutines
my %hash; # variable to tie to user specific database
@@ -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,12 +152,23 @@ sub readfromfile {
&Apache::lonnet::filelocation('',$env{'form.readfile'}));
} else {
my $parser = HTML::TokeParser->new(\$cont);
- my $token;
+ 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)$/) {
+ 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; }
+ }
} else {
if ($token->[2]->{'type'} eq 'zombie') { next; }
}
@@ -181,31 +192,12 @@ sub readfromfile {
}
}
-# --------------------------------------------------------- Read from bookmarks
-
-sub readfrombookmarks {
- my ($r,$resources)=@_;
- my %bookmarks=&Apache::lonnet::dump('bookmarks');
-# the bookmark "hash" is just one entry
-# it's a javascript program code with arguments like ('title','url');
- my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g);
- for (my $index=0;$index<($#bookmarks+1)/2;$index++) {
- if ($bookmarks[$index*2+1]) {
- my $url = $bookmarks[$index*2+1];
- my $name = $bookmarks[$index*2];
- $name =~ s/^LON\-CAPA\s+//;
-
- push(@{$resources},{'url' => $url, 'title' => $name});
- }
- }
-}
-
# ---------------------------------------------------------------- Main Handler
sub handler {
my $r = shift;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['acts','mode','readfile','recover','bookmarks']);
+ ['acts','mode','readfile','recover']);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -215,7 +207,7 @@ sub handler {
my $finishimport='';
my $begincondition='';
my $endcondition='';
- if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
+ if (($env{'form.readfile'})) {
$begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';
$endcondition='}';
}
@@ -299,8 +291,6 @@ END
if ($env{'form.readfile'}) {
&readfromfile($r,\@resources);
- } elsif ($env{'form.bookmarks'}) {
- &readfrombookmarks($r,\@resources);
} else {
&readfromdb($r,\@resources);
}
@@ -313,10 +303,7 @@ END
} else {
$title = 'Sort Imported Resources';
}
- if ($env{'form.bookmarks'}) {
- $title = 'Import Resources from Bookmarks';
- }
- if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
+ if (($clen > 1) || ($env{'form.readfile'})) {
my %lt=&Apache::lonlocal::texthash(
'fin'=> 'Finalize order of resources',
'ci' => 'Continue Import',
@@ -342,7 +329,6 @@ END
-
END
@@ -350,14 +336,11 @@ END
# ---
my $buttontext = $lt{'re'};
- if ($env{'form.bookmarks'}) {
- $buttontext = $lt{'ip'}
- }
- if ($env{'form.recover'} || $env{'form.bookmarks'}) {
+ if ($env{'form.recover'}) {
$r->print(<
'.&mt($errtxt).'
'); } } else { @@ -420,10 +400,10 @@ END foreach my $resource (@resources) { $ctr++; my $iconname=&Apache::loncommon::icon($resource->{'url'}); - if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { + if (($clen > 1) || ($env{'form.readfile'})) { $r->print(&Apache::loncommon::start_data_table_row() ."