[LON-CAPA-cvs] cvs: loncom / lontrans.pm /homework grades.pm /interface loncommon.pm loncreatecourse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 12 Nov 2003 21:37:07 -0000


albertel		Wed Nov 12 16:37:07 2003 EDT

  Modified files:              
    /loncom	lontrans.pm 
    /loncom/interface	loncommon.pm loncreatecourse.pm 
    /loncom/homework	grades.pm 
  Log:
  - consoladating the 3 different &propath()s
  
  
Index: loncom/lontrans.pm
diff -u loncom/lontrans.pm:1.5 loncom/lontrans.pm:1.6
--- loncom/lontrans.pm:1.5	Tue Mar 25 19:03:21 2003
+++ loncom/lontrans.pm	Wed Nov 12 16:37:07 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for User Files
 #
-# $Id: lontrans.pm,v 1.5 2003/03/26 00:03:21 albertel Exp $
+# $Id: lontrans.pm,v 1.6 2003/11/12 21:37:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,24 +32,15 @@
 use Apache::Constants qw(:common :remotehost);
 use Apache::lonnet();
 use Apache::File();
-
-sub propath {
-    my ($udom,$uname)=@_;
-    $udom=~s/\W//g;
-    $uname=~s/\W//g;
-    my $subdir=$uname.'__';
-    $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
-    my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
-    return $proname;
-}
-
+use Apache::loncommon;
 
 sub handler {
     my $r = shift;
     if ($r->uri=~m|^/uploaded/|) {
 	my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri);
 	$ufile=~s/^[\~\.]+//;
-	$r->filename(&propath($udom,$uname).'/userfiles/'.$ufile);
+	$r->filename(&Apache::loncommon::propath($udom,$uname).
+		     '/userfiles/'.$ufile);
     } elsif ($r->uri=~m|^/~|) {	
 	#internal authentication, needs fixup.
 	my $fn = $r->uri(); # non users do not get the full path request
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.153 loncom/interface/loncommon.pm:1.154
--- loncom/interface/loncommon.pm:1.153	Tue Nov 11 17:11:09 2003
+++ loncom/interface/loncommon.pm	Wed Nov 12 16:37:07 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.153 2003/11/11 22:11:09 matthew Exp $
+# $Id: loncommon.pm,v 1.154 2003/11/12 21:37:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2747,7 +2747,7 @@
 ############################################################
 my $uniq=0;
 sub get_cgi_id {
-    $uniq=($uniq++)%100000;
+    $uniq=($uniq+1)%100000;
     return (time.'_'.$uniq);
 }
 
@@ -3200,6 +3200,16 @@
 
 ############################################################
 ############################################################
+
+sub propath {
+    my ($udom,$uname)=@_;
+    $udom=~s/\W//g;
+    $uname=~s/\W//g;
+    my $subdir=$uname.'__';
+    $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
+    my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
+    return $proname;
+} 
 
 =pod
 
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.38 loncom/interface/loncreatecourse.pm:1.39
--- loncom/interface/loncreatecourse.pm:1.38	Sun Sep 21 17:40:06 2003
+++ loncom/interface/loncreatecourse.pm	Wed Nov 12 16:37:07 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.38 2003/09/21 21:40:06 www Exp $
+# $Id: loncreatecourse.pm,v 1.39 2003/11/12 21:37:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,18 +49,6 @@
 use Apache::londocs;
 use Apache::lonlocal;
 
-# -------------------------------------------- Return path to profile directory
-
-sub propath {
-    my ($udom,$uname)=@_;
-    $udom=~s/\W//g;
-    $uname=~s/\W//g;
-    my $subdir=$uname.'__';
-    $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
-    my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
-    return $proname;
-} 
-
 # ================================================ Get course directory listing
 
 sub crsdirlist {
@@ -69,7 +57,7 @@
     my %crsdata=&Apache::lonnet::coursedescription($courseid);
     my @listing=&Apache::lonnet::dirlist
 	($which,$crsdata{'domain'},$crsdata{'num'},
-	 &propath($crsdata{'domain'},$crsdata{'num'}));
+	 &Apache::loncommon::propath($crsdata{'domain'},$crsdata{'num'}));
     my @output=();
     foreach (@listing) {
 	unless ($_=~/^\./) {
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.158 loncom/homework/grades.pm:1.159
--- loncom/homework/grades.pm:1.158	Wed Nov 12 16:20:54 2003
+++ loncom/homework/grades.pm	Wed Nov 12 16:37:07 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.158 2003/11/12 21:20:54 albertel Exp $
+# $Id: grades.pm,v 1.159 2003/11/12 21:37:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3371,24 +3371,13 @@
     return $result;
 }
 
-#FIXME, I am in loncreatecourse, use that one instead
-sub propath {
-    my ($udom,$uname)=@_;
-    $udom=~s/\W//g;
-    $uname=~s/\W//g;
-    my $subdir=$uname.'__';
-    $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
-    my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
-    return $proname;
-} 
-
 sub scantron_uploads {
     if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''};
     my $result=	'<select name="scantron_selectfile">';
     my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
     my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
-				       &propath($cdom,$cname));
+				    &Apache::locommon::propath($cdom,$cname));
     foreach my $filename (@files) {
 	($filename)=split(/&/,$filename);
 	if ($filename!~/^scantron_orig_/) { next ; }