--- loncom/misc/refresh_courseids_db.pl 2012/07/21 20:18:37 1.12 +++ loncom/misc/refresh_courseids_db.pl 2012/07/21 21:20:25 1.13 @@ -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.13 2012/07/21 21:20:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -242,6 +242,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 +503,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; +} +