--- loncom/interface/lonfeedback.pm 2004/06/01 21:40:57 1.85 +++ loncom/interface/lonfeedback.pm 2004/09/13 18:20:38 1.99.2.6 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.85 2004/06/01 21:40:57 www Exp $ +# $Id: lonfeedback.pm,v 1.99.2.6 2004/09/13 18:20:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,16 +34,39 @@ use Apache::Constants qw(:common); use Apache::lonmsg(); use Apache::loncommon(); use Apache::lontexconvert(); -use Apache::lonlocal; +use Apache::lonlocal; # must not have () +use Apache::lonhtmlcommon(); -sub list_discussion { - my ($mode,$status,$symb)=@_; -# &Apache::lonnet::logthis("status is $status"); - if (!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' +sub discussion_open { + my ($status)=@_; + if (defined($status) && + !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'OPEN')) { - return ''; + return 0; + } + my $close=&Apache::lonnet::EXT('resource.0.discussend'); + if (defined($close) && $close ne '' && $close < time) { + return 0; + } + return 1; +} + +sub discussion_visible { + my ($status)=@_; + if (not &discussion_open($status)) { + my $hidden=&Apache::lonnet::EXT('resource.0.discusshide'); + if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden)) { + return 0; + } } + return 1; +} +sub list_discussion { + my ($mode,$status,$symb)=@_; + + my $outputtarget=$ENV{'form.grade_target'}; + if (not &discussion_visible($status)) { return ''; } my @bgcols = ("#cccccc","#eeeeee"); my $discussiononly=0; if ($mode eq 'board') { $discussiononly=1; } @@ -104,18 +127,24 @@ sub list_discussion { # 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 ++; @@ -247,7 +276,8 @@ sub list_discussion { $sender=''.$screenname.''; } } - if (&Apache::lonnet::allowed('pch', + if (&discussion_open($status) && + &Apache::lonnet::allowed('pch', $ENV{'request.course.id'}. ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { $sender.=' '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 - $discussion.=''; - my $colspan=$maxdepth+1; - $discussion .= ''. - ''; - + if ($outputtarget ne 'tex') { + my $colspan=$maxdepth+1; + $discussion.='
'. - ''. - ''. - ''. - ''. - '
'.$lt{'cuse'}.'    '.$lt{'chgt'}.'
'.$lt{'disa'}.': '.$currdisp.'    '.$dispchange.'
'.$lt{'npce'}.': '.$currmark.'    '.$markchange.'
'. - ''; - if ($visible>2) { - $discussion.=''; - } - if ($newpostsflag) { - if (!$markondisp) { - $discussion .=''; - } - } else { - $discussion .= ''; - } - $discussion .= '
'. - ''.&mt('Threaded View').'  '. - ''.&mt('Chronological View').'  '.&mt('Mark new posts as read').'  '; - } else { - $discussion .= '  
'; + $discussion .=''; + } else { + $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.'}'; + } my $numhidden = keys %notshown; if ($numhidden > 0) { my $colspan = $maxdepth+1; @@ -387,18 +420,79 @@ sub list_discussion { } foreach (sort { $a <=> $b } keys %alldiscussion) { unless ($notshown{$alldiscussion{$_}} eq '1') { - $discussion.="\n"; + if ($outputtarget ne 'tex') { + $discussion.="\n"; + } else { + $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'; + } my $thisdepth=$depth[$alldiscussion{$_}]; - for (1..$thisdepth) { - $discussion.=''; - } + if ($outputtarget ne 'tex') { + for (1..$thisdepth) { + $discussion.=''; + } + } my $colspan=$maxdepth-$thisdepth+1; - $discussion.=''; + } else { + #cleanup block + $discussionitems[$alldiscussion{$_}]=~s/]*)>/
'. + ''; + if ($visible>2) { + $discussion.=''; + } + if ($newpostsflag) { + if (!$markondisp) { + $discussion .=''; + } + } else { + $discussion .= ''; + } + $discussion .= '
'. + ''.&mt('Threaded View').'  '. + ''.&mt('Chronological View').'  '.&mt('Mark new posts as read').'  '; + } else { + $discussion .= '  
      '. + if ($outputtarget ne 'tex') { + $discussion.=''. $discussionitems[$alldiscussion{$_}]. '
/; + $discussionitems[$alldiscussion{$_}]=~s/]*)>]*)>/
/; + my $threadinsert=''; + if ($thisdepth > 0) { + $threadinsert='
Reply: '.$thisdepth.''; + } + $discussionitems[$alldiscussion{$_}]=~s/<\/td>]*)>/$threadinsert<\/td>
/; + $discussionitems[$alldiscussion{$_}]=~s/]+)>(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{$_}]); + } } } - $discussion.='


'; + if ($outputtarget ne 'tex') { + 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) { $discussion.=(<Note: in anonymous discussion, your name is visible only to course faculty
Title: 

- +

Attachment (128 KB max size):

ENDDISCUSS - $discussion.=&generate_preview_button(); + if ($outputtarget ne 'tex') { + $discussion.=&generate_preview_button(); + } } else { - if (&Apache::lonnet::allowed('pch', + if (&discussion_open($status) && + &Apache::lonnet::allowed('pch', $ENV{'request.course.id'}. ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { - $discussion.='
'. - ''. - &mt('Post Discussion').'
'; + if ($outputtarget ne 'tex') { + $discussion.='
'. + ''. + &mt('Post Discussion').'
'; + } } } return $discussion; @@ -458,7 +557,7 @@ sub mail_screen { } } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); - my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); + my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); my $send=&mt('Send'); $r->print(< @@ -502,6 +601,9 @@ $htmlheader } if (rec) { + if (typeof(document.mailform.onsubmit)=='function') { + document.mailform.onsubmit(); + } document.mailform.submit(); } else { alert('Please check a feedback type.'); @@ -525,7 +627,7 @@ $quote $latexHelp Title:

-

Attachment (128 KB max size): @@ -537,10 +639,140 @@ Attachment (128 KB max size): ENDDOCUMENT $r->print(&generate_preview_button(). -&Apache::lonhtmlcommon::htmlareaactive(). +&Apache::lonhtmlcommon::htmlareaselectactive('comment'). ''); } +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' }; @@ -553,6 +785,7 @@ sub fail_redirect { Sorry, no recipients ... +
Continue ENDFAILREDIR @@ -562,6 +795,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; @@ -587,6 +825,7 @@ $typestyle
$prevtag
+
Continue ENDREDIR @@ -609,6 +848,7 @@ ENDNOREDIR Sorry, no feedback possible on this resource ... +
Continue ENDNOREDIRTWO @@ -641,7 +881,8 @@ sub screen_header { } } if ($ENV{'request.course.id'}) { - if (&Apache::lonnet::allowed('pch', + if (&discussion_open() && + &Apache::lonnet::allowed('pch', $ENV{'request.course.id'}. ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { $discussoptions='