--- loncom/lonnet/perl/lonnet.pm 2000/09/29 14:36:30 1.33 +++ loncom/lonnet/perl/lonnet.pm 2000/09/30 17:25:04 1.34 @@ -33,6 +33,7 @@ # dump(namesp) : dumps the complete namespace into a hash # ssi(url,hash) : does a complete request cycle on url to localhost, posts # hash +# coursedescription(id) : returns and caches course description for id # repcopy(filename) : replicate file # dirlist(url) : gets a directory listing # condval(index) : value of condition index based on state @@ -51,7 +52,7 @@ # 06/26 Ben Tyszka # 06/30,07/15,07/17,07/18,07/20,07/21,07/22,07/25 Gerd Kortemeyer # 08/14 Ben Tyszka -# 08/22,08/28,08/31,09/01,09/02,09/04,09/05,09/25,09/28 Gerd Kortemeyer +# 08/22,08/28,08/31,09/01,09/02,09/04,09/05,09/25,09/28,09/30 Gerd Kortemeyer package Apache::lonnet; @@ -445,6 +446,39 @@ sub restore { return %returnhash; } +# ---------------------------------------------------------- Course Description + +sub coursedescription { + my $courseid=shift; + $courseid=~s/^\///; + my ($cdomain,$cnum)=split(/\//,$courseid); + my $chome=homeserver($cnum,$cdomain); + if ($chome ne 'no_host') { + my $rep=reply("dump:$cdomain:$cnum:environment",$chome); + if ($rep ne 'con_lost') { + my %cachehash=(); + my %returnhash=('home' => $chome, + 'domain' => $cdomain, + 'num' => $cnum); + map { + my ($name,$value)=split(/\=/,$_); + $name=&unescape($name); + $value=&unescape($value); + $returnhash{$name}=$value; + if ($name eq 'description') { + $cachehash{$courseid}=$value; + } + } split(/\&/,$rep); + $returnhash{'url'}='/res/'.declutter($returnhash{'url'}); + $returnhash{'fn'}=$perlvar{'lonDaemons'}.'/tmp/'. + $ENV{'user.name.'}.'_'.$cdomain.'_'.$cnum; + put ('coursedescriptions',%cachehash); + return %returnhash; + } + } + return (); +} + # -------------------------------------------------------- Get user priviledges sub rolesinit {