--- loncom/interface/lonfeedback.pm 2010/12/24 23:18:57 1.290.2.7 +++ loncom/interface/lonfeedback.pm 2010/03/10 21:25:50 1.291 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.290.2.7 2010/12/24 23:18:57 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.291 2010/03/10 21:25:50 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,24 +49,15 @@ 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; + !($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 + my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb); if (defined($close) && $close ne '' && $close < time) { - return 0; + return 0; } return 1; } @@ -282,10 +273,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; @@ -326,7 +313,6 @@ sub list_discussion { 'dpwn' => 'Deleted posts will no longer be visible to you and other students', 'bwco' => 'but will continue to be visible to your instructor', 'depo' => 'Deleted posts will no longer be visible to you or anyone else.', - 'discussions' => 'DISCUSSIONS' ); my $currdisp = $lt{'allposts'}; @@ -378,7 +364,8 @@ sub list_discussion { # Print the discusssion if ($outputtarget eq 'tex') { $discussion.='{\tiny \vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'. - '\textbf{'.$lt{'discussions'}.'}\makebox[2 cm][b]{\hrulefill}\vskip 0 mm'. + '\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.'}}'; } elsif ($outputtarget eq 'export') { @@ -523,6 +510,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $threadinsert='
Reply: '.$thisdepth.''; } $discussionitems[$alldiscussion{$post}]=~s/<\/td>]*)>/$threadinsert<\/td>/; + $discussionitems[$alldiscussion{$post}]=~s/]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$post}]=~s/(|<\/b>|<\/a>|]+)>)//g; $discussionitems[$alldiscussion{$post}]='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.$discussionitems[$alldiscussion{$post}]; @@ -727,10 +715,9 @@ END $attachnum += @{$currnewattach}; } } - if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { - if (($group ne '') && ($mode eq 'board')) { - if ((&check_group_priv($group,'pgd') eq 'ok') && - ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) { + if (&discussion_open($status)) { + if (($group ne '') && ($mode eq 'board')) { + if (&check_group_priv($group,'pgd') eq 'ok') { $discussion .= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, @@ -738,41 +725,26 @@ END $group,$crstype); } } else { - 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.').''; - } + $discussion.= + &postingform_display($mode,$ressymb,$now,$subject, + $comment,$outputtarget,$attachnum, + $currnewattach,$currdelold,'',$crstype); } } - if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) { - $discussion.= ''. - &mt('This discussion is closed.').''; - } - } elsif ($outputtarget ne 'tex') { + } else { $discussion.=''; + $discussion.=''; } return $discussion; } @@ -793,7 +765,7 @@ sub send_message_link { my $output = ''. ' '.&mt('Send Feedback').''; return $output; } @@ -804,7 +776,7 @@ sub action_links_bar { ''. '
'; my $escsymb=&escape($ressymb); - if ($visible) { + if ($visible>2) { $discussion .= ' @@ -881,7 +843,7 @@ sub postingform_display {
$lt{'note'}
$lt{'title'}: 

- + ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= '\n"; - $postingform .= &generate_attachments_button('',$attachnum,$ressymb, - $now,$currnewattach, - $currdelold,'',$mode, - $blockblog); - if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { - $newattachmsg = '
'.$lt{'newa'}.'
'; - if (@{$currnewattach} > 1) { - $newattachmsg .= '
    '; - foreach my $item (@{$currnewattach}) { - $item =~ m#.*/([^/]+)$#; - $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + if ($outputtarget ne 'tex') { + $postingform .= &generate_attachments_button('',$attachnum,$ressymb, + $now,$currnewattach, + $currdelold,'',$mode, + $blockblog); + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { + $newattachmsg = '
    '.$lt{'newa'}.'
    '; + if (@{$currnewattach} > 1) { + $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(); } - $postingform .= $newattachmsg; - $postingform .= &generate_preview_button(); return $postingform; } @@ -943,19 +907,6 @@ sub build_posting_display { if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) { $skip_group_check = 1; } - my (%deletions,%hiddens); - if ($contrib{'deleted'}) { - my $deleted = $contrib{'deleted'}; - $deleted =~ s/^\.//; - $deleted =~ s/\.$//; - %deletions = map { $_ => 1 } (split(/\.\./,$deleted)); - } - if ($contrib{'hidden'}) { - my $hidden = $contrib{'hidden'}; - $hidden =~ s/^\.//; - $hidden =~ s/\.$//; - %hiddens = map { $_ => 1 } (split(/\.\./,$hidden)); - } if ($contrib{'version'}) { my $oldest = $contrib{'1:timestamp'}; if ($prevread eq '0') { @@ -969,13 +920,13 @@ sub build_posting_display { } for (my $id=1;$id<=$contrib{'version'};$id++) { my $idx=$id; - next if ($contrib{$idx.':deleted'}); - next if ($contrib{$idx.':hidden'}); my $posttime = $contrib{$idx.':timestamp'}; if ($prevread <= $posttime) { $$newpostsflag = 1; } + my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./); + my $deleted=($contrib{'deleted'}=~/\.$idx\./); my $origindex='0.'; my $numoldver=0; if ($contrib{$idx.':replyto'}) { @@ -999,7 +950,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) { + unless ((($hidden) && (!$seeid)) || ($deleted)) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -1033,7 +984,7 @@ sub build_posting_display { $message.=$attachtxt{$numoldver}; $subject=$subjects{$numoldver}; if ($message) { - if ($hiddens{$idx}) { + if ($hidden) { $message=''.$message.''; if ($studenthidden) { $message .='

Deleted by poster (student).'; @@ -1097,48 +1048,46 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if ($outputtarget ne 'tex') { - if (&editing_allowed($escsymb.':::'.$idx,$group)) { - if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { - $sender.=' '.&mt('Edit').''; + if (&editing_allowed($escsymb.':::'.$idx,$group)) { + if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) { + $sender.=' '.&mt('Edit').''; - unless ($seeid) { - my $grpargs = &group_args($group); - $sender.=" '; - } + unless ($seeid) { + my $grpargs = &group_args($group); + $sender.=" '; } } - if ($seeid) { - if ($hiddens{$idx}) { - unless ($studenthidden) { - $sender.=' '.&mt('Make Visible').''; - } - } else { - $sender.=' '; - } - my $grpargs = &group_args($group); - $sender.= - " "; - $sender .= &mt('Delete').''; - } + $sender .= '">'.&mt('Make Visible').''; + } + } else { + $sender.=' '.&mt('Hide').''; + } + my $grpargs = &group_args($group); + $sender.= + " "; + $sender .= &mt('Delete').''; } } else { if ($screenname) { @@ -1166,38 +1115,36 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if ($outputtarget ne 'tex') { - if (&discussion_open($status)) { - if (($group ne '') && - (&check_group_priv($group,'pgd') eq 'ok')) { - $sender.=' '.&mt('Reply').''; - } elsif (&Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'. - $env{'request.course.sec'}:''))) { - $sender.=' '.&mt('Reply').''; + if (&discussion_open($status)) { + if (($group ne '') && + (&check_group_priv($group,'pgd') eq 'ok')) { + $sender.=' '.&mt('Reply').''; + } elsif (&Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'. + $env{'request.course.sec'}:''))) { + $sender.=' '.&mt('Reply').''; } - if ($viewgrades) { + } + if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), - $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); - } - if ($$dischash{$readkey}=~/\.$idx\./) { - $ctlink = ''; - } else { - $ctlink = ''; - } + $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); + } + if ($$dischash{$readkey}=~/\.$idx\./) { + $ctlink = ''; + } else { + $ctlink = ''; } } #figure out at what position this needs to print @@ -1214,7 +1161,7 @@ sub build_posting_display { if ($outputtarget eq 'export') { %{$$imsitems{$idx}} = (); $$imsitems{$idx}{'isvisible'}='true'; - if ($hiddens{$idx}) { + if ($hidden) { $$imsitems{$idx}{'isvisible'}='false'; } $$imsitems{$idx}{'title'}=$subjects{$numoldver}; @@ -1296,7 +1243,7 @@ sub build_posting_display { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' - '; + '; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' @@ -1717,17 +1664,6 @@ END END - my ($textareaheader,$textareaclass); - if (&Apache::lonhtmlcommon::htmlareabrowser()) { - $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive(); - $textareaclass = 'class="LC_richDefaultOff"'; - if ($env{'request.course.id'}) { - unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) { - undef($textareaclass); - } - } - } - # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Resource Feedback and Discussion'}]; @@ -1767,16 +1703,14 @@ END $r->print(< $quote -

$lt{'myqu'} -$textareaheader -

+

$lt{'myqu'}

$latexHelp

$lt{'title'}:

-

END if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) { @@ -1854,6 +1788,7 @@ END } } $r->print(&generate_preview_button(). + &Apache::lonhtmlcommon::htmlareaselectactive('comment'). &Apache::loncommon::end_page()); } @@ -2302,7 +2237,7 @@ sub print_showposters { my $group = $env{'form.group'}; my $ressymb = &wrap_symb($symb); if (($group ne '') && - ($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { + ($ressymb =~ m|^bulletin___ \d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { if (&check_group_priv($group,'dgp') eq 'ok') { $seeid = 1; } @@ -2576,10 +2511,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], @@ -2613,10 +2544,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', @@ -2643,7 +2570,7 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl,$symb,$group) = @_; + my ($feedurl,$symb) = @_; 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'); @@ -2692,19 +2619,10 @@ sub screen_header { } if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - 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', + if (!$blocked && &discussion_open(undef,$symb) && + &Apache::lonnet::allowed('pch', $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || - (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) { + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { $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, DIV=>1, IMG=>1, + M=>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); } @@ -2843,7 +2763,7 @@ sub send_msg { } sub adddiscuss { - my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_; + my ($symb,$email,$anon,$attachmenturl,$subject)=@_; my $status=''; my $realsymb; if ($symb=~/^bulletin___/) { @@ -2851,16 +2771,9 @@ sub adddiscuss { $filename=~s|^adm/wrapper/||; $realsymb=&Apache::lonnet::symbread($filename); } - my ($cnum,$cdom); - if ($env{'request.course.id'}) { - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - } if (&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') && - ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})))) { + &Apache::lonnet::allowed('pch',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { my %contrib=('message' => $email, 'sendername' => $env{'user.name'}, @@ -3011,7 +2924,7 @@ sub show_preview { &newline_to_br(\$message); $message=&Apache::lonspeller::markeduptext($message); $message=&Apache::lontexconvert::msgtexconverted($message); - my $subject=&clear_out_html($env{'form.subject'}); + my $subject=&clear_out_html($env{'form.subject'},undef,1); $subject=~s/\n/\
/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); @@ -3123,7 +3036,7 @@ END {'bread_crumbs' => $brcrum,}); my $orig_subject = &unescape($env{'form.subject'}); - my $subject=&clear_out_html($orig_subject); + my $subject=&clear_out_html($orig_subject,undef,1); $subject=~s/\n/\
/g; $subject=&Apache::lontexconvert::msgtexconverted($subject); my $timestamp=$env{'form.timestamp'}; @@ -3639,10 +3552,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, @@ -3909,7 +3818,7 @@ ENDREDIR return OK; } } - my $options=&screen_header($feedurl,$symb,$group); + my $options=&screen_header($feedurl,$symb); if ($options) { &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'}); } else { @@ -3965,11 +3874,7 @@ ENDREDIR } } # Filter HTML out of message (could be nasty) - my $override; - if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) { - $override = 1; - } - my $message=&clear_out_html($env{'form.comment'},$override); + my $message=&clear_out_html($env{'form.comment'}); # Assemble email my ($email,$citations)=&assemble_email($message,$prevattempts, @@ -3979,7 +3884,8 @@ ENDREDIR my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl); # Actually send mail - my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}), + my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}, + undef,1), $feedurl,$email,$citations, $attachmenturl,$usersymb,%to); @@ -3988,10 +3894,10 @@ ENDREDIR if ( ($env{'form.discuss'} ne '' && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/) || $env{'form.anondiscuss'} ne '') { - my $subject = &clear_out_html($env{'form.subject'}); + my $subject = &clear_out_html($env{'form.subject'},undef,1); my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} ); $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl, - $subject,$group); + $subject); $numpost++; } @@ -3999,7 +3905,7 @@ ENDREDIR my $blog=''; if ($env{'form.blog'}) { - my $subject = &clear_out_html($env{'form.subject'}); + my $subject = &clear_out_html($env{'form.subject'},undef,1); $status.=&Apache::lonrss::addentry($env{'user.name'}, $env{'user.domain'}, 'CourseBlog_'.$env{'request.course.id'},