--- loncom/interface/loncommon.pm 2002/08/07 15:39:58 1.49 +++ loncom/interface/loncommon.pm 2002/08/22 21:20:23 1.53.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.49 2002/08/07 15:39:58 ng Exp $ +# $Id: loncommon.pm,v 1.53.2.1 2002/08/22 21:20:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -80,7 +80,7 @@ package Apache::loncommon; use strict; use Apache::lonnet(); use GDBM_File; -use POSIX qw(strftime); +use POSIX qw(strftime mktime); use Apache::Constants qw(:common); use Apache::lonmsg(); my $readit; @@ -242,7 +242,7 @@ of the element the selection from the se ############################################################### sub browser_and_searcher_javascript { return < + Version 4 + Version 5 END return $result; } @@ -844,7 +846,7 @@ sub initialize_keywords { # Set up the hash as a database my %thesaurus_db; if (! tie(%thesaurus_db,'GDBM_File', - $thesaurus_db_file,&GDBM_READER,0640)){ + $thesaurus_db_file,&GDBM_READER(),0640)){ &Apache::lonnet::logthis("Could not tie \%thesaurus_db to ". $thesaurus_db_file); return 0; @@ -957,7 +959,7 @@ sub get_related_words { return (); } if (! tie(%thesaurus_db,'GDBM_File', - $thesaurus_db_file,&GDBM_READER,0640)){ + $thesaurus_db_file,&GDBM_READER(),0640)){ return (); } my @Words=(); @@ -1151,6 +1153,47 @@ sub get_student_answers { ############################################### + +sub timehash { + my @ltime=localtime(shift); + return ( 'seconds' => $ltime[0], + 'minutes' => $ltime[1], + 'hours' => $ltime[2], + 'day' => $ltime[3], + 'month' => $ltime[4]+1, + 'year' => $ltime[5]+1900, + 'weekday' => $ltime[6], + 'dayyear' => $ltime[7]+1, + 'dlsav' => $ltime[8] ); +} + +sub maketime { + my %th=@_; + return POSIX::mktime( + ($th{'seconds'},$th{'minutes'},$th{'hours'}, + $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'})); +} + + +sub findallcourses { + my %courses=(); + my $now=time; + foreach (keys %ENV) { + if ($_=~/^user\.role\.\w+\.\/(\w+)\/(\w+)/) { + my ($starttime,$endtime)=$ENV{$_}; + my $active=1; + if ($starttime) { + if ($now<$starttime) { $active=0; } + } + if ($endtime) { + if ($now>$endtime) { $active=0; } + } + if ($active) { $courses{$1.'_'.$2}=1; } + } + } + return keys %courses; +} + ############################################### sub get_unprocessed_cgi {