--- loncom/interface/lonfeedback.pm 2010/08/26 09:09:24 1.290.2.3 +++ loncom/interface/lonfeedback.pm 2010/11/19 20:32:38 1.303 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.290.2.3 2010/08/26 09:09:24 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.303 2010/11/19 20:32:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,15 +58,15 @@ sub discussion_open { return 1; } # It was not explicitly open, check if the problem is available. -# If the problem is not available, close the discussion +# If the problem is not available, close the discussion if (defined($status) && - !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' - || $status eq 'OPEN')) { - return 0; + !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER' + || $status eq 'OPEN')) { + return 0; } # The problem is available, but check if the instructor explictly closed discussion if (defined($close) && $close ne '' && $close < time) { - return 0; + return 0; } return 1; } @@ -282,10 +282,6 @@ sub list_discussion { my %anonhash=(); my $anoncnt=0; my $target=''; - unless ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { - $target='target="LONcom"'; - } my $now = time; $discinfo{$visitkey} = $visit; @@ -425,7 +421,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } } else { my $colspan=$maxdepth+1; -#JW $discussion.= &Apache::lonhtmlcommon::scripttag(qq| function verifydelete (caller,symb,idx,newflag,previous,groupparm) { var symbparm = symb+':::'+idx @@ -727,7 +722,7 @@ END $attachnum += @{$currnewattach}; } } - if (&discussion_open($status) && ($outputtarget ne 'tex')) { + if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { if (($group ne '') && ($mode eq 'board')) { if (&check_group_priv($group,'pgd') eq 'ok') { $discussion .= @@ -737,19 +732,30 @@ END $group,$crstype); } } else { - $discussion.= - &postingform_display($mode,$ressymb,$now,$subject, - $comment,$outputtarget,$attachnum, - $currnewattach,$currdelold,'',$crstype); + if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + + $discussion.= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold,'',$crstype); + } else { + $discussion.= ''. + &mt('This discussion is closed.').''; + } } } + if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) { + $discussion.= ''. + &mt('This discussion is closed.').''; + } } elsif ($outputtarget ne 'tex') { $discussion.=''; + $discussion.= &send_message_link($ressymb).''; } return $discussion; } @@ -893,22 +898,22 @@ ENDDISCUSS } $postingform .= "\n"; $postingform .= &generate_attachments_button('',$attachnum,$ressymb, - $now,$currnewattach, - $currdelold,'',$mode, - $blockblog); + $now,$currnewattach, + $currdelold,'',$mode, + $blockblog); if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { $newattachmsg = '
'.$lt{'newa'}.'
'; if (@{$currnewattach} > 1) { - $newattachmsg .= '
    '; - foreach my $item (@{$currnewattach}) { + $newattachmsg .= '
      '; + foreach my $item (@{$currnewattach}) { $item =~ m#.*/([^/]+)$#; $newattachmsg .= '
    1. '.$1.'
    2. '."\n"; - } - $newattachmsg .= '
    '."\n"; - } else { - $$currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
    '."\n"; - } + } + $newattachmsg .= '
'."\n"; + } else { + $$currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
'."\n"; + } } $postingform .= $newattachmsg; $postingform .= &generate_preview_button(); @@ -988,7 +993,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hiddens{$idx}) && (!$seeid)) || (deletions{$idx})) { + unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -1104,11 +1109,11 @@ sub build_posting_display { } } } - if ($seeid) { + if ($seeid) { if ($hiddens{$idx}) { unless ($studenthidden) { $sender.=' '; } } - } else { + } else { if ($screenname) { $sender=''.$screenname.''; } else { @@ -1156,7 +1161,7 @@ sub build_posting_display { } } if ($outputtarget ne 'tex') { - if (&discussion_open($status)) { + if (&discussion_open($status)) { if (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok')) { $sender.=' '.&mt('Reply').''; } } - if ($viewgrades) { + if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); } - if ($$dischash{$readkey}=~/\.$idx\./) { + if ($$dischash{$readkey}=~/\.$idx\./) { $ctlink = ''; } else { $ctlink = ''; @@ -1285,7 +1290,7 @@ sub build_posting_display { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' - '; + '; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' @@ -1765,7 +1770,7 @@ $latexHelp

$lt{'title'}:

-

END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { @@ -2565,10 +2570,6 @@ sub redirect_back { &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }"; - } my $start_page= &Apache::loncommon::start_page('Feedback sent',undef, {'redirect' => [0,$feedurl], @@ -2602,10 +2603,6 @@ sub no_redirect_back { my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { self.window.close(); }"; - } my %body_options = ('only_body' => 1, 'bgcolor' => '#FFFFFF', @@ -2632,7 +2629,7 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl,$symb) = @_; + my ($feedurl,$symb,$group) = @_; my $crscontent = &mt('Question/Comment/Feedback about course content'); my $crspolicy = &mt('Question/Comment/Feedback about course policy'); my $contribdisc = &mt('Contribution to course discussion of resource'); @@ -2681,10 +2678,16 @@ sub screen_header { } if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); - if (!$blocked && &discussion_open(undef,$symb) && - &Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + my $realsymb = $symb; + if ($symb=~/^bulletin___/) { + my $filename=(&Apache::lonnet::decode_symb($symb))[2]; + $filename=~s|^adm/wrapper/||; + $realsymb=&Apache::lonnet::symbread($filename); + } + if (!$blocked && &discussion_open(undef,$realsymb) && + (&Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok')))) { $discussoptions='
'.&mt('NEW'). '
'.&mt('NEW').' 
%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, PRE=>1, DIV=>1, IMG=>1, - M=>1, CHEM=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1, + BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, PRE=>1, DIV=>1, IMG=>1, + M=>1, CHEM=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1, H1=>1, H2=>1, H3=>1, H4=>1, H5=>1, H6=>1, TABLE=>1, TR=>1, TD=>1, TH=>1, TBODY=>1); } @@ -2823,7 +2826,7 @@ sub send_msg { } sub adddiscuss { - my ($symb,$email,$anon,$attachmenturl,$subject)=@_; + my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_; my $status=''; my $realsymb; if ($symb=~/^bulletin___/) { @@ -2832,8 +2835,9 @@ sub adddiscuss { $realsymb=&Apache::lonnet::symbread($filename); } if (&discussion_open(undef,$realsymb) && - &Apache::lonnet::allowed('pch',$env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { + (&Apache::lonnet::allowed('pch',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || + ($group ne '' && &check_group_priv($group,'pgd')))) { my %contrib=('message' => $email, 'sendername' => $env{'user.name'}, @@ -3612,10 +3616,6 @@ sub handler { $r->send_http_header; my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); my %onload; - if ($env{'environment.remote'} ne 'off') { - $onload{'onload'} = - "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }"; - } my $start_page= &Apache::loncommon::start_page('New posts marked as read',undef, @@ -3882,7 +3882,7 @@ ENDREDIR return OK; } } - my $options=&screen_header($feedurl,$symb); + my $options=&screen_header($feedurl,$symb,$group); if ($options) { &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'}); } else { @@ -3942,7 +3942,7 @@ ENDREDIR if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) { $override = 1; } - my $message=&clear_out_html($env{'form.comment'},1); + my $message=&clear_out_html($env{'form.comment'},$override); # Assemble email my ($email,$citations)=&assemble_email($message,$prevattempts, @@ -3964,7 +3964,7 @@ ENDREDIR my $subject = &clear_out_html($env{'form.subject'}); my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, - $subject); + $subject,$group); $numpost++; }