--- loncom/interface/lonfeedback.pm 2010/08/14 15:24:46 1.298 +++ loncom/interface/lonfeedback.pm 2011/12/11 19:17:54 1.309 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.298 2010/08/14 15:24:46 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.309 2011/12/11 19:17:54 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -135,7 +135,7 @@ sub list_discussion { $crs=~s/\_/\//g; my $encsymb=&Apache::lonenc::check_encrypt($ressymb); my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs) - && ($ressymb=~/\.(problem|exam|quiz|assess|survey|form|task)$/)); + && ($ressymb=~/$LONCAPA::assess_re/)); my %usernamesort = (); my %namesort =(); @@ -281,13 +281,12 @@ sub list_discussion { my $maxdepth=0; my %anonhash=(); my $anoncnt=0; - my $target=''; my $now = time; $discinfo{$visitkey} = $visit; &Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'}); - &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); + &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); my $discussion=''; my $manifestfile; @@ -722,9 +721,10 @@ END $attachnum += @{$currnewattach}; } } - if (&discussion_open($status)) { + if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { if (($group ne '') && ($mode eq 'board')) { - if (&check_group_priv($group,'pgd') eq 'ok') { + if ((&check_group_priv($group,'pgd') eq 'ok') && + ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) { $discussion .= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, @@ -732,50 +732,64 @@ 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.').''; + } } } - } else { + 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; } + +sub discussion_link { + my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds)=@_; + my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item; + if ($flag) { $link .= '&previous='.$prev; } + if ($adds) { $link .= $adds; } + return &Apache::loncommon::modal_link($link,$linktext,600,400); +} + + sub send_feedback_link { - my ($ressymb,$target) = @_; - my $output = ''. - ' '. - ''.&mt('Post Discussion').''; - return $output; + my ($ressymb) = @_; + return ''. + &discussion_link($ressymb, + ''.&mt('Post Discussion').'', + 'replydisc'). + ''; } sub send_message_link { @@ -794,7 +808,7 @@ sub action_links_bar { ''. ''. + ''; } if ($discussoptions) { - $discussoptions='

' - .' '.&mt('Discussion Contributions').'

'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'

' - .$discussoptions; + $discussoptions=''. + ''; } - return $msgoptions.$discussoptions; + return &Apache::loncommon::start_data_table().$msgoptions.$discussoptions.&Apache::loncommon::end_data_table(); } sub resource_output { @@ -2790,7 +2820,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___/) { @@ -2798,9 +2828,16 @@ 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'}:''))) { + (&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$})))) { my %contrib=('message' => $email, 'sendername' => $env{'user.name'}, @@ -3058,9 +3095,11 @@ END # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Discussion Post Attachments'}]; + my %parms=(); + if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } + my $start_page = - &Apache::loncommon::start_page('Discussion Post Attachments',$js, - {'bread_crumbs' => $brcrum,}); + &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms); my $orig_subject = &unescape($env{'form.subject'}); my $subject=&clear_out_html($orig_subject); @@ -3421,7 +3460,7 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); + ['modal','hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); my $group = $env{'form.group'}; my %attachmax = ( text => &mt('(128 KB max size)'), @@ -3472,10 +3511,11 @@ sub handler { # Breadcrumbs my $brcrum = [{'href' => '', 'text' => 'Discussion Post Versions'}]; + + my %parms=(); + if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } - $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef, - {'bread_crumbs' => $brcrum,}) - ); + $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms)); my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -3767,7 +3807,7 @@ ENDREDIR my $mode='board'; my $status='OPEN'; my $previous=$env{'form.previous'}; - if ($feedurl =~ /\.(problem|exam|quiz|assess|survey|form|library|task)$/) { + if ($feedurl =~ /$LONCAPA::assess_re/) { $mode='problem'; $status=$Apache::inputtags::status[-1]; } @@ -3807,7 +3847,7 @@ ENDREDIR &dewrapper(\$feedurl); } my $goahead=1; - if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { + if ($feedurl=~/$LONCAPA::assess_re/) { unless ($symb) { $goahead=0; } } if (!$goahead) { @@ -3845,7 +3885,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 { @@ -3901,7 +3941,11 @@ ENDREDIR } } # Filter HTML out of message (could be nasty) - my $message=&clear_out_html($env{'form.comment'}); + my $override; + if ($env{'form.discuss'} =~ /^(?:author|question|course|policy)$/) { + $override = 1; + } + my $message=&clear_out_html($env{'form.comment'},$override); # Assemble email my ($email,$citations)=&assemble_email($message,$prevattempts, @@ -3923,7 +3967,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++; }
'; my $escsymb=&escape($ressymb); - if ($visible>2) { + if ($visible) { $discussion .= ' @@ -913,7 +931,7 @@ ENDDISCUSS } sub build_posting_display { - my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; + my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; my @original=(); my @index=(); my $skip_group_check = 0; @@ -929,6 +947,19 @@ 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') { @@ -942,13 +973,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'}) { @@ -972,7 +1003,7 @@ sub build_posting_display { } else { $$replies[$$depth[$idx]]=1; } - unless ((($hidden) && (!$seeid)) || ($deleted)) { + unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) { $$visible++; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { @@ -1006,7 +1037,7 @@ sub build_posting_display { $message.=$attachtxt{$numoldver}; $subject=$subjects{$numoldver}; if ($message) { - if ($hidden) { + if ($hiddens{$idx}) { $message=''.$message.''; if ($studenthidden) { $message .='

Deleted by poster (student).'; @@ -1070,48 +1101,35 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if ((&editing_allowed($escsymb.':::'.$idx,$group)) && ($outputtarget ne 'tex')) { - 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.=" '; + 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.=' '. + &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group)); + unless ($seeid) { + my $grpargs = &group_args($group); + $sender.=" '; + } } } - } - if (($seeid) && ($outputtarget ne 'tex')) { - if ($hidden) { - unless ($studenthidden) { - $sender.=' '.&mt('Make Visible').''; - } - } else { - $sender.=' '.&mt('Hide').''; - } - my $grpargs = &group_args($group); - $sender.= - " "; - $sender .= &mt('Delete').''; + } else { + $sender.=' '. + &discussion_link($symb,&mt('Hide'),'hide',$idx,$$newpostsflag,$prevread,&group_args($group)); + } + my $grpargs = &group_args($group); + $sender.= + " "; + $sender .= &mt('Delete').''; + } } - } else { + } else { if ($screenname) { $sender=''.$screenname.''; } else { @@ -1137,36 +1155,29 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if ((&discussion_open($status)) && ($outputtarget ne 'tex')) { - 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) && ($outputtarget ne 'tex')) { + if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink(&mt('Submissions'), - $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb); - } - if (($$dischash{$readkey}=~/\.$idx\./) && ($outputtarget ne 'tex')) { - $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 @@ -1183,7 +1194,7 @@ sub build_posting_display { if ($outputtarget eq 'export') { %{$$imsitems{$idx}} = (); $$imsitems{$idx}{'isvisible'}='true'; - if ($hidden) { + if ($hiddens{$idx}) { $$imsitems{$idx}{'isvisible'}='false'; } $$imsitems{$idx}{'title'}=$subjects{$numoldver}; @@ -1286,9 +1297,8 @@ sub build_posting_display { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); if ($seeid) { - $$discussionitems[$idx] .= '  '.&mt('Display all versions').''; + $$discussionitems[$idx] .= '  '. + &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); } $$discussionitems[$idx].='
'.&mt('Earlier version(s) were posted on: '); if ($contrib{$idx.':history'} =~ m/:/) { @@ -1690,6 +1700,11 @@ END 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 @@ -1697,10 +1712,10 @@ END 'text' => 'Resource Feedback and Discussion'}]; my %onload = ('onload' => 'window.focus();setposttype();'); + my %parms=('add_entries' => \%onload); + if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } my $start_page= - &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, - {'add_entries' => \%onload, - 'bread_crumbs' => $brcrum,}); + &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms); if ($quote ne '') { $quote = &HTML::Entities::decode($quote); @@ -1709,14 +1724,18 @@ END } $quote='
'.&Apache::lontexconvert::msgtexconverted($quote).'
'; } - + my $header=''; + unless ($env{'form.modal'}) { + $header="

$restitle

"; + } $r->print(<$restitle +$header
$prevtag + END if ($env{'form.replydisc'}) { $r->print(<print(< +$options $quote

$lt{'myqu'} $textareaheader @@ -2266,7 +2285,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; } @@ -2539,12 +2558,14 @@ sub redirect_back { } &Apache::lonenc::check_encrypt(\$feedurl); my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif'); - my %onload; + my %parms=('only_body' => 1); + if ($env{'form.modal'}) { + $parms{'add_entries'}={'onLoad' => 'document.forms.reldt.submit()'}; + } else { + $parms{'redirect'}=[0,$feedurl]; + } my $start_page= - &Apache::loncommon::start_page('Feedback sent',undef, - {'redirect' => [0,$feedurl], - 'only_body' => 1, - 'add_entries' => \%onload}); + &Apache::loncommon::start_page('Feedback sent',undef,\%parms); my $end_page = &Apache::loncommon::end_page(); $r->print(<

' - .' '.&mt('Send Feedback').'

'.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').'

' - .$msgoptions; + $msgoptions='
' + .'
'.&mt('Send Feedback').'
'.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').'
'.$msgoptions.'
' + .'
'.&mt('Discussion Contributions').'
'.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').'
'.$discussoptions.'