--- loncom/interface/lonfeedback.pm 2004/07/21 23:57:24 1.101
+++ loncom/interface/lonfeedback.pm 2004/08/10 18:01:25 1.114
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.101 2004/07/21 23:57:24 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.114 2004/08/10 18:01:25 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,8 @@ use Apache::loncommon();
use Apache::lontexconvert();
use Apache::lonlocal; # must not have ()
use Apache::lonhtmlcommon();
+use HTML::LCParser();
+use Apache::lonspeller();
sub discussion_open {
my ($status)=@_;
@@ -63,8 +65,7 @@ sub discussion_visible {
}
sub list_discussion {
- my ($mode,$status,$symb)=@_;
-
+ my ($mode,$status,$symb,$ttarget,$tagstack,$parstack,$parser,$safeeval)=@_;
my $outputtarget=$ENV{'form.grade_target'};
if (not &discussion_visible($status)) { return ''; }
my @bgcols = ("#cccccc","#eeeeee");
@@ -95,12 +96,17 @@ sub list_discussion {
# Get discussion display settings for this discussion
my $lastkey = $ressymb.'_lastread';
my $showkey = $ressymb.'_showonlyunread';
+ my $markkey = $ressymb.'_showonlyunmark',
my $visitkey = $ressymb.'_visit';
my $ondispkey = $ressymb.'_markondisp';
my $userpickkey = $ressymb.'_userpick';
- my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey,$ondispkey,$userpickkey],$ENV{'user.domain'},$ENV{'user.name'});
+ my $toggkey = $ressymb.'_readtoggle';
+ my $readkey = $ressymb.'_read';
+
+ my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'});
my %discinfo = ();
my $showonlyunread = 0;
+ my $showunmark = 0;
my $markondisp = 0;
my $prevread = 0;
my $previous = 0;
@@ -124,7 +130,7 @@ sub list_discussion {
}
}
-# Get information about students and non-stundents in course for filtering display of posts
+# Get information about students and non-students in course for filtering display of posts
my %roleshash = ();
my %roleinfo = ();
if ($rolefilter) {
@@ -175,6 +181,10 @@ sub list_discussion {
$showonlyunread = $dischash{$showkey};
}
+ if (defined($dischash{$markkey})) {
+ $showunmark = $dischash{$markkey};
+ }
+
if (defined($dischash{$visitkey})) {
$visit = $dischash{$visitkey};
}
@@ -204,7 +214,7 @@ sub list_discussion {
$ENV{'environment.remote'} eq 'off' ) {
$target='target="LONcom"';
}
-
+
my $now = time;
$discinfo{$visitkey} = $visit;
@@ -222,8 +232,10 @@ sub list_discussion {
$newpostsflag = 1;
}
my $hidden=($contrib{'hidden'}=~/\.$idx\./);
+ my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./);
my $deleted=($contrib{'deleted'}=~/\.$idx\./);
my $origindex='0.';
+ my $numoldver=0;
if ($contrib{$idx.':replyto'}) {
if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($sortposts eq 'thread')) {
# this is a follow-up message
@@ -247,26 +259,55 @@ sub list_discussion {
}
unless ((($hidden) && (!$seeid)) || ($deleted)) {
$visible++;
- my $message=$contrib{$idx.':message'};
+ if ($contrib{$idx.':history'}) {
+ if ($contrib{$idx.':history'} =~ /:/) {
+ my @oldversions = split/:/,$contrib{$idx.':history'};
+ $numoldver = @oldversions;
+ } else {
+ $numoldver = 1;
+ }
+ }
+ my ($message,$subject);
+ if ($idx > 0) {
+ if ($contrib{$idx.':message'} =~ /^ '.&mt('Attachment').
- ': '.
- $fname.'
/g;
$message=&Apache::lontexconvert::msgtexconverted($message);
- my $subject=$contrib{$idx.':subject'};
+ if ($idx > 0) {
+ if ($contrib{$idx.':subject'} =~ /^
Deleted by poster (student).';
+ }
}
my $screenname=&Apache::loncommon::screenname(
$contrib{$idx.':sendername'},
@@ -329,14 +370,29 @@ sub list_discussion {
} else {
@{$namesort{$lastname}{$firstname}} = ("$idx");
}
- if ($seeid) {
- if ($hidden) {
- $sender.=' '.&mt('Make Visible').'';
+ $sender .= '" '.$target.'>'.&mt('Edit').''; unless ($seeid) {
+ $sender.=" ';
+ }
+ }
+ }
+ if ($seeid) {
+ if ($hidden) {
+ unless ($studenthidden) {
+ $sender.=' '.&mt('Make Visible').'';
+ }
} else {
$sender.=' '.&mt('Hide').'';
}
$sender.=' ';
+ } else {
+ $ctlink = ''.&mt('Mark read').'? ';
+ }
#figure out at what position this needs to print
my $thisindex=$idx;
if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($sortposts eq 'thread')) {
@@ -402,7 +464,10 @@ sub list_discussion {
my $spansize = 2;
if ($showonlyunread && $prevread > $posttime) {
$notshown{$idx} = 1;
+ } elsif ($showunmark && $dischash{$readkey}=~/\.$idx\./) {
+ $notshown{$idx} = 1;
} else {
+# apply filters
my $uname = $contrib{$idx.':sendername'};
my $udom = $contrib{$idx.':senderdomain'};
my $poster = $uname.':'.$udom;
@@ -464,8 +529,29 @@ sub list_discussion {
$discussionitems[$idx] .= ' '.
''.$subject.' '.
$sender.' '.$vgrlink.' ('.
- localtime($posttime).') '.
- ''.$message.'
'.$message.''; + if ($contrib{$idx.':history'}) { + my @postversions = (); + $discussionitems[$idx] .= '
-Attachment (128 KB max size): -
- + +'.&Apache::lontexconvert::msgtexconverted($message).''; - if ($idx > 0) { - $subject = 'Re: '.$contrib{$idx.':subject'}; + if ($contrib{$idx.':history'}) { + if ($contrib{$idx.':history'} =~ /:/) { + my @oldversions = split/:/,$contrib{$idx.':history'}; + $numoldver = @oldversions; + } else { + $numoldver = 1; + } + } + if ($ENV{'form.replydisc'}) { + if ($contrib{$idx.':history'}) { + if ($contrib{$idx.':history'} =~ /:/) { + my @oldversions = split/:/,$contrib{$idx.':history'}; + $numoldver = @oldversions; + } else { + $numoldver = 1; + } + } + my $message; + if ($idx > 0) { + if ($contrib{$idx.':message'} =~ /^
'.&Apache::lontexconvert::msgtexconverted($message).''; + if ($idx > 0) { + if ($contrib{$idx.':subject'} =~ /^
-
+END
+ if ( ($ENV{'form.editdisc'}) || ($ENV{'form.replydisc'}) ) {
+ if ($ENV{'form.origpage'}) {
+ foreach (@currnewattach) {
+ $r->print(''."\n");
+ }
+ foreach (@currdelold) {
+ $r->print(''."\n");
+ }
+ }
+ if ($ENV{'form.editdisc'}) {
+ if ($attachmenturls) {
+ &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold);
+ $attachnum = scalar(keys %currattach);
+ foreach (keys %currattach) {
+ $r->print(''."\n");
+ }
+ }
+ }
+ } else {
+ $r->print(<