[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm lonnavmaps.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Mon, 04 Oct 2004 21:35:52 -0000


raeburn		Mon Oct  4 17:35:52 2004 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm lonfeedback.pm 
  Log:
  Fix bug #3515. identification of resources with discussion now occurs in lonfeedback after 'Mark all posts as read call'. To simplify further we might want to eliminate the extra code in lonnavmaps, called when sort is by "Has Discussion" and always do the resource->has_discussion call in lonfeedback.  
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.298 loncom/interface/lonnavmaps.pm:1.299
--- loncom/interface/lonnavmaps.pm:1.298	Wed Sep 29 15:13:20 2004
+++ loncom/interface/lonnavmaps.pm	Mon Oct  4 17:35:52 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.298 2004/09/29 19:13:20 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.299 2004/10/04 21:35:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1585,7 +1585,6 @@
 	    }
 	    if ($totdisc > 0) {
 		$haveDisc =~ s/:$//;
-		my $navurl = $ENV{'QUERY_STRING'};
 		$result .= (<<END);
 	<input type="hidden" name="navmaps" value="$haveDisc" />
     </form>
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.127 loncom/interface/lonfeedback.pm:1.128
--- loncom/interface/lonfeedback.pm:1.127	Tue Sep 21 16:44:16 2004
+++ loncom/interface/lonfeedback.pm	Mon Oct  4 17:35:52 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.127 2004/09/21 20:44:16 albertel Exp $
+# $Id: lonfeedback.pm,v 1.128 2004/10/04 21:35:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,6 +36,7 @@
 use Apache::lontexconvert();
 use Apache::lonlocal; # must not have ()
 use Apache::lonhtmlcommon();
+use Apache::lonnavmaps;
 use HTML::LCParser();
 use Apache::lonspeller();
 use Cwd;
@@ -2716,6 +2717,24 @@
     }
     return $newattachmenturl; 
 }
+
+sub has_discussion {
+    my $resourcesref = shift;
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    my @allres=$navmap->retrieveResources();
+    foreach my $resource (@allres) {
+        if ($resource->hasDiscussion()) {
+            my $ressymb;
+            if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) {
+                $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
+            } else {
+                $ressymb = $resource->symb();
+            }
+            push @{$resourcesref}, $ressymb;
+        }
+    }
+    return;
+} 
   
 sub handler {
   my $r = shift;
@@ -2728,7 +2747,7 @@
 # --------------------------- Get query string for limited number of parameters
 
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-         ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navmaps','navurl','navtime','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);
+         ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);
   if ($ENV{'form.discsymb'}) {
       my $symb = $ENV{'form.discsymb'};
       my $readkey = $symb.'_read';
@@ -2875,13 +2894,17 @@
       }
       &print_sortfilter_options($r,$symb,$previous,$feedurl);
       return OK;
-  } elsif ($ENV{'form.navmaps'}) {
+  } elsif ($ENV{'form.navtime'}) {
       my %discinfo = ();
       my @resources = ();
-      if ($ENV{'form.navmaps'} =~ /:/) {
-          @resources = split/:/,$ENV{'form.navmaps'};
+      if (defined($ENV{'form.navmaps'})) {
+          if ($ENV{'form.navmaps'} =~ /:/) {
+              @resources = split/:/,$ENV{'form.navmaps'};
+          } else {
+              @resources = ("$ENV{'form.navmaps'}");
+          }
       } else {
-          @resources = ("$ENV{'form.navmaps'}");
+          &has_discussion(\@resources);
       }
       my $numitems = @resources;
       my $feedurl = '/adm/navmaps';
@@ -2890,7 +2913,8 @@
       }
       my %lt = &Apache::lonlocal::texthash(
           'mnpa' => 'Marked "New" posts as read in a total of',
-          'robb' => 'resources/bulletin boards.'
+          'robb' => 'resources/bulletin boards.',
+          'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.'
       );       
       foreach (@resources) {
 # backward compatibility (bulletin boards used to be 'wrapped')
@@ -2903,7 +2927,12 @@
           my $lastkey = $ressymb.'_lastread';
           $discinfo{$lastkey} = $ENV{'form.navtime'};
       }
-      &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+      my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";
+      if ($numitems > 0) {
+          &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+      } else {
+          $textline = "<b>$lt{'twnp'}</b>";
+      }
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       $r->print (<<ENDREDIR);
@@ -2915,7 +2944,7 @@
 </head>
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />
-<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>
+$textline
 <form name="reldt" action="$feedurl" target="loncapaclient">
 </form>
 <br /><a href="$feedurl">Continue</a>