--- loncom/interface/lonwhatsnew.pm 2005/04/05 22:49:17 1.1 +++ loncom/interface/lonwhatsnew.pm 2005/04/11 12:20:23 1.6 @@ -1,13 +1,40 @@ +# +# $Id: lonwhatsnew.pm,v 1.6 2005/04/11 12:20:23 raeburn Exp $ +# +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# LON-CAPA is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LON-CAPA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LON-CAPA; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# /home/httpd/html/adm/gpl.txt +# +# http://www.lon-capa.org/ +# + + package Apache::lonwhatsnew; use strict; use lib qw(/home/httpd/lib/perl); use Apache::lonnet; -use Apache::loncommon; -use Apache::lonhtmlcommon; +use Apache::loncommon(); +use Apache::lonhtmlcommon(); use Apache::lonlocal; -use Apache::loncoursedata; -use Apache::lonnavmaps; +use Apache::loncoursedata(); +use Apache::lonnavmaps(); use Apache::Constants qw(:common :http); use Time::Local; @@ -20,16 +47,16 @@ sub handler { my $r = shift; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']); - my $command = $ENV{'form.command'}; + my $command = $env{'form.command'}; if ($command eq '') { $command = "info"; } $r->print(&display_header()); - if (! (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$ENV{'request.course.id'})))) { + if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$env{'request.course.id'})))) { # Not in a course, or not allowed to modify parms - $ENV{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity"; + $env{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity"; return HTTP_NOT_ACCEPTABLE; } @@ -150,9 +177,10 @@ sub display_nav_box { #------------------------------- sub display_header{ + my $html=&Apache::lonxml::xmlbegin(); my $bodytag=&Apache::loncommon::bodytag('Course Action Items'); return(< +$html Course Action Items @@ -185,10 +213,10 @@ sub display_actions_box() { my $domain=&Apache::loncommon::determinedomain(); my $function; - if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { + if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { $function='coordinator'; } - if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) { + if ($env{'request.role'}=~/^(su|dc|ad|li)/) { $function='admin'; } @@ -198,7 +226,7 @@ sub display_actions_box() { &getitems(\%unread,\%ungraded,\%bombed,\@newdiscussions,\@tograde,\@bombs); my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs); - unless ($ENV{'request.course.id'}) { + unless ($env{'request.course.id'}) { $r->print('
You are accessing an invalid course


'); return; } @@ -223,13 +251,8 @@ END my $rowNum = 0; foreach my $ressymb (@newdiscussions) { my $forum_title = $unread{$ressymb}{'title'}; - my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb); - my $feedurl = &Apache::lonnet::clutter($url); -# backward compatibility (bulletin boards used to be 'wrapped') - if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { - $feedurl=~s|^/adm/wrapper||; - } - my $unreadnum = keys %{$unread{$ressymb}}; + my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb); + my $unreadnum = keys(%{$unread{$ressymb}}); $unreadnum = $unreadnum - 2; if ($unreadnum > 0) { if ($rowNum %2 == 1) { @@ -382,17 +405,17 @@ sub getitems { my $navmap = Apache::lonnavmaps::navmap->new(); my @allres=$navmap->retrieveResources(); my %discussiontime = &Apache::lonnet::dump('discussiontimes', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); - my %lastread = &Apache::lonnet::dump('nohist_'.$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'},'lastread'); + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}); + my %lastread = &Apache::lonnet::dump('nohist_'.$env{'request.course.id'}.'_discuss',$env{'user.domain'},$env{'user.name'},'lastread'); my %lastreadtime = (); my @discussions = (); my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist(); - foreach (keys %lastread) { - my $key = $_; - $key =~ s/_lastread$//; - $lastreadtime{$key} = $lastread{$_}; + foreach my $key (keys(%lastread)) { + my $newkey = $key; + $newkey =~ s/_lastread$//; + $lastreadtime{$newkey} = $lastread{$key}; } foreach my $resource (@allres) { my $result = ''; @@ -402,11 +425,8 @@ sub getitems { %{$$ungraded{$symb}} = (); my $title = $resource->compTitle(); my $ressymb = $symb; - if ($ressymb =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { - $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; - unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { - $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|; - } + if ($ressymb =~ m-___adm/\w+/\w+/\d+/bulletinboard$-) { + $ressymb = $resource->wrap_symb(); } # Check for unread discussion postings @@ -420,9 +440,9 @@ sub getitems { if (defined($lastreadtime{$ressymb})) { $prevread = $lastreadtime{$ressymb}; } - my %contrib = &Apache::lonnet::restore($ressymb,$ENV{'request.course.id'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'}, + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}); if ($contrib{'version'}) { for (my $id=1;$id<=$contrib{'version'};$id++) { unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) { @@ -442,7 +462,7 @@ sub getitems { my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($url,$symb); foreach my $student (keys(%$classlist)) { - my ($uname,$udom) = split/:/,$student; + my ($uname,$udom) = split(/:/,$student); my %status=&Apache::grades::student_gradeStatus($url,$symb,$udom,$uname,$partlist); my $submitted = 0; my $graded = 0; @@ -483,14 +503,13 @@ sub getmail { my ($newmsgs,$critmsgs) = @_; # Check for unread mail in course my $msgcount = 0; - my @msgids = sort split(/\&/,&Apache::lonnet::reply - ('keys:'.$ENV{'user.domain'}.':'. - $ENV{'user.name'}.':nohist_email', - $ENV{'user.home'})); - foreach my $msgid (@msgids) { + + my @messages = &Apache::lonnet::getkeys('nohist_email'); + foreach my $message (@messages) { + my $msgid=&Apache::lonnet::escape($message); my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)= &Apache::lonmsg::unpackmsgid($msgid); - if ($fromcid eq $ENV{'request.course.id'}) { + if ($fromcid eq $env{'request.course.id'}) { if (defined($sendtime) && $sendtime!~/error/) { my $numsendtime = $sendtime; $sendtime = &Apache::lonlocal::locallocaltime($sendtime); @@ -512,10 +531,10 @@ sub getmail { my %what=&Apache::lonnet::dump('critical'); my $result = ''; my $critmsgcount = 0; - foreach my $msgid (sort keys %what) { + foreach my $msgid (sort(keys(%what))) { my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)= &Apache::lonmsg::unpackmsgid($_); - if ($fromcid eq $ENV{'request.course.id'}) { + if ($fromcid eq $env{'request.course.id'}) { if (defined($sendtime) && $sendtime!~/error/) { my $numsendtime = $sendtime; $sendtime = &Apache::lonlocal::locallocaltime($sendtime);