[LON-CAPA-cvs] cvs: loncom /interface groupsort.pm loncommon.pm
raeburn
raeburn at source.lon-capa.org
Tue Jan 8 22:56:28 EST 2013
raeburn Wed Jan 9 03:56:28 2013 EDT
Modified files:
/loncom/interface loncommon.pm groupsort.pm
Log:
- &get_allmaps() moved form groupsort.pm to loncommon.pm and renamed as
&allmaps_incourse() to facilitate reuse.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1109 loncom/interface/loncommon.pm:1.1110
--- loncom/interface/loncommon.pm:1.1109 Thu Jan 3 20:08:59 2013
+++ loncom/interface/loncommon.pm Wed Jan 9 03:56:27 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1109 2013/01/03 20:08:59 raeburn Exp $
+# $Id: loncommon.pm,v 1.1110 2013/01/09 03:56:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,6 +68,7 @@
use Apache::lontexconvert();
use Apache::lonclonecourse();
use Apache::lonuserutils();
+use Apache::lonuserstate();
use LONCAPA qw(:DEFAULT :match);
use DateTime::TimeZone;
use DateTime::Locale::Catalog;
@@ -14144,6 +14145,32 @@
return;
}
+sub allmaps_incourse {
+ my ($cdom,$cnum,$chome,$cid) = @_;
+ if ($cdom eq '' || $cnum eq '' || $chome eq '' || $cid eq '') {
+ $cid = $env{'request.course.id'};
+ $cdom = $env{'course.'.$cid.'.domain'};
+ $cnum = $env{'course.'.$cid.'.num'};
+ $chome = $env{'course.'.$cid.'.home'};
+ }
+ my %allmaps = ();
+ my $lastchange =
+ &Apache::lonnet::get_coursechange($cdom,$cnum);
+ if ($lastchange > $env{'request.course.tied'}) {
+ my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
+ unless ($ferr) {
+ &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 \%allmaps;
+}
+
sub parse_supplemental_title {
my ($title) = @_;
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.70 loncom/interface/groupsort.pm:1.71
--- loncom/interface/groupsort.pm:1.70 Tue Jan 8 03:46:07 2013
+++ loncom/interface/groupsort.pm Wed Jan 9 03:56:28 2013
@@ -2,7 +2,7 @@
# The LON-CAPA group sort handler
# Allows for sorting prior to import into RAT.
#
-# $Id: groupsort.pm,v 1.70 2013/01/08 03:46:07 raeburn Exp $
+# $Id: groupsort.pm,v 1.71 2013/01/09 03:56:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -152,17 +152,22 @@
&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 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;
More information about the LON-CAPA-cvs
mailing list