[LON-CAPA-cvs] cvs: loncom / lond /homework bridgetask.pm /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sat, 21 Jan 2006 08:27:09 -0000
albertel Sat Jan 21 03:27:09 2006 EDT
Modified files:
/loncom lond
/loncom/lonnet/perl lonnet.pm
/loncom/homework bridgetask.pm
Log:
- bug #4608
- adding optional 'range' attribute to dump for controlling the number of results
Index: loncom/lond
diff -u loncom/lond:1.305 loncom/lond:1.306
--- loncom/lond:1.305 Tue Jan 17 16:00:00 2006
+++ loncom/lond Sat Jan 21 03:26:52 2006
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.305 2006/01/17 21:00:00 albertel Exp $
+# $Id: lond,v 1.306 2006/01/21 08:26:52 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.305 $'; #' stupid emacs
+my $VERSION='$Revision: 1.306 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -2895,22 +2895,39 @@
my $userinput = "$cmd:$tail";
- my ($udom,$uname,$namespace,$regexp)=split(/:/,$tail);
+ my ($udom,$uname,$namespace,$regexp,$range)=split(/:/,$tail);
if (defined($regexp)) {
$regexp=&unescape($regexp);
} else {
$regexp='.';
}
+ my ($start,$end);
+ if (defined($range)) {
+ if ($range =~/^(\d+)\-(\d+)$/) {
+ ($start,$end) = ($1,$2);
+ } elsif ($range =~/^(\d+)$/) {
+ ($start,$end) = (0,$1);
+ } else {
+ undef($range);
+ }
+ }
my $hashref = &tie_user_hash($udom, $uname, $namespace,
&GDBM_READER());
if ($hashref) {
my $qresult='';
+ my $count=0;
while (my ($key,$value) = each(%$hashref)) {
if ($regexp eq '.') {
+ $count++;
+ if (defined($range) && $count >= $end) { last; }
+ if (defined($range) && $count < $start) { next; }
$qresult.=$key.'='.$value.'&';
} else {
my $unescapeKey = &unescape($key);
if (eval('$unescapeKey=~/$regexp/')) {
+ $count++;
+ if (defined($range) && $count >= $end) { last; }
+ if (defined($range) && $count < $start) { next; }
$qresult.="$key=$value&";
}
}
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.701 loncom/lonnet/perl/lonnet.pm:1.702
--- loncom/lonnet/perl/lonnet.pm:1.701 Wed Jan 18 16:15:41 2006
+++ loncom/lonnet/perl/lonnet.pm Sat Jan 21 03:27:02 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.701 2006/01/18 21:15:41 albertel Exp $
+# $Id: lonnet.pm,v 1.702 2006/01/21 08:27:02 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2793,7 +2793,7 @@
# -------------------------------------------------------------- dump interface
sub dump {
- my ($namespace,$udomain,$uname,$regexp)=@_;
+ my ($namespace,$udomain,$uname,$regexp,$range)=@_;
if (!$udomain) { $udomain=$env{'user.domain'}; }
if (!$uname) { $uname=$env{'user.name'}; }
my $uhome=&homeserver($uname,$udomain);
@@ -2802,11 +2802,11 @@
} else {
$regexp='.';
}
- my $rep=reply("dump:$udomain:$uname:$namespace:$regexp",$uhome);
+ my $rep=reply("dump:$udomain:$uname:$namespace:$regexp:$range",$uhome);
my @pairs=split(/\&/,$rep);
my %returnhash=();
foreach (@pairs) {
- my ($key,$value)=split(/=/,$_);
+ my ($key,$value)=split(/=/,$_,2);
$returnhash{unescape($key)}=&thaw_unescape($value);
}
return %returnhash;
@@ -7048,10 +7048,15 @@
=item *
-dump($namespace,$udom,$uname,$regexp) :
+dump($namespace,$udom,$uname,$regexp,$range) :
dumps the complete (or key matching regexp) namespace into a hash
-($udom, $uname and $regexp are optional)
+($udom, $uname, $regexp, $range are optional)
+$range should be either an integer '100' (give me the first 100
+ matching records)
+ or be two integers sperated by a - with no spaces
+ '30-50' (give me the 30th through the 50th matching
+ records)
=item *
inc($namespace,$store,$udom,$uname) : increments $store in $namespace.
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.96 loncom/homework/bridgetask.pm:1.97
--- loncom/homework/bridgetask.pm:1.96 Sat Jan 21 03:03:27 2006
+++ loncom/homework/bridgetask.pm Sat Jan 21 03:27:09 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.96 2006/01/21 08:03:27 albertel Exp $
+# $Id: bridgetask.pm,v 1.97 2006/01/21 08:27:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1334,7 +1334,9 @@
$cdom,$cnum);
&Apache::lonxml::debug("$starttime");
my $regexp="^$symb\0queue\0";
- my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
+ my $range= ($attempts < 1 ) ? '0-100' : '0-400';
+
+ my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp,$range);
#make a pass looking for a user _not_ in my section
if ($env{'request.course.sec'}) {
&Apache::lonxml::debug("sce");