--- loncom/interface/lonfeedback.pm 2004/07/28 18:50:26 1.108 +++ 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.108 2004/07/28 18:50:26 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,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 { @@ -64,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"); @@ -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,11 +529,19 @@ sub list_discussion { $discussionitems[$idx] .= '  '. ''.$subject.'  '. $sender.' '.$vgrlink.' ('. - localtime($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.').'
'.&mt('Earlier version(s) were posted on: '); + $discussionitems[$idx] .= '
'.&mt('This post has been edited by the author.'); + if ($seeid) { + $discussionitems[$idx] .= '  '.&mt('Display all versions').''; + } + $discussionitems[$idx].='
'.&mt('Earlier version(s) were posted on: '); if ($contrib{$idx.':history'} =~ m/:/) { @postversions = split/:/,$contrib{$idx.':history'}; } else { @@ -522,7 +551,6 @@ sub list_discussion { my $version = $i+1; $discussionitems[$idx] .= ''.$version.'. - '.&Apache::lonlocal::locallocaltime($postversions[$i]).' '; } - $discussionitems[$idx] .= '
'; } } } @@ -539,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'}; @@ -565,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; @@ -592,7 +643,7 @@ sub list_discussion { } |; - $discussion.=''; + $discussion.='
'; $discussion .=''; } else { - $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. + $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.'}'; + '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}'; } my $numhidden = keys %notshown; if ($numhidden > 0) { @@ -646,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 @@ -683,8 +739,6 @@ sub list_discussion { unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) { if ($outputtarget ne 'tex') { $discussion.="\n"; - } else { - $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'; } my $thisdepth=$depth[$alldiscussion{$_}]; if ($outputtarget ne 'tex') { @@ -708,19 +762,18 @@ sub list_discussion { $discussionitems[$alldiscussion{$_}]=~s/<\/td>]*)>/$threadinsert<\/td> +END + if ($dischash{$toggkey}) { + my $storebutton = &mt('Store read/unread changes'); + $discussion.=''; + } + $discussion .= (<
'. ''; if ($visible>2) { @@ -622,7 +673,7 @@ sub list_discussion { $discussion .= '">'.&mt('Export').'?  '; if ($newpostsflag) { if (!$markondisp) { - $discussion .=''; } @@ -631,11 +682,11 @@ sub list_discussion { } $discussion .= '
'.&mt('Mark new posts as read').'  '; + $discussion .=''.&mt('Mark NEW posts no longer new').'  '; } else { $discussion .= ' 
/; $discussionitems[$alldiscussion{$_}]=~s/]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$_}]=~s/(|<\/b>|<\/a>|]+)>)//g; - - #FIXME xmlparse can't be safely called from inside xmlparse - # due to the global variables that are use, the safe - # space etc. I expect this has unforseen issues that - # need resolving. - - $discussion.=&Apache::lonxml::xmlparse('','tex',$discussionitems[$alldiscussion{$_}]); + + $discussionitems[$alldiscussion{$_}]='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.$discussionitems[$alldiscussion{$_}]; + if ($_ eq $showposts[-1]) { + $discussionitems[$alldiscussion{$_}].='\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}'; + } + $discussion.=$discussionitems[$alldiscussion{$_}]; } } } if ($outputtarget ne 'tex') { my $colspan=$maxdepth+1; - $discussion .= < @@ -731,29 +784,49 @@ 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 - } + } } if ($discussiononly) { my $now = time; @@ -825,7 +898,7 @@ ENDDISCUSS } } } - return $discussion; + return $discussion; } sub mail_screen { @@ -849,7 +922,7 @@ sub mail_screen { my @currnewattach = (); my @currdelold = (); my @keepold = (); - my @attachments = (); + my %attachments = (); my %currattach = (); my $attachnum = 0; my $anonchk = (< 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'}; } @@ -1074,7 +1160,7 @@ END } if ($ENV{'form.editdisc'}) { if ($attachmenturls) { - &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\@attachments,\%currattach,\@currdelold); + &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold); $attachnum = scalar(keys %currattach); foreach (keys %currattach) { $r->print(''."\n"); @@ -1134,7 +1220,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||; @@ -1154,54 +1240,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'}