--- loncom/interface/lonfeedback.pm 2004/06/01 21:40:57 1.85 +++ 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.85 2004/06/01 21:40:57 www Exp $ +# $Id: lonfeedback.pm,v 1.96 2004/06/28 16:41:08 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; } @@ -247,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; @@ -387,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; @@ -458,7 +522,12 @@ sub mail_screen { } } my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(); - my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); + my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders(); + my $onsubmit=''; + if ((&Apache::lonhtmlcommon::htmlareabrowser()) && + (!&Apache::lonhtmlcommon::htmlareablocked())) { + $onsubmit='document.mailform.onsubmit();'; + } my $send=&mt('Send'); $r->print(< @@ -502,6 +571,7 @@ $htmlheader } if (rec) { + $onsubmit document.mailform.submit(); } else { alert('Please check a feedback type.'); @@ -525,7 +595,7 @@ $quote $latexHelp Title:

-

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


      • - #
        + #

        + # my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1, - M=>1); + M=>1, SUB=>1, SUP=>1, SPAN=>1, + H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge; @@ -814,7 +888,8 @@ sub send_msg { sub adddiscuss { my ($symb,$email,$anon,$attachmenturl,$subject)=@_; my $status=''; - if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}. + if (&discussion_open() && + &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}. ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { my %contrib=('message' => $email, @@ -881,7 +956,7 @@ sub generate_preview_button { +onClick="document.mailform.onsubmit();this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" /> ENDPREVIEW }