[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface groupsort.pm

raeburn raeburn at source.lon-capa.org
Mon Jan 7 22:51:06 EST 2013


raeburn		Tue Jan  8 03:51:06 2013 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	groupsort.pm 
  Log:
  - For 2.11
    - Backport 1.70.
  
  
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.68.6.3 loncom/interface/groupsort.pm:1.68.6.4
--- loncom/interface/groupsort.pm:1.68.6.3	Wed Aug  1 12:52:41 2012
+++ loncom/interface/groupsort.pm	Tue Jan  8 03:51:06 2013
@@ -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.3 2012/08/01 12:52:41 raeburn Exp $
+# $Id: groupsort.pm,v 1.68.6.4 2013/01/08 03:51:06 raeburn Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -152,12 +152,18 @@
 		  &Apache::lonnet::filelocation('',$env{'form.readfile'}));
     } else {
         my $parser = HTML::TokeParser->new(\$cont);
-        my $token;
+        my ($token,$donechk,%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 ($allmaps{$token->[2]->{'src'}}) { next; }
+                        }
 		    } else {
 			if ($token->[2]->{'type'} eq 'zombie') { next; }
 		    }
@@ -181,6 +187,34 @@
     }
 }
 
+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 {




More information about the LON-CAPA-cvs mailing list