--- loncom/interface/lonfeedback.pm 2004/06/03 20:06:15 1.89 +++ loncom/interface/lonfeedback.pm 2004/06/28 16:41:08 1.96 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.89 2004/06/03 20:06:15 albertel Exp $ +# $Id: lonfeedback.pm,v 1.96 2004/06/28 16:41:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,18 +37,36 @@ use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); -sub list_discussion { - my ($mode,$status,$symb)=@_; - - 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 '' + 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; } @@ -252,7 +270,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.=' '; - 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 .= '  
'; - + if ($outputtarget ne 'tex') { + $discussion.=''; + my $colspan=$maxdepth+1; + $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; @@ -392,18 +418,46 @@ 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/]*)>/
'. + ''. + ''. + ''. + ''. + '
'.$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 .= '  
      '. + 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') { + $discussion.='

'; + } } 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; @@ -464,6 +523,11 @@ 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(< @@ -507,7 +571,7 @@ $htmlheader } if (rec) { - document.mailform.onsubmit(); + $onsubmit document.mailform.submit(); } else { alert('Please check a feedback type.'); @@ -531,7 +595,7 @@ $quote $latexHelp Title:

-

Attachment (128 KB max size): @@ -543,7 +607,7 @@ Attachment (128 KB max size): ENDDOCUMENT $r->print(&generate_preview_button(). -&Apache::lonhtmlcommon::htmlareaactive(). +&Apache::lonhtmlcommon::htmlareaselectactive('comment'). ''); } @@ -647,7 +711,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=' $email,