--- loncom/interface/lonfeedback.pm 2004/06/28 16:41:08 1.96 +++ loncom/interface/lonfeedback.pm 2004/07/27 14:29:03 1.99.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.96 2004/06/28 16:41:08 albertel Exp $ +# $Id: lonfeedback.pm,v 1.99.2.2 2004/07/27 14:29:03 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -325,54 +325,50 @@ sub list_discussion { my $color = &Apache::loncommon::designparm($function.'.tabbg', $ENV{'user.domain'}); my %lt = &Apache::lonlocal::texthash( - 'cuse' => 'Current settings for this discussion', + 'cuse' => 'Current discussion settings', 'allposts' => 'All posts', 'unread' => 'New posts only', 'ondisp' => 'Once displayed', 'onmark' => 'Once marked read', 'disa' => 'Posts to be displayed', 'npce' => 'Posts cease to be marked "NEW"', - 'chgt' => 'Change to ', + 'chgt' => 'Change', + 'disp' => 'Display', + 'nolo' => 'Not new', ); my $currdisp = $lt{'allposts'}; my $currmark = $lt{'onmark'}; my $dispchange = $lt{'unread'}; my $markchange = $lt{'ondisp'}; - my $displink = '/adm/feedback?onlyunread='.$ressymb; - my $marklink = '/adm/feedback?markondisp='.$ressymb; + my $chglink = '/adm/feedback?modifydisp='.$ressymb; + my $displink = 'onlyunread'; + my $marklink = 'markondisp'; if ($markondisp) { $currmark = $lt{'ondisp'}; $markchange = $lt{'onmark'}; - $marklink = '/adm/feedback?markonread='.$ressymb; - if ($newpostsflag) { - $marklink .= '&previous='.$prevread; - } + $marklink = 'markonread'; } if ($showonlyunread) { $currdisp = $lt{'unread'}; $dispchange = $lt{'allposts'}; - $displink = '/adm/feedback?allposts='.$ressymb; + $displink = 'allposts'; } + + $chglink .= '&changes='.$displink.'_'.$marklink; if ($newpostsflag) { - $displink .= '&previous='.$prevread; + $chglink .= '&previous='.$prevread; } if ($visible) { # Print the discusssion if ($outputtarget ne 'tex') { + my $colspan=$maxdepth+1; $discussion.=''; - my $colspan=$maxdepth+1; - $discussion .= ''. - ' + +
'. - ''. - ''. - ''. - ''. - '
'.$lt{'cuse'}.'    '.$lt{'chgt'}.'
'.$lt{'disa'}.': '.$currdisp.'    '.$dispchange.'
'.$lt{'npce'}.': '.$currmark.'    '.$markchange.'
'. + $discussion .='
'. ''; if ($visible>2) { $discussion.=''; - } + } if ($newpostsflag) { if (!$markondisp) { $discussion .='
'. @@ -386,7 +382,7 @@ sub list_discussion { $discussion .= '&previous='.$prevread; } $discussion .='">'.&mt('Chronological View').'  '.&mt('Mark new posts as read').'  '; @@ -456,7 +452,40 @@ sub list_discussion { } } if ($outputtarget ne 'tex') { - $discussion.='


'; + my $colspan=$maxdepth+1; + $discussion .= < +
+ + + + +
+ + + + +END + if ($newpostsflag) { + $discussion .= + ''; + } else { + $discussion .= + ''; + } + $discussion .= <  + + +
+ $lt{'cuse'}: 1. '.$lt{'disp'}.' - '.$currdisp.'  2. '.$lt{'nolo'}.' - '.$currmark.''.$lt{'disp'}.' - '.$currdisp.' + $lt{'chgt'}?
+
+
+

+END } } if ($discussiononly) { @@ -523,11 +552,6 @@ sub mail_screen { } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); - my $onsubmit=''; - if ((&Apache::lonhtmlcommon::htmlareabrowser()) && - (!&Apache::lonhtmlcommon::htmlareablocked())) { - $onsubmit='document.mailform.onsubmit();'; - } my $send=&mt('Send'); $r->print(< @@ -571,7 +595,9 @@ $htmlheader } if (rec) { - $onsubmit + if (typeof(document.mailform.onsubmit)!='undefined') { + document.mailform.onsubmit(); + } document.mailform.submit(); } else { alert('Please check a feedback type.'); @@ -611,6 +637,136 @@ $r->print(&generate_preview_button(). ''); } +sub print_display_options { + my ($r,$symb,$previous,$dispchg,$markchg,$feedurl) = @_; + # backward compatibility (bulletin boards used to be 'wrapped') + if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { + $feedurl=~s|^/adm/wrapper||; + } + + my $function = &Apache::loncommon::get_users_function(); + my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', + $ENV{'user.domain'}); + my $bodytag=&Apache::loncommon::bodytag('Discussion options', + '',''); + + my %lt = &Apache::lonlocal::texthash( + 'dido' => 'Discussion display options', + 'pref' => 'Display Preference', + 'curr' => 'Current setting ', + 'actn' => 'Action', + '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."', + 'allposts' => 'All posts', + 'unread' => 'New posts only', + 'ondisp' => 'Once displayed', + 'onmark' => 'Once marked as read', + 'disa' => 'Posts displayed?', + 'npmr' => 'New posts cease to be identified as "New"?', + 'chgt' => 'Change to ', + 'mkdf' => 'Set to ', + 'yhni' => 'You have not indicated that you wish to change either of the discussion settings', + 'ywbr' => 'You will be returned to the previous page if you click OK.' + ); + + my $dispchange = $lt{'unread'}; + my $markchange = $lt{'ondisp'}; + my $currdisp = $lt{'allposts'}; + my $currmark = $lt{'onmark'}; + my $discdisp = 'allposts'; + my $discmark = 'onmark'; + + if ($dispchg eq 'allposts') { + $dispchange = $lt{'allposts'}; + $currdisp = $lt{'unread'}; + $discdisp = 'unread'; + } + + if ($markchg eq 'markonread') { + $markchange = $lt{'onmark'}; + $currmark = $lt{'ondisp'}; + $discmark = 'ondisp'; + } + $r->print(< + +$lt{'dido'} + + + +$bodytag +
+$lt{'sdpf'}
$lt{'prca'}
  1. $lt{'whpo'}
  2. $lt{'unwh'}
+
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + +
$lt{'pref'}$lt{'curr'}$lt{'actn'}?
$lt{'disa'}$lt{$discdisp} $lt{'chgt'} "$dispchange"
$lt{'npmr'}$lt{$discmark}$lt{'chgt'} "$markchange"
+
+
+
+
+ + + + +
+
+
+ + +END + return; +} + sub fail_redirect { my ($r,$feedurl) = @_; if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; @@ -632,6 +788,11 @@ sub redirect_back { my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous) = @_; my $prevtag = ''; my $qrystr = ''; + # backward compatibility (bulletin boards used to be 'wrapped') + if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { + $feedurl=~s|^/adm/wrapper||; + } + if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' }; if ($previous > 0) { $qrystr = 'previous='.$previous; @@ -956,7 +1117,7 @@ sub generate_preview_button { +onClick="if (typeof(document.mailform.onsubmit)!='undefined') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" /> ENDPREVIEW } @@ -971,58 +1132,117 @@ sub handler { # --------------------------- Get query string for limited number of parameters - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp']); - - if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) { -# ---------------------- Modify setting for identification of 'NEW' posts in this discussion - - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'}; - my $ressymb = $symb; - my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); - unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { - $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; - } - + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl']); + if ($ENV{'form.navmaps'}) { my %discinfo = (); - my $lastkey = $ressymb.'_lastread'; - my $ondispkey = $ressymb.'_markondisp'; - if ($ENV{'form.markondisp'}) { - $discinfo{$lastkey} = time; - $discinfo{$ondispkey} = 1; - } elsif ($ENV{'form.markonread'}) { - if ( defined($ENV{'previous'}) ) { - $discinfo{$lastkey} = $ENV{'previous'}; + my @resources = (); + if ($ENV{'form.navmaps'} =~ /:/) { + @resources = split/:/,$ENV{'form.navmaps'}; + } else { + @resources = ("$ENV{'form.navmaps'}"); + } + my $numitems = @resources; + my $feedurl = '/adm/navmaps'; + if ($ENV{'form.navurl'}) { + $feedurl .= '?'.$ENV{'form.navurl'}; + } + my %lt = &Apache::lonlocal::texthash( + 'mnpa' => 'Marked "New" posts as read in a total of', + 'robb' => 'resources/bulletin boards.' + ); + foreach (@resources) { +# backward compatibility (bulletin boards used to be 'wrapped') + my $ressymb=$_; + if ($ressymb =~ m/bulletin___\d+___/) { + unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { + $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|; + } } - $discinfo{$ondispkey} = 0; + my $lastkey = $ressymb.'_lastread'; + $discinfo{$lastkey} = time; } &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); - if ($ENV{'form.markondisp'}) { - &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'
','0','0'); - } else { - &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'
','0','0','',$ENV{'form.previous'}); - } + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + $r->print (< + +New posts marked as read + + + + + +$lt{'mnpa'} $numitems $lt{'robb'} +
+
+ + +ENDREDIR return OK; - } elsif (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) { -# ----------------------------------------------------------------- Modify display setting for this discussion + } elsif ($ENV{'form.modifydisp'}) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'}; - my $ressymb = $symb; + my $symb=$ENV{'form.modifydisp'}; my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); - unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { - $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; + my $previous=$ENV{'form.previous'}; + my ($dispchg,$markchg) = split/_/,$ENV{'form.changes'}; + my $feedurl = &Apache::lonnet::clutter($url); + # backward compatibility (bulletin boards used to be 'wrapped') + if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { + $feedurl=~s|^/adm/wrapper||; } - my %discinfo = (); - if ($ENV{'form.allposts'}) { - $discinfo{$ressymb.'_showonlyunread'} = 0; - } elsif ($ENV{'form.onlyunread'}) { - $discinfo{$ressymb.'_showonlyunread'} = 1; + &print_display_options($r,$symb,$previous,$dispchg,$markchg,$feedurl); + return OK; + } elsif (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + my $previous=$ENV{'form.previous'}; + my ($map,$ind,$url); + if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) { +# ---------------------- Modify setting for identification of 'NEW' posts in this discussion + my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'}; + my $ressymb = $symb; + ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); + unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { + $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; + } + my %discinfo = (); + my $lastkey = $ressymb.'_lastread'; + my $ondispkey = $ressymb.'_markondisp'; + if ($ENV{'form.markondisp'}) { + $discinfo{$lastkey} = time; + $discinfo{$ondispkey} = 1; + } elsif ($ENV{'form.markonread'}) { + if ( $previous > 0 ) { + $discinfo{$lastkey} = $previous; + } + $discinfo{$ondispkey} = 0; + } + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + } + if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) { +# ----------------------------------------------------------------- Modify display setting for this discussion + my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'}; + my $ressymb = $symb; + ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); + unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { + $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; + } + my %discinfo = (); + if ($ENV{'form.allposts'}) { + $discinfo{$ressymb.'_showonlyunread'} = 0; + } elsif ($ENV{'form.onlyunread'}) { + $discinfo{$ressymb.'_showonlyunread'} = 1; + } + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + } + if (($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) { + &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'
','0','0','',$previous); + } else { + &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'
','0','0'); } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); - &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'
','0','0','',$ENV{'form.previous'}); return OK; } elsif ($ENV{'form.markread'}) { # ----------------------------------------------------------------- Mark new posts as read @@ -1143,7 +1363,7 @@ sub handler { if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) { unless ($symb) { $goahead=0; } } - # backward compatibility (bulltin boards used to be 'wrapped') + # backward compatibility (bulletin boards used to be 'wrapped') if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { $feedurl=~s|^/adm/wrapper||; }