--- loncom/misc/refresh_courseids_db.pl 2012/07/21 20:18:37 1.12 +++ loncom/misc/refresh_courseids_db.pl 2013/05/27 17:24:11 1.15 @@ -1,7 +1,7 @@ #!/usr/bin/perl # The LearningOnline Network # -# $Id: refresh_courseids_db.pl,v 1.12 2012/07/21 20:18:37 raeburn Exp $ +# $Id: refresh_courseids_db.pl,v 1.15 2013/05/27 17:24:11 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -85,6 +85,8 @@ my @ids=&Apache::lonnet::current_machine $env{'allowed.bre'} = 'F'; foreach my $dom (@domains) { + $env{'user.domain'} = $dom; + $env{'user.name'} = &Apache::lonnet::get_domainconfiguser($dom); my %courseshash; my %currhash = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,\@ids,'.'); my %lastaccess = &Apache::lonnet::courselastaccess($dom,undef,\@ids); @@ -101,6 +103,8 @@ foreach my $dom (@domains) { } } } + delete($env{'user.name'}); + delete($env{'user.domain'}); } delete($env{'allowed.bre'}); @@ -242,6 +246,20 @@ sub recurse_courses { } unless ($chome eq 'no_host') { + if (($lastaccess->{$cid} eq '') || + ($lastaccess->{$cid} > $twodaysago)) { + my $contentchange; + if ($courseinfo{'internal.created'} eq '') { + $contentchange = &last_map_update($cnum,$cdom); + } else { + unless ($courseinfo{'internal.created'} > $lastaccess->{$cid}) { + $contentchange = &last_map_update($cnum,$cdom); + } + } + if (($contentchange) && ($contentchange > $courseinfo{'internal.contentchange'})) { + $changes{'internal.contentchange'} = $contentchange; + } + } $courseshash->{$chome}{$cid} = { description => $courseinfo{'description'}, inst_code => $inst_code, @@ -489,3 +507,21 @@ sub read_paramdata { return $resourcedata; } +sub last_map_update { + my ($cnum,$cdom) = @_; + my $lastupdate = 0; + my $path = &LONCAPA::propath($cdom,$cnum); + if (-d "$path/userfiles") { + if (opendir(my $dirh, "$path/userfiles")) { + my @maps = grep(/^default_?\d*\.(?:sequence|page)$/,readdir($dirh)); + foreach my $map (@maps) { + my $mtime = (stat("$path/userfiles/$map"))[9]; + if ($mtime > $lastupdate) { + $lastupdate = $mtime; + } + } + } + } + return $lastupdate; +} +