--- loncom/interface/lonfeedback.pm 2010/01/25 04:34:37 1.273.4.7 +++ loncom/interface/lonfeedback.pm 2010/09/21 04:58:17 1.273.4.11 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.273.4.7 2010/01/25 04:34:37 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.273.4.11 2010/09/21 04:58:17 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,13 +48,22 @@ use LONCAPA; sub discussion_open { my ($status,$symb)=@_; +# Advanced roles can always discuss if ($env{'request.role.adv'}) { return 1; } +# Get discussion closing date + my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); +# If it is defined and in the future, the instructor wants this discussion to be open + if (defined($close) && $close ne '' && $close > time) { + return 1; + } +# It was not explicitly open, check if the problem is available. +# 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; } - my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); +# The problem is available, but check if the instructor explictly closed discussion if (defined($close) && $close ne '' && $close < time) { return 0; } @@ -741,13 +750,21 @@ END $env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { if ($outputtarget ne 'tex') { - $discussion.= &send_feedback_link($ressymb,$target); + $discussion.= &send_feedback_link($ressymb,$target); + if ($env{'request.role.adv'}) { + my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb); + if (defined($close) && $close ne '' && $close < time) { + $discussion .= ' '.&mt('(Closed for [_1] roles)', + &Apache::lonnet::plaintext('st',$crstype)); + } + } + } + } else { + if ($outputtarget ne 'tex') { + $discussion.= ''.&mt('This discussion is closed.').''; } - } - if ($outputtarget ne 'tex') { - $discussion.= &send_message_link($ressymb); } - $discussion.=''; + $discussion.=&send_message_link($ressymb).''; } return $discussion; } @@ -1172,7 +1189,7 @@ sub build_posting_display { $$imsitems{$idx}{'attach'}=$attachtxt{$numoldver}; $$imsitems{$idx}{'timestamp'}=$contrib{$idx.':timestamp'}; $$imsitems{$idx}{'sender'}=$plainname.' ('. - $contrib{$idx.':sendername'}.' at '. + $contrib{$idx.':sendername'}.':'. $contrib{$idx.':senderdomain'}.')'; $$imsitems{$idx}{'isanonymous'}='false'; if ($contrib{$idx.':anonymous'}) { @@ -1369,7 +1386,7 @@ sub get_post_contents { $$plainname, $$contrib{$idx.':sendername'}, $$contrib{$idx.':senderdomain'}).' ('. - $$contrib{$idx.':sendername'}.' at '. + $$contrib{$idx.':sendername'}.':'. $$contrib{$idx.':senderdomain'}.')'; my $attachmenturls = $$contrib{$idx.':attachmenturl'}; my @postversions = (); @@ -2625,7 +2642,13 @@ 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) && + 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'}:''))) {