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

sakharuk lon-capa-cvs@mail.lon-capa.org
Wed, 23 Jun 2004 17:42:58 -0000


This is a MIME encoded message

--sakharuk1088012578
Content-Type: text/plain

sakharuk		Wed Jun 23 13:42:58 2004 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  Bug 2838 (print attached discussions too) is fixed.
  
  
--sakharuk1088012578
Content-Type: text/plain
Content-Disposition: attachment; filename="sakharuk-20040623134258.txt"

Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.94 loncom/interface/lonfeedback.pm:1.95
--- loncom/interface/lonfeedback.pm:1.94	Fri Jun 11 21:07:10 2004
+++ loncom/interface/lonfeedback.pm	Wed Jun 23 13:42:58 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.94 2004/06/12 01:07:10 www Exp $
+# $Id: lonfeedback.pm,v 1.95 2004/06/23 17:42:58 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,6 +65,7 @@
 sub list_discussion {
     my ($mode,$status,$symb)=@_;
 
+    my $outputtarget=$ENV{'form.grade_target'};
     if (not &discussion_visible($status)) { return ''; }
     my @bgcols = ("#cccccc","#eeeeee");
     my $discussiononly=0;
@@ -362,40 +363,47 @@
 
     if ($visible) {
 # Print the discusssion
-	$discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
-	my $colspan=$maxdepth+1;
-        $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.
-        '<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.
-        '<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.
-        '<tr><td>'.$lt{'disa'}.':&nbsp;<i>'.$currdisp.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.
-        '<tr><td>'.$lt{'npce'}.':&nbsp;<i>'.$currmark.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.
-        '</table></td></tr>'.
-        '<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
-        '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
-        if ($visible>2) {
-	    $discussion.='<td align="left">'.
-            '<a href="/adm/feedback?threadedon='.$ressymb;
-            if ($newpostsflag) {
-                $discussion .= '&previous='.$prevread;
-            }
-            $discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.
-            '<a href="/adm/feedback?threadedoff='.$ressymb;
-            if ($newpostsflag) {
-                $discussion .= '&previous='.$prevread;
-            }
-            $discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;</td>';
-	} 
-        if ($newpostsflag) {
-            if (!$markondisp) {
-                $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a>&nbsp;&nbsp;';
-            } else {
-                $discussion .= '<td>&nbsp;</td>';
-            }
-        } else {
-            $discussion .= '<td>&nbsp;</td>';
-        }
-        $discussion .= '</tr></table></td></tr>';
-
+	if ($outputtarget ne 'tex') {
+	    $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
+	    my $colspan=$maxdepth+1;
+	    $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.
+		'<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.
+		'<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.
+		'<tr><td>'.$lt{'disa'}.':&nbsp;<i>'.$currdisp.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.
+		'<tr><td>'.$lt{'npce'}.':&nbsp;<i>'.$currmark.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.
+		'</table></td></tr>'.
+		'<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
+		'<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
+	    if ($visible>2) {
+		$discussion.='<td align="left">'.
+		    '<a href="/adm/feedback?threadedon='.$ressymb;
+		if ($newpostsflag) {
+		    $discussion .= '&previous='.$prevread;
+		}
+		$discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.
+		    '<a href="/adm/feedback?threadedoff='.$ressymb;
+		if ($newpostsflag) {
+		    $discussion .= '&previous='.$prevread;
+		}
+		$discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;</td>';
+	    } 
+	    if ($newpostsflag) {
+		if (!$markondisp) {
+		    $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a>&nbsp;&nbsp;';
+		} else {
+		    $discussion .= '<td>&nbsp;</td>';
+		}
+	    } else {
+		$discussion .= '<td>&nbsp;</td>';
+	    }
+	    $discussion .= '</tr></table></td></tr>';
+	} else {
+	    $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.
+                         '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'.
+                         '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'.
+                         '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'.
+                         '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}';
+	}
         my $numhidden = keys %notshown;
         if ($numhidden > 0) {
             my $colspan = $maxdepth+1;
@@ -410,18 +418,40 @@
         }
 	foreach (sort { $a <=> $b } keys %alldiscussion) {
             unless ($notshown{$alldiscussion{$_}} eq '1') {
-	        $discussion.="\n<tr>";
+                if ($outputtarget ne 'tex') {
+		    $discussion.="\n<tr>";
+		} else {
+		    $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}';
+		}
 	        my $thisdepth=$depth[$alldiscussion{$_}];
-	        for (1..$thisdepth) {
-		    $discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';
-	        }
+                if ($outputtarget ne 'tex') {
+		    for (1..$thisdepth) {
+			$discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';
+		    }
+		}
 	        my $colspan=$maxdepth-$thisdepth+1;
-                $discussion.='<td  bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].'" colspan="'.$colspan.'">'.
+                if ($outputtarget ne 'tex') {
+		    $discussion.='<td  bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].'" colspan="'.$colspan.'">'.
                              $discussionitems[$alldiscussion{$_}].
 	                     '</td></tr>';
+		} else {
+		    #cleanup block
+		    $discussionitems[$alldiscussion{$_}]=~s/<table([^>]*)>/<table TeXwidth="90 mm">/;
+		    $discussionitems[$alldiscussion{$_}]=~s/<tr([^>]*)><td([^>]*)>/<tr><td TeXwidth="20 mm" align="left">/;
+                    my $threadinsert='';
+                    if ($thisdepth > 0) {
+			$threadinsert='<br /><strong>Reply: '.$thisdepth.'</strong>';
+		    }
+		    $discussionitems[$alldiscussion{$_}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/;
+		    $discussionitems[$alldiscussion{$_}]=~s/<a([^>]+)>(Hide|Delete|Reply|Submissions)<\/a>//g;
+                    $discussionitems[$alldiscussion{$_}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g;
+		    $discussion.=&Apache::lonxml::xmlparse('','tex',$discussionitems[$alldiscussion{$_}]);
+		}
 	    }
         }
-        $discussion.='</table><br /><br />';
+	if ($outputtarget ne 'tex') {
+	    $discussion.='</table><br /><br />';
+	}
     }
     if ($discussiononly) {
 	$discussion.=(<<ENDDISCUSS);
@@ -440,16 +470,20 @@
 </p>
 </form>
 ENDDISCUSS
-      $discussion.=&generate_preview_button();
+        if ($outputtarget ne 'tex') {
+	    $discussion.=&generate_preview_button();
+	}
     } else {
 	if (&discussion_open($status) &&
 	    &Apache::lonnet::allowed('pch',
 				   $ENV{'request.course.id'}.
 	($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
-			    $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
-				$symb.':::" '.$target.'>'.
-				'<img src="/adm/lonMisc/chat.gif" border="0" />'.
-				&mt('Post Discussion').'</a></td></tr></table>';
+	    if ($outputtarget ne 'tex') {
+		$discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
+		    $symb.':::" '.$target.'>'.
+		    '<img src="/adm/lonMisc/chat.gif" border="0" />'.
+		    &mt('Post Discussion').'</a></td></tr></table>';
+	    }
 			}
     }
    return $discussion;

--sakharuk1088012578--