--- loncom/interface/lonfeedback.pm 2010/09/21 04:58:17 1.273.4.11 +++ loncom/interface/lonfeedback.pm 2010/01/25 02:27:09 1.287 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.273.4.11 2010/09/21 04:58:17 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.287 2010/01/25 02:27:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonnavmaps; use Apache::lonenc(); use Apache::lonrss(); use HTML::LCParser(); +#use HTML::Tidy::libXML; use Apache::lonspeller(); use Apache::longroup; use Cwd; @@ -48,22 +49,13 @@ 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; } -# 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; } @@ -100,7 +92,7 @@ sub list_discussion { if (not &discussion_visible($status)) { if ($mode ne 'board') { &Apache::lonenc::check_encrypt(\$ressymb); - return '
'.&send_message_link($ressymb); + return '
"; } } if ($group ne '' && $mode eq 'board') { @@ -112,9 +104,12 @@ sub list_discussion { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); if ($blocked) { + $blocktext = '
'; + }else{ + $blocktext.=""; } return $blocktext; } @@ -180,7 +175,6 @@ sub list_discussion { my $cnum = $env{'course.'.$cid.'.num'}; my $crstype = &Apache::loncommon::course_type(); - # Get information about students and non-students in course for filtering display of posts my %roleshash = (); my %roleinfo = (); @@ -410,7 +404,6 @@ sub list_discussion { if ($manifestfile = Apache::File->new('>'.$manifestfilename)) { $manifestok=1; print $manifestfile qq| - - |; + |); $discussion.='
'. "\n".''; $discussion .= &action_links_bar($colspan,$ressymb,$visible, @@ -653,7 +645,7 @@ END $discussion.=''; } $discussion .= (<'; + $discussion.= &send_feedback_link($ressymb,$target); } + } + if ($outputtarget ne 'tex') { + $discussion.= &send_message_link($ressymb); } - $discussion.=&send_message_link($ressymb).''; + $discussion.=''; } return $discussion; } @@ -774,9 +758,9 @@ sub send_feedback_link { my $output = ''. ' '. - ''.&mt('Post Discussion').''; + '" border="0" />'.&mt('Post Discussion').''; return $output; } @@ -784,9 +768,9 @@ sub send_message_link { my ($ressymb) = @_; my $output = ''. ' '.&mt('Send Feedback').''; + '" border="0" />'.&mt('Send Feedback').''; return $output; } @@ -805,20 +789,20 @@ sub action_links_bar { $discussion .='">'.&mt('Threaded View').'  '. ''.&mt('Chronological View').'   '.&mt('Sorting/Filtering options').''.(' ' x2); } $discussion .=''.&mt('Export').'?  '; @@ -863,7 +847,7 @@ sub postingform_display {
$lt{'note'}
$lt{'title'}: 

- + ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= ''; } @@ -1116,6 +1099,7 @@ sub build_posting_display { } else { $sender=''.$$anonhash{$key}.''; } + $sender = ''.$sender.''; # Set up for sorting by domain, then username for anonymous unless (defined($$usernamesort{'__anon'})) { %{$$usernamesort{'__anon'}} = (); @@ -1152,7 +1136,7 @@ sub build_posting_display { $sender.=' '.&mt('Reply').''; } @@ -1262,17 +1246,17 @@ sub build_posting_display { if ($prevread > 0 && $prevread <= $posttime) { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' -
'. ''."\n". ''."\n". + ' onclick="this.form.submit();" />'."\n". '
+
'; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' -
'.&mt('NEW').'
+
'; } $$discussionitems[$idx] .= ''; if ($$dischash{$toggkey}) { $$discussionitems[$idx].='
   '. ''.$subject.'  '. - $sender.' '.$vgrlink.' ('. + $sender.$vgrlink.' ('. &Apache::lonlocal::locallocaltime($posttime).')  '. @@ -1684,10 +1668,15 @@ END END + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Resource Feedback and Discussion'}]; + my %onload = ('onload' => 'window.focus();setposttype();'); my $start_page= &Apache::loncommon::start_page('Resource Feedback and Discussion',$js, - {'add_entries' => \%onload}); + {'add_entries' => \%onload, + 'bread_crumbs' => $brcrum,}); if ($quote ne '') { $quote = &HTML::Entities::decode($quote); @@ -2038,7 +2027,7 @@ sub print_sortfilter_options { $ccrole = 'co'; } push(@courseroles,$ccrole); - + if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section @sections = ('all',$env{'request.course.sec'}); $numvisible = 2; @@ -2464,7 +2453,7 @@ sub redirect_back { $userpicktag = ''; } else { if (ref($sectionpick) eq 'ARRAY') { - $feedurl .= '§ionpick='; + $feedurl .= '&sectionpick='; $sectag .= ''; } if (ref($grouppick) eq 'ARRAY') { - $feedurl .= '&grouppick='; + $feedurl .= '&grouppick='; $sectag .= ''; } if (ref($rolefilter) eq 'ARRAY') { - $feedurl .= '&rolefilter='; + $feedurl .= '&rolefilter='; $roletag .= ''; } else { - $feedurl .= '&rolefilter='.$rolefilter; + $feedurl .= '&rolefilter='.$rolefilter; $roletag = ''; } $feedurl .= '&statusfilter='.$statusfilter; @@ -2642,22 +2631,15 @@ sub screen_header { } if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) { my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); - 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) && + if (!$blocked && &discussion_open(undef,$symb) && &Apache::lonnet::allowed('pch', $env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { $discussoptions='
'. - + $contribdisc. + '
'. ''.&mt('Change Screenname').''; my $blockblog = &Apache::loncommon::blocking_status('blogs'); if (!$blockblog) { @@ -2709,7 +2691,6 @@ sub clear_out_html { 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); - } # Do the substitution of everything that is not explicitly allowed $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ @@ -2726,6 +2707,9 @@ sub assemble_email { 'orig' => 'Original screen output (if applicable)', 'corr' => 'Correct Answer(s) (if applicable)', ); + if (&Apache::loncommon::course_type() eq 'Community') { + $lt{'prev'} = &mt('Previous attempts of member (if applicable)'); + } my $email=<<"ENDEMAIL"; $message ENDEMAIL @@ -2975,17 +2959,29 @@ sub show_preview { sub contains_block_html { my ($message)=@_; return ($message =~ m{ - <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div) - \s* - (\w+\=['"]\w+['"])* - \s* - ( - \s*/>| - >.* - )}xs + <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div) + \s* + (\w+\=['"]\w+['"])* + \s* + ( + \s*/>| + >.* + )}xs ); } +sub tidy_html { + my ($message)=@_; +# my $tidy = HTML::Tidy::libXML->new(); +# my $xhtml = $tidy->clean($message, 'utf-8', 1); +# $xhtml =~ m/(.*)<\/body>/is; +# my $clean = $1; +# # remove any empty block-level tags +# $clean =~ s/<(table|p|div|tbody|blockquote|m|pre|algebra|center|ol|ul|span|h1|h2|h3|h4|h5|h6)\s*\/>//i; +# $message=$clean; + return $message; +} + sub newline_to_br { my ($message)=@_; my $newmessage; @@ -3044,8 +3040,12 @@ sub modify_attachments { END + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Discussion Post Attachments'}]; my $start_page = - &Apache::loncommon::start_page('Discussion Post Attachments',$js); + &Apache::loncommon::start_page('Discussion Post Attachments',$js, + {'bread_crumbs' => $brcrum,}); my $orig_subject = &unescape($env{'form.subject'}); my $subject=&clear_out_html($orig_subject,undef,1); @@ -3171,7 +3171,7 @@ sub generate_attachments_button {
$lt{'clic'}:  'Roles of any status', - Active => 'Only active roles', - Expired => 'Only past roles', - Future => 'Only future roles', - ); + all => 'Roles of any status', + Active => 'Only active roles', + Expired => 'Only past roles', + Future => 'Only future roles', + ); } } - + sub handler { my $r = shift; if ($r->header_only) { @@ -3454,7 +3454,13 @@ sub handler { &Apache::loncommon::no_cache($r); $r->send_http_header; - $r->print(&Apache::loncommon::start_page('Discussion Post Versions')); + # Breadcrumbs + my $brcrum = [{'href' => '', + 'text' => 'Discussion Post Versions'}]; + + $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef, + {'bread_crumbs' => $brcrum,}) + ); my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -4160,6 +4166,8 @@ None =item newline_to_br() +=item tidy_html() + =item generate_preview_button() =item modify_attachments()