[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

foxr foxr at source.lon-capa.org
Mon Jul 18 06:25:56 EDT 2011


foxr		Mon Jul 18 10:25:56 2011 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Provide support for coursedescription to return a filename for a user
  other than the logged in user via the $args hashref.
  
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1117 loncom/lonnet/perl/lonnet.pm:1.1118
--- loncom/lonnet/perl/lonnet.pm:1.1117	Mon Jul  4 09:25:06 2011
+++ loncom/lonnet/perl/lonnet.pm	Mon Jul 18 10:25:55 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1117 2011/07/04 09:25:06 foxr Exp $
+# $Id: lonnet.pm,v 1.1118 2011/07/18 10:25:55 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3998,6 +3998,8 @@
 }
 
 # ---------------------------------------------------------- Course Description
+#
+#  
 
 sub coursedescription {
     my ($courseid,$args)=@_;
@@ -4027,7 +4029,8 @@
 	return %returnhash;
     }
 
-    # get the data agin
+    # get the data again
+
     if (!$args->{'one_time'}) {
 	$envhash{'course.'.$normalid.'.last_cache'}=time;
     }
@@ -4035,6 +4038,10 @@
     if ($chome ne 'no_host') {
        %returnhash=&dump('environment',$cdomain,$cnum);
        if (!exists($returnhash{'con_lost'})) {
+	   my $username = $env{'user.name'}; # Defult username
+	   if(defined $args->{'user'}) {
+	       $username = $args->{'user'};
+	   }
            $returnhash{'home'}= $chome;
 	   $returnhash{'domain'} = $cdomain;
 	   $returnhash{'num'} = $cnum;
@@ -4046,7 +4053,7 @@
            }
            $returnhash{'url'}=&clutter($returnhash{'url'});
            $returnhash{'fn'}=LONCAPA::tempdir() .
-	       $env{'user.name'}.'_'.$cdomain.'_'.$cnum;
+	       $username.'_'.$cdomain.'_'.$cnum;
            $envhash{'course.'.$normalid.'.home'}=$chome;
            $envhash{'course.'.$normalid.'.domain'}=$cdomain;
            $envhash{'course.'.$normalid.'.num'}=$cnum;
@@ -11038,11 +11045,32 @@
 
 =item *
 
-coursedescription($courseid) : returns a hash of information about the
+coursedescription($courseid,$options) : returns a hash of information about the
 specified course id, including all environment settings for the
 course, the description of the course will be in the hash under the
 key 'description'
 
+$options is an optional parameter that if supplied is a hash reference that controls
+what how this function works.  It has the following key/values:
+
+=over 4
+
+=item freshen_cache
+
+If defined, and the environment cache for the course is valid, it is 
+returned in the returned hash.
+
+=item one_time
+
+If defined, the last cache time is set to _now_
+
+=item user
+
+If defined, the supplied username is used instead of the current user.
+
+
+=back
+
 =item *
 
 resdata($name,$domain,$type, at which) : request for current parameter




More information about the LON-CAPA-cvs mailing list