File:  [LON-CAPA] / loncom / interface / loncommunicate.pm
Revision 1.22: download - view: text, annotated - select for diffs
Mon May 17 19:00:46 2004 UTC (19 years, 11 months ago) by raeburn
Branches: MAIN
CVS tags: version_1_2_X, version_1_2_1, version_1_2_0, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, HEAD
Course Coordinators and Instructors can schedule blocking periods for student display of e-mail.
During a blocking period students will be unable to display LON-CAPA e-mail sent during the current
blocking period. If Course Coodinators or Instructors need to contact students during this time, they
should send a critical message (these will still be viewable). Note: because COM functions can be
used outside a course context, blocking prevents display of all messages sent to the student during the
blocking period (including other courses).

    1: # The LearningOnline Network
    2: # Communicate
    3: #
    4: # $Id: loncommunicate.pm,v 1.22 2004/05/17 19:00:46 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###
   29: 
   30: package Apache::loncommunicate;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common);
   34: use Apache::lonmsg();
   35: use Apache::loncommon;
   36: use Apache::lonlocal;
   37: 
   38: sub menu {
   39:     my $r=shift;
   40:     my %lt=&Apache::lonlocal::texthash(
   41: 'vam' => 'View All Messages',
   42: 'vcm' => 'View Critical Messages',
   43: 'smu' => 'Send Message to User(s)',
   44: 'bmc' => 'Broadcast Message to Course',
   45: 'dmu' => 'Distribute Messages from Uploaded File to Course',
   46: 'unr' => 
   47:      'User Notes, Records of Face-to-Face Discussions, and Critical Messages',
   48: 'nm' => 'New Messages',
   49: 'su' => 'Subject',
   50: 'da' => 'Date',
   51: 'us' => 'Username',
   52: 'op' => 'Open',
   53: 'do' => 'Domain',
   54: 'cbs' => 'Configure blocking of student communication during exams' 
   55: 
   56: );
   57:     my %help=();
   58:     foreach ('Course_Face_To_Face_Records,Course_Critical_Message',
   59: 	     'Course_Broadcast_Message') {
   60: 	$help{$_}=&Apache::loncommon::help_open_topic($_);
   61:     }
   62: # ------------------------------------------------------------------------ Menu
   63:    $r->print(<<END);
   64: <table cellspacing="10" cellpadding="2">
   65: <tr><td bgcolor="#FFFFAA">
   66:   <b><a href="/adm/email/">$lt{'vam'}</a></b>
   67: </td></tr>
   68: <tr><td bgcolor="#FFFFAA">
   69:   <b><a href="/adm/email?critical=display">$lt{'vcm'}</a></b>
   70: </td></tr>
   71: <tr><td bgcolor="#FFFFAA">
   72:   <b><a href="/adm/email?compose=individual">$lt{'smu'}</a></b>
   73: </td></tr>
   74: END
   75:     if (($ENV{'request.course.id'}) && 
   76:         (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
   77:         $r->print(<<END);
   78: <tr><td bgcolor="#FFFFAA">
   79:     <b><a href="/adm/email?compose=group">$lt{'bmc'}</a></b>$help{'Course_Broadcast_Message'}
   80: </td></tr>
   81: <tr><td bgcolor="#FFFFAA">
   82:   <b><a href="/adm/email?compose=upload">$lt{'dmu'}</a></b>
   83: </td></tr>
   84: <tr><td bgcolor="#FFFFAA">
   85: <b><a href="/adm/email?recordftf=query">$lt{'unr'}</a></b>$help{'Course_Face_To_Face_Records,Course_Critical_Message'}
   86: </td></tr>
   87: <tr><td bgcolor="#FFFFAA">
   88:   <b><a href="/adm/email?block=display">$lt{'cbs'}</a>
   89: </td></tr>
   90: END
   91:     }
   92:     $r->print('</table>');
   93:     my @msgids = sort split(/\&/,&Apache::lonnet::reply
   94:                             ('keys:'.$ENV{'user.domain'}.':'.
   95:                              $ENV{'user.name'}.':nohist_email',
   96:                              $ENV{'user.home'}));
   97:     my @newmsgs;
   98:     my %setters = ();
   99:     my $startblock = 0;
  100:     my $endblock = 0;
  101:     my %blocked = ();
  102:     my $numblocked = 0;
  103:     # Check for blocking of display because of scheduled online exams.
  104:     &Apache::lonmsg::blockcheck(\%setters,\$startblock,\$endblock);
  105:     foreach (@msgids) {
  106:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status)=
  107: 	    &Apache::lonmsg::unpackmsgid($_);
  108:         if (defined($sendtime) && $sendtime!~/error/) {
  109:             my $numsendtime = $sendtime;
  110:             $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
  111:             if ($status eq 'new') {
  112:                 if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
  113:                     $blocked{$_} = 'ON';
  114:                     $numblocked ++;
  115:                 } else {
  116:                     push @newmsgs, { 
  117:                         msgid    => $_,
  118:                         sendtime => $sendtime,
  119:                         shortsub => &Apache::lonnet::unescape($shortsubj),
  120:                         from     => $fromname,
  121:                         fromdom  => $fromdom 
  122:                         }
  123:                 }
  124:             }
  125:         }
  126:     }
  127:     if ($#newmsgs >= 0) {
  128:         $r->print(<<TABLEHEAD);
  129: <h2>$lt{'nm'}</h2>
  130: <table border=2><tr><th>&nbsp</th>
  131: <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th></tr>
  132: TABLEHEAD
  133:         foreach my $msg (@newmsgs) {
  134:             $r->print(<<"ENDLINK");
  135: <tr bgcolor="#FFBB77">
  136: <td><a href="/adm/email?display=$msg->{'msgid'}">$lt{'op'}</a></td>
  137: ENDLINK
  138:             foreach ('sendtime','from','fromdom','shortsub') {
  139:                 $r->print("<td>$msg->{$_}</td>");
  140:             }
  141:             $r->print("</td></tr>");
  142:         }
  143:         $r->print('</table></body></html>');
  144:     } elsif ($numblocked == 0) {
  145:         $r->print("<h3>".&mt('You have no unread messages')."</h3>");
  146:     }
  147:     if ($numblocked > 0) {
  148:         my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
  149:         my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
  150:         if ($numblocked == 1) {
  151:             $r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread message').".</h3>");
  152:             $r->print(&mt('This message is not viewable because').' ');
  153:         } else {
  154:             $r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread messages').".</h3>");
  155:             $r->print(&mt('These').' '.$numblocked.' '.&mt('messages are not viewable because '));
  156:         }
  157:         $r->print(
  158: &mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');
  159:         &Apache::lonmsg::build_block_table($r,$startblock,$endblock,\%setters);
  160:     }
  161: }
  162: 
  163: sub handler {
  164:     my $r = shift;
  165:     &Apache::loncommon::content_type($r,'text/html');
  166:     $r->send_http_header;
  167:     return OK if $r->header_only;
  168: #
  169: # Start document
  170: #
  171:     $r->print(<<END);
  172: <html>
  173: <head>
  174: <title>The LearningOnline Network with CAPA</title>
  175: </head>
  176: END
  177: 
  178: # ----------------------------------------------------------------- Breadcrumbs
  179:     &Apache::lonhtmlcommon::clear_breadcrumbs();
  180:     &Apache::lonhtmlcommon::add_breadcrumb
  181:         ({href=>"/adm/communicate",
  182:           text=>"Communication/Messages",
  183:           faq=>12,bug=>'Communication Tools',});
  184: 
  185: # ---------------------------------------------------------------------- Header
  186:     &Apache::lonmsg::header($r);
  187:     &menu($r);
  188:     return OK;
  189: }
  190: 
  191: 1;
  192: __END__

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