[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm /misc refresh_courseids_db.pl
raeburn
raeburn@source.lon-capa.org
Thu, 29 Jul 2010 17:44:46 -0000
raeburn Thu Jul 29 17:44:46 2010 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom/misc refresh_courseids_db.pl
Log:
- If any anonymous submissions have been made for a problem part, required
LON-CAPA version for roles in course is 2.10
- Move &parse_releases_xml() from refresh_courseids.db to lonnet.pm
- Add %needsrelease as a package hash in lonnet.pm
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1078 loncom/lonnet/perl/lonnet.pm:1.1079
--- loncom/lonnet/perl/lonnet.pm:1.1078 Mon Jul 26 21:52:19 2010
+++ loncom/lonnet/perl/lonnet.pm Thu Jul 29 17:44:41 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1078 2010/07/26 21:52:19 raeburn Exp $
+# $Id: lonnet.pm,v 1.1079 2010/07/29 17:44:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -76,7 +76,7 @@
use Image::Magick;
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir
- $_64bit %env %protocol %loncaparevs %serverhomeIDs);
+ $_64bit %env %protocol %loncaparevs %serverhomeIDs %needsrelease);
my (%badServerCache, $memcache, %courselogs, %accesshash, %domainrolehash,
%userrolehash, $processmarker, $dumpcount, %coursedombuf,
@@ -10139,6 +10139,10 @@
}
+sub all_loncaparevs {
+ return qw(1.1 1.2 1.3 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10);
+}
+
BEGIN {
# ----------------------------------- Read loncapa.conf and loncapa_apache.conf
@@ -10242,8 +10246,23 @@
}
}
-sub all_loncaparevs {
- return qw(1.1 1.2 1.3 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10);
+{
+ my $file = $Apache::lonnet::perlvar{'lonTabDir'}.'/releaseslist.xml';
+ if (-e $file) {
+ my $parser = HTML::LCParser->new($file);
+ while (my $token = $parser->get_token()) {
+ if ($token->[0] eq 'S') {
+ my $item = $token->[1];
+ my $name = $token->[2]{'name'};
+ my $value = $token->[2]{'value'};
+ if ($item ne '' && $name ne '' && $value ne '') {
+ my $release = $parser->get_text();
+ $release =~ s/(^\s*|\s*$ )//gx;
+ $needsrelease{$item.':'.$name.':'.$value} = $release;
+ }
+ }
+ }
+ }
}
# ------------- set up temporary directory
Index: loncom/misc/refresh_courseids_db.pl
diff -u loncom/misc/refresh_courseids_db.pl:1.4 loncom/misc/refresh_courseids_db.pl:1.5
--- loncom/misc/refresh_courseids_db.pl:1.4 Sat Jul 24 00:01:12 2010
+++ loncom/misc/refresh_courseids_db.pl Thu Jul 29 17:44:45 2010
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# The LearningOnline Network
#
-# $Id: refresh_courseids_db.pl,v 1.4 2010/07/24 00:01:12 raeburn Exp $
+# $Id: refresh_courseids_db.pl,v 1.5 2010/07/29 17:44:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,7 +61,7 @@
exit if ($Apache::lonnet::perlvar{'lonRole'} ne 'library');
-use vars qw( %needsrelease %checkparms %checkresponsetypes %checkcrstypes);
+use vars qw( %checkparms %checkresponsetypes %checkcrstypes %anonsurvey );
# Make sure this process is running from user=www
my $wwwid=getpwnam('www');
@@ -79,7 +79,7 @@
my @domains = sort(&Apache::lonnet::current_machine_domains());
-&parse_releases_xml();
+&build_release_hashes();
$env{'allowed.bre'} = 'F';
foreach my $dom (@domains) {
@@ -339,7 +339,7 @@
if (ref($checkparms{$item}) eq 'ARRAY') {
my $value = $resourcedata->{$key};
if (grep(/^\Q$value\E$/,@{$checkparms{$item}})) {
- my ($major,$minor) = split(/\./,$needsrelease{'parameter'}{$item}{$value});
+ my ($major,$minor) = split(/\./,$Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value});
($reqdmajor,$reqdminor) =
&update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
}
@@ -365,18 +365,32 @@
my ($cnum,$cdom,$reqdmajor,$reqdminor) = @_;
my $navmap = Apache::lonnavmaps::navmap->new();
if (defined($navmap)) {
+ my %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
+ $cdom,$cnum);
my %allresponses;
+ my $anonsurv_subm;
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
my %responses = $res->responseTypes();
foreach my $key (keys(%responses)) {
next unless(exists($checkresponsetypes{$key}));
$allresponses{$key} += $responses{$key};
}
+ my @parts = @{$res->parts()};
+ my $symb = $res->symb();
+ foreach my $part (@parts) {
+ if (exists($resourcetracker{$symb."\0".$part."\0anonymous"})) {
+ $anonsurv_subm = 1;
+ }
+ }
}
foreach my $key (keys(%allresponses)) {
my ($major,$minor) = split(/\./,$checkresponsetypes{$key});
($reqdmajor,$reqdminor) = &update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
}
+ if ($anonsurv_subm) {
+ ($reqdmajor,$reqdminor) = &update_reqd_loncaparev($anonsurvey{major},
+ $anonsurvey{minor},$reqdmajor,$reqdminor);
+ }
}
return ($reqdmajor,$reqdminor);
}
@@ -416,40 +430,28 @@
return $resourcedata;
}
-sub parse_releases_xml {
- my $file = $Apache::lonnet::perlvar{'lonTabDir'}.'/releaseslist.xml';
- if (-e $file) {
- my $parser = HTML::LCParser->new($file);
- while (my $token = $parser->get_token()) {
- if ($token->[0] eq 'S') {
- my $item = $token->[1];
- my $name = $token->[2]{'name'};
- my $value = $token->[2]{'value'};
- if ($item ne '' && $name ne '' && $value ne '') {
- my $release = $parser->get_text();
- $release =~ s/(^\s*|\s*$ )//gx;
- $needsrelease{$item}{$name}{$value} = $release;
- if ($item eq 'parameter') {
- if (ref($checkparms{$name}) eq 'ARRAY') {
- unless(grep(/^\Q$name\E$/,@{$checkparms{$name}})) {
- push(@{$checkparms{$name}},$value);
- }
- } else {
- push(@{$checkparms{$name}},$value);
- }
- } elsif ($item eq 'resourcetag') {
- if ($name eq 'responsetype') {
- $checkresponsetypes{$value} = $release;
- }
- } elsif ($item eq 'course') {
- if ($name eq 'crstype') {
- $checkcrstypes{$value} = $release;
- }
- }
+sub build_release_hashes {
+ foreach my $key (keys(%Apache::lonnet::needsrelease)) {
+ my ($item,$name,$value) = split(/:/,$key);
+ if ($item eq 'parameter') {
+ if (ref($checkparms{$name}) eq 'ARRAY') {
+ unless(grep(/^\Q$name\E$/,@{$checkparms{$name}})) {
+ push(@{$checkparms{$name}},$value);
}
+ } else {
+ push(@{$checkparms{$name}},$value);
+ }
+ } elsif ($item eq 'resourcetag') {
+ if ($name eq 'responsetype') {
+ $checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key}
+ }
+ } elsif ($item eq 'course') {
+ if ($name eq 'crstype') {
+ $checkcrstypes{$value} = $Apache::lonnet::needsrelease{$key};
}
}
}
+ ($anonsurvey{major},$anonsurvey{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'});
return;
}