[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm /publisher packages.tab

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 04 Jun 2004 19:27:34 -0000


albertel		Fri Jun  4 15:27:34 2004 EDT

  Modified files:              
    /loncom/publisher	packages.tab 
    /loncom/interface	lonfeedback.pm 
  Log:
  - adding the ability to choose between whether 'closed' discussions are also 'hidden'
   - which is the last of BUG#2636
  
  
Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.34 loncom/publisher/packages.tab:1.35
--- loncom/publisher/packages.tab:1.34	Thu Jun  3 16:06:15 2004
+++ loncom/publisher/packages.tab	Fri Jun  4 15:27:33 2004
@@ -36,6 +36,9 @@
 part_0&interval&type:date_interval
 part_0&discussend&display:Discussion End Time
 part_0&discussend&type:date_end
+part_0&discusshide&display:Hide Closed Discussion
+part_0&discusshide&type:string_yesno
+part_0&discusshide&default:yes
 numericalhint&tol&display:Numerical Tolerance
 numericalhint&tol&type:tolerance
 numericalhint&tol&default:5%
@@ -79,9 +82,12 @@
 extension_page&contentopen&display:Opening Date
 extension_page&contentopen&type:date_start
 extension_page&contentclose&display:Due Date
+extension_page&contentclose&type:date_end
 extension_page&discussend&display:Discussion End Time
 extension_page&discussend&type:date_end
-extension_page&contentclose&type:date_end
+extension_page&discusshide&display:Hide Closed Discussion
+extension_page&discusshide&type:string_yesno
+extension_page&discusshide&default:yes
 extension_page&encrypturl&type:string_yesno
 extension_page&encrypturl&display:Do not show plain URL
 
@@ -99,5 +105,8 @@
 default&encrypturl&display:Do not show plain URL
 default&discussend&display:Discussion End Time
 default&discussend&type:date_end
-part_0&hiddenresource&display:Resource Hidden from Students
-part_0&hiddenresource&type:string_yesno
+default&discusshide&display:Hide Closed Discussion
+default&discusshide&type:string_yesno
+default&discusshide&default:yes
+default&hiddenresource&display:Resource Hidden from Students
+default&hiddenresource&type:string_yesno
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.91 loncom/interface/lonfeedback.pm:1.92
--- loncom/interface/lonfeedback.pm:1.91	Fri Jun  4 14:58:32 2004
+++ loncom/interface/lonfeedback.pm	Fri Jun  4 15:27:33 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.91 2004/06/04 18:58:32 matthew Exp $
+# $Id: lonfeedback.pm,v 1.92 2004/06/04 19:27:33 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,25 +37,40 @@
 use Apache::lonlocal; # must not have ()
 use Apache::lonhtmlcommon();
 
-sub discussion_closed {
+sub discussion_open {
     my ($status)=@_;
-    if (!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
+    if (defined($status) &&
+	!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
 	  || $status eq 'OPEN')) {
-	return '1';
+	&Apache::lonnet::logthis(" no open due to status $status");
+	return 0;
     }
     my $close=&Apache::lonnet::EXT('resource.0.discussend');
     if (defined($close) && $close ne '' && $close < time) {
-	return '1'
+	&Apache::lonnet::logthis(" no open due to time ");
+	return 0;
     }
-    return 0;
+    &Apache::lonnet::logthis(" open ");
+    return 1;
+}
+
+sub discussion_visible {
+    my ($status)=@_;
+    if (not &discussion_open($status)) {
+	my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
+	if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden))  {
+	    &Apache::lonnet::logthis(" hidden ");
+	    return 0;
+	}
+    }
+    &Apache::lonnet::logthis(" visible ");
+    return 1;
 }
 
 sub list_discussion {
     my ($mode,$status,$symb)=@_;
 
-    if (&discussion_closed($status)) {
-	return '';
-    }
+    if (not &discussion_visible($status)) { return ''; }
     my @bgcols = ("#cccccc","#eeeeee");
     my $discussiononly=0;
     if ($mode eq 'board') { $discussiononly=1; }
@@ -259,7 +274,7 @@
 			    $sender='<i>'.$screenname.'</i>';
 			}
 		    }
-		    if (!&discussion_closed($status) &&
+		    if (&discussion_open($status) &&
 			&Apache::lonnet::allowed('pch',
 						 $ENV{'request.course.id'}.
 						 ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
@@ -432,7 +447,7 @@
 ENDDISCUSS
       $discussion.=&generate_preview_button();
     } else {
-	if (!&discussion_closed($status) &&
+	if (&discussion_open($status) &&
 	    &Apache::lonnet::allowed('pch',
 				   $ENV{'request.course.id'}.
 	($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
@@ -656,7 +671,7 @@
 	}
     }
     if ($ENV{'request.course.id'}) {
-	if (not &discussion_closed() &&
+	if (&discussion_open() &&
 	    &Apache::lonnet::allowed('pch',
 				     $ENV{'request.course.id'}.
 				     ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
@@ -833,7 +848,7 @@
 sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
     my $status='';
-    if (not &discussion_closed() &&
+    if (&discussion_open() &&
 	&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {