--- loncom/interface/lonfeedback.pm 2004/06/23 17:42:58 1.95 +++ loncom/interface/lonfeedback.pm 2004/09/15 20:29:37 1.99.2.7 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.95 2004/06/23 17:42:58 sakharuk Exp $ +# $Id: lonfeedback.pm,v 1.99.2.7 2004/09/15 20:29:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -115,30 +115,33 @@ sub list_discussion { } # Get discussion display default settings for user - my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'}); - my $discdisplay=$userenv{'discdisplay'}; - if ($discdisplay eq 'unread') { + if ($ENV{'environment.discdisplay'} eq 'unread') { $showonlyunread = 1; } - my $discmarkread=$userenv{'discmarkread'}; - if ($discmarkread eq 'ondisp') { + if ($ENV{'environment.discmarkread'} eq 'ondisp') { $markondisp = 1; } # Override user's default if user specified display setting for this discussion if (defined($dischash{$ondispkey})) { - $markondisp = $dischash{$ondispkey}; + unless ($dischash{$showkey} eq '') { + $markondisp = $dischash{$ondispkey}; + } } if ($markondisp) { $discinfo{$lastkey} = time; } if (defined($dischash{$showkey})) { - $showonlyunread = $dischash{$showkey}; + unless ($dischash{$showkey} eq '') { + $showonlyunread = $dischash{$showkey}; + } } if (defined($dischash{$visitkey})) { - $visit = $dischash{$visitkey}; + unless ($dischash{$showkey} eq '') { + $visit = $dischash{$visitkey}; + } } $visit ++; @@ -223,13 +226,14 @@ sub list_discussion { if ($hidden) { $message=''.$message.''; } - my $screenname=&Apache::loncommon::screenname( - $contrib{$idx.':sendername'}, - $contrib{$idx.':senderdomain'}); - my $plainname=&Apache::loncommon::nickname( - $contrib{$idx.':sendername'}, - $contrib{$idx.':senderdomain'}); - +# my $screenname=&Apache::loncommon::screenname( +# $contrib{$idx.':sendername'}, +# $contrib{$idx.':senderdomain'}); +# my $plainname=&Apache::loncommon::nickname( +# $contrib{$idx.':sendername'}, +# $contrib{$idx.':senderdomain'}); + ($$screenname,$$plainname)=($$contrib{$idx.':screenname'}, + $$contrib{$idx.':plainname'}); my $sender=&mt('Anonymous'); if ((!$contrib{$idx.':anonymous'}) || ($seeid)) { $sender=&Apache::loncommon::aboutmewrapper( @@ -325,54 +329,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 +386,7 @@ sub list_discussion { $discussion .= '&previous='.$prevread; } $discussion .='">'.&mt('Chronological View').'  '.&mt('Mark new posts as read').'  '; @@ -445,12 +445,51 @@ sub list_discussion { $discussionitems[$alldiscussion{$_}]=~s/<\/td>]*)>/$threadinsert<\/td>/; $discussionitems[$alldiscussion{$_}]=~s/]+)>(Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$_}]=~s/(|<\/b>|<\/a>|]+)>)//g; - $discussion.=&Apache::lonxml::xmlparse('','tex',$discussionitems[$alldiscussion{$_}]); + + #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{$_}]); } } } 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) { @@ -517,11 +556,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(< @@ -565,7 +599,9 @@ $htmlheader } if (rec) { - $onsubmit + if (typeof(document.mailform.onsubmit)=='function') { + document.mailform.onsubmit(); + } document.mailform.submit(); } else { alert('Please check a feedback type.'); @@ -605,6 +641,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' }; @@ -617,6 +783,7 @@ sub fail_redirect { Sorry, no recipients ... +
Continue ENDFAILREDIR @@ -626,6 +793,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; @@ -651,6 +823,7 @@ $typestyle
$prevtag
+
Continue ENDREDIR @@ -673,6 +846,7 @@ ENDNOREDIR Sorry, no feedback possible on this resource ... +
Continue ENDNOREDIRTWO @@ -950,7 +1124,7 @@ sub generate_preview_button { +onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" /> ENDPREVIEW } @@ -965,58 +1139,118 @@ 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'} +
+
+
Continue + + +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 @@ -1137,7 +1371,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||; }