--- loncom/interface/lonfeedback.pm 2004/07/29 22:42:25 1.110 +++ loncom/interface/lonfeedback.pm 2004/08/03 21:29:32 1.112 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.110 2004/07/29 22:42:25 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.112 2004/08/03 21:29:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); +use HTML::LCParser(); use Apache::lonspeller(); sub discussion_open { @@ -65,7 +66,6 @@ sub discussion_visible { sub list_discussion { my ($mode,$status,$symb)=@_; - my $outputtarget=$ENV{'form.grade_target'}; if (not &discussion_visible($status)) { return ''; } my @bgcols = ("#cccccc","#eeeeee"); @@ -96,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; @@ -176,6 +181,10 @@ sub list_discussion { $showonlyunread = $dischash{$showkey}; } + if (defined($dischash{$markkey})) { + $showunmark = $dischash{$markkey}; + } + if (defined($dischash{$visitkey})) { $visit = $dischash{$visitkey}; } @@ -205,7 +214,7 @@ sub list_discussion { $ENV{'environment.remote'} eq 'off' ) { $target='target="LONcom"'; } - + my $now = time; $discinfo{$visitkey} = $visit; @@ -260,8 +269,10 @@ sub list_discussion { } my ($message,$subject); if ($idx > 0) { - if ($contrib{$idx.':message'} =~ /.*::::\Q$numoldver\E::::(.+?)$/si) { - $message = $1; + if ($contrib{$idx.':message'} =~ /^/) { + my %versions = (); + &get_post_versions(\%versions,$contrib{$idx.':message'},$numoldver); + $message = &HTML::Entities::decode($versions{$numoldver}); } else { $message = $contrib{$idx.':message'}; } @@ -272,8 +283,10 @@ sub list_discussion { $message=~s/\n/\
/g; $message=&Apache::lontexconvert::msgtexconverted($message); if ($idx > 0) { - if ($contrib{$idx.':subject'} =~ /.*::::\Q$numoldver\E::::(.+?)$/si) { - $subject = $1; + if ($contrib{$idx.':subject'} =~ /^ '; + } 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')) { @@ -445,6 +464,8 @@ 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'}; @@ -508,8 +529,12 @@ sub list_discussion { $discussionitems[$idx] .= '  '. ''.$subject.'  '. $sender.' '.$vgrlink.' ('. - &Apache::lonlocal::locallocaltime($posttime).')'. - '
'.$message.'

'; + &Apache::lonlocal::locallocaltime($posttime).')'; + if ($dischash{$toggkey}) { + $discussionitems[$idx].='  '. + $ctlink.''; + } + $discussionitems[$idx].= '
'.$message.'

'; if ($contrib{$idx.':history'}) { my @postversions = (); $discussionitems[$idx] .= '
'.&mt('This post has been edited by the author.'); @@ -542,22 +567,31 @@ sub list_discussion { 'cuse' => 'Current discussion settings', 'allposts' => 'All posts', 'unread' => 'New posts only', + 'unmark' => 'Unread only', 'ondisp' => 'Once displayed', - 'onmark' => 'Once marked read', + 'onmark' => 'Once marked not NEW', + 'toggoff' => 'Off', + 'toggon' => 'On', 'disa' => 'Posts to be displayed', 'npce' => 'Posts cease to be marked "NEW"', + 'epcb' => 'Each post can be toggled read/unread', 'chgt' => 'Change', 'disp' => 'Display', 'nolo' => 'Not new', + 'togg' => 'Toggle read/unread', ); my $currdisp = $lt{'allposts'}; my $currmark = $lt{'onmark'}; + my $currtogg = $lt{'toggoff'}; my $dispchange = $lt{'unread'}; my $markchange = $lt{'ondisp'}; + my $toggchange = $lt{'toggon'}; my $chglink = '/adm/feedback?modifydisp='.$ressymb; - my $displink = 'onlyunread'; + my $displinkA = 'onlyunread'; + my $displinkB = 'onlyunmark'; my $marklink = 'markondisp'; + my $togglink = 'toggon'; if ($markondisp) { $currmark = $lt{'ondisp'}; @@ -568,10 +602,24 @@ sub list_discussion { if ($showonlyunread) { $currdisp = $lt{'unread'}; $dispchange = $lt{'allposts'}; - $displink = 'allposts'; + $displinkA = 'allposts'; + } + + if ($showunmark) { + $currdisp = $lt{'unmark'}; + $dispchange = $lt{'unmark'}; + $displinkA='allposts'; + $displinkB='onlyunread'; + $showonlyunread = 0; } + + if ($dischash{$toggkey}) { + $currtogg = $lt{'toggon'}; + $toggchange = $lt{'toggoff'}; + $togglink = 'toggoff'; + } - $chglink .= '&changes='.$displink.'_'.$marklink; + $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; if ($newpostsflag) { $chglink .= '&previous='.$prevread; @@ -595,7 +643,7 @@ sub list_discussion { } |; - $discussion.=''; + $discussion.='
'; $discussion .='
'. ''; if ($visible>2) { @@ -625,7 +673,7 @@ sub list_discussion { $discussion .= '">'.&mt('Export').'?  '; if ($newpostsflag) { if (!$markondisp) { - $discussion .=''; } @@ -649,8 +697,13 @@ sub list_discussion { $discussion .= '&previous='.$prevread; } $discussion .= '">'.&mt('Show all posts').' '.&mt('to display').' '. - $numhidden.' '.&mt('previously viewed posts'). - '
'; + $numhidden.' '; + if ($showunmark) { + $discussion .= &mt('posts previously marked read'); + } else { + $discussion .= &mt('previously viewed posts'); + } + $discussion .= '
'; } # Choose sort mechanism @@ -723,7 +776,7 @@ sub list_discussion { } if ($outputtarget ne 'tex') { my $colspan=$maxdepth+1; - $discussion .= < +END + if ($dischash{$toggkey}) { + my $storebutton = &mt('Store read/unread changes'); + $discussion.=''; + } + $discussion .= (<
'.&mt('Mark new posts as read').'  '; + $discussion .=''.&mt('Mark NEW posts no longer new').'  '; } else { $discussion .= ' 
@@ -734,27 +787,47 @@ sub list_discussion { + '; + '1. '.$lt{'disp'}.' - '.$currdisp.'  2. '.$lt{'nolo'}.' - '.$currmark.''; + if ($dischash{$toggkey}) { + $discussion .= '  3. '.$lt{'togg'}.' - '.$currtogg.''; + } } else { - $discussion .= - ''; + if ($dischash{$toggkey}) { + $discussion .= '1. '.$lt{'disp'}.' - '.$currdisp.' 2. '.$lt{'togg'}.' - '.$currtogg.''; + } else { + $discussion .= + $lt{'disp'}.' - '.$currdisp.''; + } } $discussion .= < + $lt{'chgt'}? +
$lt{'cuse'}:   END if ($newpostsflag) { $discussion .= - '1. '.$lt{'disp'}.' - '.$currdisp.'  2. '.$lt{'nolo'}.' - '.$currmark.''.$lt{'disp'}.' - '.$currdisp.'  - $lt{'chgt'}?
'. + ''."\n". + ''."\n". + '
-

+

END } } @@ -898,6 +971,14 @@ END $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { + 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'} =~ /:/) { @@ -909,8 +990,10 @@ END } my $message; if ($idx > 0) { - if ($contrib{$idx.':message'} =~ /::::\Q$numoldver\E::::(.+?)$/si) { - $message = $1; + if ($contrib{$idx.':message'} =~ /^/g; $quote='
'.&Apache::lontexconvert::msgtexconverted($message).'
'; if ($idx > 0) { - if ($contrib{$idx.':subject'} =~ /::::\Q$numoldver\E::::(.+?)$/si) { - $subject = $1; + if ($contrib{$idx.':subject'} =~ /^&"'); } else { $attachmenturls = $contrib{$idx.':attachmenturl'}; - if ($contrib{$idx.':message'} =~ /.*::::(\d+)::::(.*?)$/si) { - $numoldver = $1; - $comment = $2; + if ($contrib{$idx.':message'} =~ /^/) { + my %versions = (); + &get_post_versions(\%versions,$contrib{$idx.':message'},$numoldver); + $comment = $versions{$numoldver}; } else { - $comment = $contrib{$idx.':message'}; + $comment = &HTML::Entities::encode($contrib{$idx.':message'},'<>&"'); } - $comment = &HTML::Entities::encode($comment,'<>&"'); - if ($contrib{$idx.':subject'} =~ /.*::::\d+::::(.+?)$/si) { - $subject = $1; + if ($contrib{$idx.':subject'} =~ //) { + my %versions = (); + &get_post_versions(\%versions,$contrib{$idx.':subject'},$numoldver); + $subject = $versions{$numoldver}; } else { - $subject = $contrib{$idx.':subject'}; + $subject = &HTML::Entities::encode($contrib{$idx.':subject'},'<>&"'); } - $subject = &HTML::Entities::encode($subject,'<>&"'); if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } @@ -1137,7 +1223,7 @@ END } sub print_display_options { - my ($r,$symb,$previous,$dispchg,$markchg,$feedurl) = @_; + my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_; # backward compatibility (bulletin boards used to be 'wrapped') if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { $feedurl=~s|^/adm/wrapper||; @@ -1157,54 +1243,116 @@ sub print_display_options { 'deff' => 'Default for all discussions', 'prca' => 'Preferences can be set for this discussion that determine ....', 'whpo' => 'Which posts are displayed when you display this bulletin board or resource, and', - 'unwh' => 'Under what circumstances posts are identfied as "New."', + 'unwh' => 'Under what circumstances posts are identified as "NEW", and', + 'wipa' => 'Whether individual posts can be marked as read/unread', 'allposts' => 'All posts', 'unread' => 'New posts only', + 'unmark' => 'Posts not marked read', 'ondisp' => 'Once displayed', - 'onmark' => 'Once marked as read', + 'onmark' => 'Once marked not NEW ', + 'toggon' => 'Shown', + 'toggoff' => 'Not shown', 'disa' => 'Posts displayed?', - 'npmr' => 'New posts cease to be identified as "New"?', + 'npmr' => 'New posts cease to be identified as "NEW"?', + 'dotm' => 'Option to mark each post as read/unread?', 'chgt' => 'Change to ', 'mkdf' => 'Set to ', - 'yhni' => 'You have not indicated that you wish to change either of the discussion settings', + 'yhni' => 'You have not indicated that you wish to change any of the discussion settings', 'ywbr' => 'You will be returned to the previous page if you click OK.' ); - my $dispchange = $lt{'unread'}; + my $dispchangeA = $lt{'unread'}; + my $dispchangeB = $lt{'unmark'}; my $markchange = $lt{'ondisp'}; + my $toggchange = $lt{'toggon'}; my $currdisp = $lt{'allposts'}; my $currmark = $lt{'onmark'}; my $discdisp = 'allposts'; my $discmark = 'onmark'; + my $currtogg = $lt{'toggoff'}; + my $disctogg = 'toggoff'; - if ($dispchg eq 'allposts') { - $dispchange = $lt{'allposts'}; + if ($dispchgA eq 'allposts') { + $dispchangeA = $lt{'allposts'}; $currdisp = $lt{'unread'}; $discdisp = 'unread'; } - + if ($markchg eq 'markonread') { $markchange = $lt{'onmark'}; $currmark = $lt{'ondisp'}; $discmark = 'ondisp'; } + + if ($dispchgB eq 'onlyunread') { + $dispchangeB = $lt{'unread'}; + $currdisp = $lt{'unmark'}; + $discdisp = 'unmark'; + } + if ($toggchg eq 'toggoff') { + $toggchange = $lt{'toggoff'}; + $currtogg = $lt{'toggon'}; + $disctogg = 'toggon'; + } $r->print(< $lt{'dido'}