[LON-CAPA-cvs] cvs: modules /gerd/harvesting getcnames.pl
www
www at source.lon-capa.org
Wed Sep 7 08:45:10 EDT 2011
www Wed Sep 7 12:45:10 2011 EDT
Added files:
/modules/gerd/harvesting getcnames.pl
Log:
Helper to get course titles
Index: modules/gerd/harvesting/getcnames.pl
+++ modules/gerd/harvesting/getcnames.pl
use strict;
use POSIX;
use lib '/home/httpd/lib/perl';
use Apache::lonnet;
# Fishy data
my $excl='mcgill';
# ---------------------------------------------------- Fork once and dissociate
my $fpid=fork;
exit if $fpid;
die "Couldn't fork: $!" unless defined ($fpid);
POSIX::setsid() or die "Can't start new session: $!";
open(IN,'course_list.dat');
my %classes=();
while (my $line=<IN>) {
my ($id,$class)=split(/\t/,$line);
$classes{$class}=1;;
}
close(IN);
open(OUT,'>course_titles.dat');
foreach my $key (keys(%classes)) {
chomp($key);
my $desc=&coursedescription($key);
print OUT $key."\t".$desc."\n";
}
close(OUT);
sub coursedescription {
my ($courseid)=@_;
$courseid=~s/^\///;
$courseid=~s/\_/\//g;
open(LOG,'>>course_titles.log');
print LOG localtime().':'.$courseid."\n";
close(LOG);
if ($courseid=~/^\Q$excl\E/) { return ''; }
my ($cdomain,$cnum)=split(/\//,$courseid);
my $chome=&Apache::lonnet::homeserver($cnum,$cdomain);
if ($chome ne 'no_host') {
my %returnhash=&Apache::lonnet::dump('environment',$cdomain,$cnum);
if (!exists($returnhash{'con_lost'})) {
return $returnhash{'description'};
} else {
return '';
}
} else {
return '';
}
}
More information about the LON-CAPA-cvs
mailing list