[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet lonspreadsheet.pm /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 12 Oct 2004 20:51:54 -0000
albertel Tue Oct 12 16:51:54 2004 EDT
Modified files:
/loncom/interface/spreadsheet lonspreadsheet.pm
/loncom/lonnet/perl lonnet.pm
Log:
- eliminating usection in favor of getsection
Index: loncom/interface/spreadsheet/lonspreadsheet.pm
diff -u loncom/interface/spreadsheet/lonspreadsheet.pm:1.38 loncom/interface/spreadsheet/lonspreadsheet.pm:1.39
--- loncom/interface/spreadsheet/lonspreadsheet.pm:1.38 Tue Jun 8 11:55:38 2004
+++ loncom/interface/spreadsheet/lonspreadsheet.pm Tue Oct 12 16:51:54 2004
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.38 2004/06/08 15:55:38 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.39 2004/10/12 20:51:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -293,8 +293,8 @@
# Check that the student is in their section?
if (exists($ENV{'request.course.sec'}) &&
$ENV{'request.course.sec'} ne '' ) {
- my $stu_sec = &Apache::lonnet::usection($domain,$name,
- $ENV{'request.course.id'});
+ my $stu_sec = &Apache::lonnet::getsection($domain,$name,
+ $ENV{'request.course.id'});
if ($stu_sec ne $ENV{'request.course.sec'}) {
$ENV{'user.error.msg'}=
$r->uri.":vgr:0:0:Requested student not in your section.";
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.550 loncom/lonnet/perl/lonnet.pm:1.551
--- loncom/lonnet/perl/lonnet.pm:1.550 Wed Oct 6 05:48:39 2004
+++ loncom/lonnet/perl/lonnet.pm Tue Oct 12 16:51:54 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.550 2004/10/06 09:48:39 foxr Exp $
+# $Id: lonnet.pm,v 1.551 2004/10/12 20:51:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,7 +39,7 @@
%libserv %pr %prp %metacache %packagetab %titlecache %courseresversioncache %resversioncache
%courselogs %accesshash %userrolehash $processmarker $dumpcount
%coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseresdatacache
- %userresdatacache %usectioncache %domaindescription %domain_auth_def %domain_auth_arg_def
+ %userresdatacache %getsectioncache %domaindescription %domain_auth_def %domain_auth_arg_def
%domain_lang_def %domain_city %domain_longi %domain_lati $tmpdir);
use IO::Socket;
@@ -798,6 +798,11 @@
my ($udom,$unam,$courseid)=@_;
$courseid=~s/\_/\//g;
$courseid=~s/^(\w)/\/$1/;
+
+ my $hashid="$udom:$unam:$courseid";
+ my ($result,$cached)=&is_cached(\%getsectioncache,$hashid,'getsection');
+ if (defined($cached)) { return $result; }
+
my %Pending;
my %Expired;
#
@@ -830,21 +835,21 @@
$Pending{$start}=$section;
next;
}
- return $section;
+ return &do_cache(\%getsectioncache,$hashid,$section,'getsection');
}
#
# Presumedly there will be few matching roles from the above
# loop and the sorting time will be negligible.
if (scalar(keys(%Pending))) {
my ($time) = sort {$a <=> $b} keys(%Pending);
- return $Pending{$time};
+ return &do_cache(\%getsectioncache,$hashid,$Pending{$time},'getsection');
}
if (scalar(keys(%Expired))) {
my @sorted = sort {$a <=> $b} keys(%Expired);
my $time = pop(@sorted);
- return $Expired{$time};
+ return &do_cache(\%getsectioncache,$hashid,$Expired{$time},'getsection');
}
- return '-1';
+ return &do_cache(\%getsectioncache,$hashid,'-1','getsection');
}
@@ -1035,38 +1040,6 @@
# &logthis("load_cache_item $name took ".(&Time::HiRes::time()-$starttime));
}
-sub usection {
- my ($udom,$unam,$courseid)=@_;
- my $hashid="$udom:$unam:$courseid";
-
- my ($result,$cached)=&is_cached(\%usectioncache,$hashid,'usection');
- if (defined($cached)) { return $result; }
- $courseid=~s/\_/\//g;
- $courseid=~s/^(\w)/\/$1/;
- foreach (split(/\&/,&reply('dump:'.$udom.':'.$unam.':roles',
- &homeserver($unam,$udom)))) {
- my ($key,$value)=split(/\=/,$_);
- $key=&unescape($key);
- if ($key=~/^\Q$courseid\E(?:\/)*(\w+)*\_st$/) {
- my $section=$1;
- if ($key eq $courseid.'_st') { $section=''; }
- my ($dummy,$end,$start)=split(/\_/,&unescape($value));
- my $now=time;
- my $notactive=0;
- if ($start) {
- if ($now<$start) { $notactive=1; }
- }
- if ($end) {
- if ($now>$end) { $notactive=1; }
- }
- unless ($notactive) {
- return &do_cache(\%usectioncache,$hashid,$section,'usection');
- }
- }
- }
- return &do_cache(\%usectioncache,$hashid,'-1','usection');
-}
-
# ------------------------------------- Read an entry from a user's environment
sub userenvironment {
@@ -4142,7 +4115,7 @@
$section=$ENV{'request.course.sec'};
} else {
if (! defined($usection)) {
- $section=&usection($udom,$uname,$courseid);
+ $section=&getsection($udom,$uname,$courseid);
} else {
$section = $usection;
}
@@ -5298,7 +5271,7 @@
&logthis(sprintf("%-20s is %s",'%courseresdatacache',scalar(%courseresdatacache)));
#1.1 only
&logthis(sprintf("%-20s is %s",'%userresdatacache',scalar(%userresdatacache)));
- &logthis(sprintf("%-20s is %s",'%usectioncache',scalar(%usectioncache)));
+ &logthis(sprintf("%-20s is %s",'%getsectioncache',scalar(%getsectioncache)));
&logthis(sprintf("%-20s is %s",'%courseresversioncache',scalar(%courseresversioncache)));
&logthis(sprintf("%-20s is %s",'%resversioncache',scalar(%resversioncache)));
&flushcourselogs();
@@ -5680,8 +5653,8 @@
B<rolesinit($udom,$username,$authhost)>: get user privileges
=item *
-X<usection()>
-B<usection($udom,$uname,$cname)>: finds the section of student in the
+X<getsection()>
+B<getsection($udom,$uname,$cname)>: finds the section of student in the
course $cname, return section name/number or '' for "not in course"
and '-1' for "no section"