[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface lonannounce.pm lonsyllabus.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 21 May 2003 20:10:53 -0000


www		Wed May 21 16:10:53 2003 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
    /loncom/interface	lonannounce.pm lonsyllabus.pm 
  Log:
  Bug 1108: show date range for announcements.
  Also: include announcements on Roles/Courses and on Syllabus
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.56 loncom/auth/lonroles.pm:1.57
--- loncom/auth/lonroles.pm:1.56	Mon Apr  7 14:24:05 2003
+++ loncom/auth/lonroles.pm	Wed May 21 16:10:53 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.56 2003/04/07 18:24:05 www Exp $
+# $Id: lonroles.pm,v 1.57 2003/05/21 20:10:53 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,6 +50,7 @@
 use Apache::File();
 use Apache::lonmenu;
 use Apache::loncommon;
+use Apache::lonannounce;
 
 sub handler {
 
@@ -437,6 +438,9 @@
                         $r->print('<td>&nbsp;</td>');
                     }
                 }
+                $tremark.=&Apache::lonannounce::showday(time,1,
+                         &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
+                
 		$r->print('<td><font color="'.$tfont.'">'.$trole.
                       '</font></td><td><font color="'.$tfont.'">'.$ttype.
                       '</font></td><td><font color="'.$tfont.'">'.$twhere.
Index: loncom/interface/lonannounce.pm
diff -u loncom/interface/lonannounce.pm:1.10 loncom/interface/lonannounce.pm:1.11
--- loncom/interface/lonannounce.pm:1.10	Wed May 21 15:15:41 2003
+++ loncom/interface/lonannounce.pm	Wed May 21 16:10:53 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Announce
 #
-# $Id: lonannounce.pm,v 1.10 2003/05/21 19:15:41 www Exp $
+# $Id: lonannounce.pm,v 1.11 2003/05/21 20:10:53 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -78,7 +78,8 @@
         if ($_) {
 	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
             my $msg=join('@',@msg);
-            my $fullmsg=$ENV{'course.'.$courseid.'.description'}.': '.$msg;
+            my $fullmsg=$ENV{'course.'.$courseid.'.description'}.
+		', '.localtime($start).' - '.localtime($end).': '.$msg;
             if ($courseid eq $ENV{'request.course.id'}) {
               if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
                $output.='<input type="checkbox" name="remove_'.$start.'_'.
@@ -86,12 +87,43 @@
 	      }
 	    }
             $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
-	       substr($msg,0,20).'...</a><br>';
+	       substr($msg,0,20).'...</a><br />';
        }
     }
     return '<td><b>'.$day.'</b><br>'.$output.'</td>';
 }
 
+sub plaincell {
+    my ($text)=@_;
+    my $output='';
+    foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
+        if ($_) {
+	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
+            my $msg=join('@',@msg);
+            my $fullmsg=$ENV{'course.'.$courseid.'.description'}.
+		', '.localtime($start).' - '.localtime($end).': '.$msg;
+            $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
+	       substr($msg,0,40).'...</a><br />';
+       }
+    }
+    return $output;
+}
+
+sub listcell {
+    my ($text)=@_;
+    my $output='';
+    foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
+        if ($_) {
+	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
+            my $msg=join('@',@msg);
+            my $fullmsg=localtime($start).' to '.localtime($end).':<br /><b>'.
+               $msg.'</b>';
+            $output.='<li>'.$fullmsg.'</li>';
+       }
+    }
+    return $output;
+}
+
 sub nextday {
     my %th=@_;
     $th{'day'}++;
@@ -99,7 +131,7 @@
 }
 
 sub showday {
-    my ($tk,%allcal)=@_;
+    my ($tk,$mode,%allcal)=@_;
     my %th=&Apache::loncommon::timehash($tk);
     my ($nextday,$nextmonth)=&nextday(%th);
     my $outp='';
@@ -111,7 +143,17 @@
             $allcal{$_};
         }
     }
-    return ($nextday,$nextmonth,&normalcell($th{'day'},$outp));
+    unless ($mode) {
+       return ($nextday,$nextmonth,&normalcell($th{'day'},$outp));
+   } elsif ($outp) {
+       if ($mode==1) {
+          return '<br />'.&plaincell($outp);
+      } else {
+          return '<ul>'.&listcell($outp).'</ul>';
+      }
+   } else {
+       return '';
+   }
 }
 
 sub handler {
@@ -230,7 +272,7 @@
     $r->print('<tr>');
     for (my $i=0;$i<$weekday;$i++) { $r->print(&emptycell); }
     for (my $i=$weekday;$i<=6;$i++) { 
-        ($tk,$nm,$outp)=&showday($tk,%allcal);
+        ($tk,$nm,$outp)=&showday($tk,0,%allcal);
         $r->print($outp);
     }
     $r->print('</tr>');
@@ -238,7 +280,7 @@
     for (my $k=0;$k<=3;$k++) {
         $r->print('<tr>');
         for (my $i=0;$i<=6;$i++) {
-            ($tk,$nm,$outp)=&showday($tk,%allcal);
+            ($tk,$nm,$outp)=&showday($tk,0,%allcal);
             if ($month!=$nm) { $outp=&emptycell; }
             $r->print($outp);
         }
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.18 loncom/interface/lonsyllabus.pm:1.19
--- loncom/interface/lonsyllabus.pm:1.18	Sat May 10 19:01:56 2003
+++ loncom/interface/lonsyllabus.pm	Wed May 21 16:10:53 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.18 2003/05/10 23:01:56 www Exp $
+# $Id: lonsyllabus.pm,v 1.19 2003/05/21 20:10:53 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::lonnet;
 use Apache::lontexconvert;
 use Apache::lonfeedback;
+use Apache::lonannounce;
 
 sub handler {
     my $r = shift;
@@ -92,7 +93,9 @@
        ("Syllabus",$forcestudent,$addentries,'',$cdom,$ENV{'form.register'}));
     $r->print('<h1>'.$courseenv{'description'}.'</h1><h3>'.
               $Apache::lonnet::domaindescription{$cdom}.'</h3>');
-
+# -------------------------------------------------------------- Announcements?
+    $r->print(&Apache::lonannounce::showday(time,2,
+                         &Apache::lonannounce::readcalendar($cdom.'_'.$cnum)));
 # -------------------------------------------------------- Get course personnel
     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
     $r->print('<table border="2">');