Diff for /loncom/interface/lonwhatsnew.pm between versions 1.1 and 1.5

version 1.1, 2005/04/05 22:49:17 version 1.5, 2005/04/07 06:56:23
Line 1 Line 1
   #
   # $Id$
   #
   # 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;  package Apache::lonwhatsnew;
   
 use strict;  use strict;
 use lib qw(/home/httpd/lib/perl);  use lib qw(/home/httpd/lib/perl);
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon;  use Apache::loncommon();
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::loncoursedata;  use Apache::loncoursedata();
 use Apache::lonnavmaps;  use Apache::lonnavmaps();
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Time::Local;  use Time::Local;
   
Line 20  sub handler { Line 47  sub handler {
     my $r = shift;      my $r = shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);
   
     my $command = $ENV{'form.command'};      my $command = $env{'form.command'};
   
     if ($command eq '') {      if ($command eq '') {
         $command = "info";          $command = "info";
     }      }
   
     $r->print(&display_header());      $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          # 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;          return HTTP_NOT_ACCEPTABLE;
     }      }
   
Line 150  sub display_nav_box { Line 177  sub display_nav_box {
 #-------------------------------  #-------------------------------
   
 sub display_header{  sub display_header{
       my $html=&Apache::lonxml::xmlbegin();
     my $bodytag=&Apache::loncommon::bodytag('Course Action Items');      my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
     return(<<ENDHEAD);      return(<<ENDHEAD);
 <html>  $html
 <head>  <head>
 <title>Course Action Items</title>  <title>Course Action Items</title>
 </head>  </head>
Line 185  sub display_actions_box() { Line 213  sub display_actions_box() {
   
     my $domain=&Apache::loncommon::determinedomain();      my $domain=&Apache::loncommon::determinedomain();
     my $function;      my $function;
     if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {      if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
         $function='coordinator';          $function='coordinator';
     }      }
     if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {      if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
         $function='admin';          $function='admin';
     }      }
   
Line 198  sub display_actions_box() { Line 226  sub display_actions_box() {
     &getitems(\%unread,\%ungraded,\%bombed,\@newdiscussions,\@tograde,\@bombs);      &getitems(\%unread,\%ungraded,\%bombed,\@newdiscussions,\@tograde,\@bombs);
     my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs);      my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs);
   
     unless ($ENV{'request.course.id'}) {      unless ($env{'request.course.id'}) {
         $r->print('<br /><b><center>You are accessing an invalid course</center></b><br /><br />');          $r->print('<br /><b><center>You are accessing an invalid course</center></b><br /><br />');
         return;          return;
     }      }
Line 223  END Line 251  END
         my $rowNum = 0;          my $rowNum = 0;
         foreach my $ressymb (@newdiscussions) {          foreach my $ressymb (@newdiscussions) {
             my $forum_title = $unread{$ressymb}{'title'};              my $forum_title = $unread{$ressymb}{'title'};
             my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb);      my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
             my $feedurl = &Apache::lonnet::clutter($url);              my $unreadnum = keys(%{$unread{$ressymb}});
 # backward compatibility (bulletin boards used to be 'wrapped')  
             if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {  
                 $feedurl=~s|^/adm/wrapper||;  
             }  
             my $unreadnum = keys %{$unread{$ressymb}};  
             $unreadnum = $unreadnum - 2;              $unreadnum = $unreadnum - 2;
             if ($unreadnum > 0) {              if ($unreadnum > 0) {
                 if ($rowNum %2 == 1) {                  if ($rowNum %2 == 1) {
Line 382  sub getitems { Line 405  sub getitems {
     my $navmap = Apache::lonnavmaps::navmap->new();      my $navmap = Apache::lonnavmaps::navmap->new();
     my @allres=$navmap->retrieveResources();      my @allres=$navmap->retrieveResources();
     my %discussiontime = &Apache::lonnet::dump('discussiontimes',      my %discussiontime = &Apache::lonnet::dump('discussiontimes',
                $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},                 $env{'course.'.$env{'request.course.id'}.'.domain'},
                $ENV{'course.'.$ENV{'request.course.id'}.'.num'});                 $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 %lastread = &Apache::lonnet::dump('nohist_'.$env{'request.course.id'}.'_discuss',$env{'user.domain'},$env{'user.name'},'lastread');
     my %lastreadtime = ();      my %lastreadtime = ();
     my @discussions = ();      my @discussions = ();
     my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();      my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
   
     foreach (keys %lastread) {      foreach my $key (keys(%lastread)) {
         my $key = $_;          my $newkey = $key;
         $key =~ s/_lastread$//;          $newkey =~ s/_lastread$//;
         $lastreadtime{$key} = $lastread{$_};          $lastreadtime{$newkey} = $lastread{$key};
     }      }
     foreach my $resource (@allres) {      foreach my $resource (@allres) {
         my $result = '';          my $result = '';
Line 403  sub getitems { Line 426  sub getitems {
         my $title = $resource->compTitle();          my $title = $resource->compTitle();
         my $ressymb = $symb;          my $ressymb = $symb;
         if ($ressymb =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) {          if ($ressymb =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) {
             $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';              $ressymb = &Apache::lonfeedback::wrap_symb('bulletin___'.$2.$1.'/'.
             unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {         $2.'/bulletinboard');
                  $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|;  
             }  
         }          }
   
 # Check for unread discussion postings  # Check for unread discussion postings
Line 420  sub getitems { Line 441  sub getitems {
             if (defined($lastreadtime{$ressymb})) {              if (defined($lastreadtime{$ressymb})) {
                 $prevread = $lastreadtime{$ressymb};                  $prevread = $lastreadtime{$ressymb};
             }              }
             my %contrib = &Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},              my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},
             $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},              $env{'course.'.$env{'request.course.id'}.'.domain'},
             $ENV{'course.'.$ENV{'request.course.id'}.'.num'});              $env{'course.'.$env{'request.course.id'}.'.num'});
             if ($contrib{'version'}) {              if ($contrib{'version'}) {
                 for (my $id=1;$id<=$contrib{'version'};$id++) {                  for (my $id=1;$id<=$contrib{'version'};$id++) {
                     unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) {                      unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) {
Line 442  sub getitems { Line 463  sub getitems {
             my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);              my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
             my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($url,$symb);              my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($url,$symb);
             foreach my $student (keys(%$classlist)) {              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 %status=&Apache::grades::student_gradeStatus($url,$symb,$udom,$uname,$partlist);
                 my $submitted = 0;                  my $submitted = 0;
                 my $graded = 0;                  my $graded = 0;
Line 483  sub getmail { Line 504  sub getmail {
     my ($newmsgs,$critmsgs) = @_;      my ($newmsgs,$critmsgs) = @_;
 # Check for unread mail in course  # Check for unread mail in course
     my $msgcount = 0;      my $msgcount = 0;
     my @msgids = sort split(/\&/,&Apache::lonnet::reply  
                             ('keys:'.$ENV{'user.domain'}.':'.      my @messages = &Apache::lonnet::getkeys('nohist_email');
                              $ENV{'user.name'}.':nohist_email',      foreach my $message (@messages) {
                              $ENV{'user.home'}));   my $msgid=&Apache::lonnet::escape($message);
     foreach my $msgid (@msgids) {  
         my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)=          my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)=
             &Apache::lonmsg::unpackmsgid($msgid);              &Apache::lonmsg::unpackmsgid($msgid);
         if ($fromcid eq $ENV{'request.course.id'}) {          if ($fromcid eq $env{'request.course.id'}) {
             if (defined($sendtime) && $sendtime!~/error/) {              if (defined($sendtime) && $sendtime!~/error/) {
                 my $numsendtime = $sendtime;                  my $numsendtime = $sendtime;
                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);                  $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
Line 512  sub getmail { Line 532  sub getmail {
     my %what=&Apache::lonnet::dump('critical');      my %what=&Apache::lonnet::dump('critical');
     my $result = '';      my $result = '';
     my $critmsgcount = 0;      my $critmsgcount = 0;
     foreach my $msgid (sort keys %what) {      foreach my $msgid (sort(keys(%what))) {
         my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)=          my ($sendtime,$shortsubj,$fromname,$fromdom,$fromcid,$status)=
             &Apache::lonmsg::unpackmsgid($_);              &Apache::lonmsg::unpackmsgid($_);
         if ($fromcid eq  $ENV{'request.course.id'}) {          if ($fromcid eq  $env{'request.course.id'}) {
             if (defined($sendtime) && $sendtime!~/error/) {              if (defined($sendtime) && $sendtime!~/error/) {
                 my $numsendtime = $sendtime;                  my $numsendtime = $sendtime;
                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);                  $sendtime = &Apache::lonlocal::locallocaltime($sendtime);

Removed from v.1.1  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>