--- loncom/interface/lonfeedback.pm 2009/05/11 16:51:27 1.273 +++ loncom/interface/lonfeedback.pm 2010/01/25 03:56:00 1.273.4.6 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.273 2009/05/11 16:51:27 bisitz Exp $ +# $Id: lonfeedback.pm,v 1.273.4.6 2010/01/25 03:56:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -169,6 +169,8 @@ sub list_discussion { my $cdom = $env{'course.'.$cid.'.domain'}; 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 = (); @@ -352,10 +354,10 @@ sub list_discussion { $togglink = 'toggoff'; } - $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; + $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink; if ($newpostsflag) { - $chglink .= '&previous='.$prevread; + $chglink .= '&previous='.$prevread; } $chglink.=&group_args($group); @@ -418,7 +420,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ var symbparm = symb+':::'+idx var prevparm = "" if (newflag == 1) { - prevparm = "&previous="+previous + prevparm = "&previous="+previous } if (caller == 'studentdelete') { if (confirm("$lt{'aysu'}\\n$lt{'dpwn'},\\n$lt{'bwco'}")) { @@ -446,7 +448,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ $discussion.="\n".''. ''.&mt('Show all posts').' '.&mt('to display').' '. @@ -565,7 +567,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ + $lt{'cuse'}:
- $lt{'cuse'}:   END @@ -587,7 +589,7 @@ END   - $lt{'chgt'}? + $lt{'chgt'}?
@@ -597,7 +599,7 @@ END my %sort_types = (); my %role_types = (); my %status_types = (); - &sort_filter_names(\%sort_types,\%role_types,\%status_types); + &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype); $discussion .= ''.&mt('Sorted by').': '.$sort_types{$sortposts}.'
'; if (defined($env{'form.totposters'})) { @@ -723,13 +725,13 @@ END &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, $currnewattach,$currdelold, - $group); + $group,$crstype); } } else { $discussion.= &postingform_display($mode,$ressymb,$now,$subject, $comment,$outputtarget,$attachnum, - $currnewattach,$currdelold); + $currnewattach,$currdelold,'',$crstype); } } } else { @@ -774,13 +776,13 @@ sub send_message_link { sub action_links_bar { my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp) = @_; my $discussion = ''. - ''; + '
'. + ''; } else { $discussion .= ''; } @@ -826,7 +826,7 @@ sub action_links_bar { sub postingform_display { my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum, - $currnewattach,$currdelold,$group) = @_; + $currnewattach,$currdelold,$group,$crstype) = @_; my $newattachmsg; my %lt = &Apache::lonlocal::texthash( 'note' => 'Note: in anonymous discussion, your name is visible only to course faculty', @@ -835,6 +835,9 @@ sub postingform_display { 'poan' => 'Post Anonymous Discussion', 'newa' => 'New attachments', ); + if ($crstype eq 'Community') { + $lt{'note'} = &mt('Note: in anonymous discussion, your name is visible only to community facilitators'); + } my $postingform = (< @@ -843,7 +846,7 @@ sub postingform_display {
$lt{'note'}
$lt{'title'}: 

- + ENDDISCUSS if ($env{'form.origpage'}) { $postingform .= '\n"; if ($outputtarget ne 'tex') { @@ -1011,6 +1014,7 @@ sub build_posting_display { $contrib{$idx.':senderdomain'}).' ('. $contrib{$idx.':sendername'}.':'. $contrib{$idx.':senderdomain'}.')'; + $sender = ''.$sender.''; if ($contrib{$idx.':anonymous'}) { $sender.=' ['.$$anonhash{$key}.'] '. $screenname; @@ -1018,6 +1022,7 @@ sub build_posting_display { if ($see_anonymous) { $sender.=&Apache::loncommon::student_image_tag($contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'}); } + $sender = ''.$sender.''; # Set up for sorting by domain, then username unless (defined($$usernamesort{$contrib{$idx.':senderdomain'}})) { %{$$usernamesort{$contrib{$idx.':senderdomain'}}} = (); @@ -1052,7 +1057,7 @@ sub build_posting_display { $sender.=' '.&mt('Edit').''; @@ -1078,7 +1083,7 @@ sub build_posting_display { $sender.=' '.&mt('Hide').''; @@ -1119,7 +1124,7 @@ sub build_posting_display { $sender.=' '.&mt('Reply').''; @@ -1240,24 +1245,24 @@ sub build_posting_display { if ($prevread > 0 && $prevread <= $posttime) { $$newitem{$idx} = 1; $$discussionitems[$idx] .= ' -

'; my $escsymb=&escape($ressymb); if ($visible>2) { - $discussion .= ''. - '  '. @@ -796,8 +798,6 @@ sub action_links_bar { } $discussion .= &group_args($group); $discussion .='">'.&mt('Sorting/Filtering options').''.(' ' x2); - } else { - $discussion .= '
'.&mt('Mark NEW posts no longer new').''; + $discussion .= '">'.&mt('Mark NEW posts no longer new').'
 
+
'; } else { $$newitem{$idx} = 0; $$discussionitems[$idx] .= ' -

'.&mt('NEW').'
+
'; } $$discussionitems[$idx] .= ''; if ($$dischash{$toggkey}) { $$discussionitems[$idx].=''; } $$discussionitems[$idx].= '
   '. ''.$subject.'  '. - $sender.' '.$vgrlink.' ('. + $sender.' '.$vgrlink.' ('. &Apache::lonlocal::locallocaltime($posttime).')  '. $ctlink.'
'. - $message.'

'; + $message.''; if ($contrib{$idx.':history'}) { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); @@ -1479,7 +1484,6 @@ sub mail_screen { } my %lt = &Apache::lonlocal::texthash( - 'plch' => 'Please check at least one of the following feedback types:', 'myqu' => 'My question/comment/feedback:', 'title' => 'Title', 'reta' => 'Retained attachments', @@ -1690,7 +1694,6 @@ END END } $r->print(< $quote

$lt{'myqu'}

@@ -1700,7 +1703,7 @@ $latexHelp

$lt{'title'}:

-

END @@ -1737,7 +1740,7 @@ END $r->print(< - +

END @@ -1944,9 +1947,9 @@ END $r->print(<$lt{'disa'} $lt{$discdisp} - +
- + END $r->print(&Apache::loncommon::end_data_table_row()); @@ -1961,7 +1964,7 @@ END $r->print(<$lt{'dotm'} $lt{$disctogg} - + END my $save = &mt('Save'); $r->print(&Apache::loncommon::end_data_table_row()); @@ -1975,7 +1978,7 @@ END - + END if (exists($env{'form.group'})) { $r->print(''); @@ -2006,6 +2009,13 @@ sub print_sortfilter_options { my $group_sel = ''; my $numgroupvis = 5; my %sectioncount = &Apache::loncommon::get_sections(); + my @courseroles = qw(st ad ep ta in); + my $crstype = &Apache::loncommon::course_type(); + my $ccrole = 'cc'; + if ($crstype eq 'Community') { + $ccrole = 'co'; + } + push(@courseroles,$ccrole); if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section @sections = ('all',$env{'request.course.sec'}); @@ -2069,7 +2079,7 @@ sub print_sortfilter_options { my %sort_types = (); my %role_types = (); my %status_types = (); - &sort_filter_names(\%sort_types,\%role_types,\%status_types); + &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype); my $js = < @@ -2121,17 +2131,17 @@ $start_page

- - - - - - - - - - - + + + + + + + + + + + @@ -2185,7 +2196,7 @@ $start_page
- + END if (exists($env{'form.group'})) { $r->print(''); @@ -2308,7 +2319,7 @@ END
- + $end_page END @@ -2411,7 +2422,7 @@ sub redirect_back { if ($previous > 0) { $qrystr = 'previous='.$previous; if ($feedurl =~ /\?register=1/) { - $feedurl .= '&'.$qrystr; + $feedurl .= '&'.$qrystr; } else { $feedurl .= '?'.$qrystr; } @@ -2420,14 +2431,14 @@ sub redirect_back { if (defined($sort)) { my $sortqry = 'sortposts='.$sort; if (($feedurl =~ /\?register=1/) || ($feedurl =~ /\?previous=/)) { - $feedurl .= '&'.$sortqry; + $feedurl .= '&'.$sortqry; } else { $feedurl .= '?'.$sortqry; } $sorttag = ''; if (defined($numpicks)) { my $userpickqry = 'totposters='.$numpicks; - $feedurl .= '&'.$userpickqry; + $feedurl .= '&'.$userpickqry; $userpicktag = ''; } else { if (ref($sectionpick) eq 'ARRAY') { @@ -2441,7 +2452,7 @@ sub redirect_back { $sectag =~ s/,$//; $sectag .= '" />'; } else { - $feedurl .= '§ionpick='.$sectionpick; + $feedurl .= '&sectionpick='.$sectionpick; $sectag = ''; } if (ref($grouppick) eq 'ARRAY') { @@ -2455,7 +2466,7 @@ sub redirect_back { $grptag =~ s/,$//; $grptag .= '" />'; } else { - $feedurl .= '&grouppick='.$grouppick; + $feedurl .= '&grouppick='.$grouppick; $grptag = ''; } if (ref($rolefilter) eq 'ARRAY') { @@ -2472,7 +2483,7 @@ sub redirect_back { $feedurl .= '&rolefilter='.$rolefilter; $roletag = ''; } - $feedurl .= '&statusfilter='.$statusfilter; + $feedurl .= '&statusfilter='.$statusfilter; $statustag =''; } } @@ -2561,6 +2572,22 @@ ENDNOREDIRTWO sub screen_header { 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'); + my $anoncontrib = &mt('Anonymous contribution to course discussion of resource'); + my $namevis = &mt('name only visible to course faculty'); + my $crstype; + if ($env{'request.course.id'}) { + $crstype = &Apache::loncommon::course_type(); + if ($crstype eq 'Community') { + $crscontent = &mt('Question/Comment/Feedback about community content'); + $crspolicy = &mt('Question/Comment/Feedback about community policy'); + $contribdisc = &mt('Contribution to community discussion of resource'); + $anoncontrib = &mt('Anonymous contribution to community discussion of resource'); + $namevis = &mt('name only visible to community facilitators'); + } + } my $msgoptions=''; my $discussoptions=''; unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) { @@ -2581,13 +2608,13 @@ sub screen_header { if (&feedback_available(0,1)) { $msgoptions.= '

'; } if (&feedback_available(0,0,1)) { $msgoptions.= '

'; } } @@ -2598,25 +2625,26 @@ sub screen_header { $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) { - $discussoptions.= &add_blog_checkbox(); + $discussoptions.= &add_blog_checkbox($crstype); } } } if ($msgoptions) { $msgoptions='

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

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

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

' .$msgoptions; } if ($discussoptions) { $discussoptions='

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

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

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

' .$discussoptions; } return $msgoptions.$discussoptions; @@ -2914,6 +2942,19 @@ 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 + ); +} sub newline_to_br { my ($message)=@_; @@ -2947,7 +2988,7 @@ sub generate_preview_button { +onclick="if (typeof(document.$formname.onsubmit)=='function') {document.$formname.onsubmit();};this.form.comment.value=document.$formname.$fieldname.value;this.form.subject.value=document.$formname.subject.value;this.form.submit();" /> ENDPREVIEW } @@ -3002,7 +3043,7 @@ $toolarge
$lt{'soor'} $lt{'sprs'} $lt{'spur'} $lt{'spse'} $lt{'spgr'} $lt{'psub'}$lt{'soor'} $lt{'sprs'} $lt{'spur'} $lt{'spse'} $lt{'spgr'} $lt{'psub'}
@@ -2158,10 +2168,11 @@ $start_page
@@ -3053,7 +3094,7 @@ END $r->print(''."\n"); } $r->print(< + $end_page END @@ -3245,7 +3286,8 @@ sub construct_attachmenturl { } sub add_blog_checkbox { - my ($checkstatus); + my ($crstype) = @_; + my $checkstatus; if ($env{'form.blog'}) { $checkstatus = 'checked="checked"'; } @@ -3259,8 +3301,13 @@ function setblogvalue() { } }
-
'."\n"; +
'."\n"; return $output; } @@ -3284,8 +3331,9 @@ sub has_discussion { } sub sort_filter_names { - my ($sort_types,$role_types,$status_types) = @_; - %{$sort_types} = ( + my ($sort_types,$role_types,$status_types,$crstype) = @_; + if (ref($sort_types) eq 'HASH') { + %{$sort_types} = ( ascdate => 'Date order - oldest first', descdate => 'Date order - newest first', thread => 'Threaded', @@ -3293,24 +3341,30 @@ sub sort_filter_names { username => 'By domain and username', lastfirst => 'By last name, first name' ); - %{$role_types} = ( - all => 'All roles', - st => 'Students', - cc => 'Course Coordinators', - in => 'Instructors', - ta => 'TAs', - ep => 'Exam proctors', - ad => 'Administrators', - cr => 'Custom roles' - ); - %{$status_types} = ( - all => 'Roles of any status', - Active => 'Only active roles', - Expired => 'Only past roles', - Future => 'Only future roles', - ); + } + my @courseroles = qw(st in ta ep ad); + if ($crstype eq 'Community') { + push(@courseroles,'co'); + } else { + push(@courseroles,'cc'); + } + if (ref($role_types) eq 'HASH') { + foreach my $role (@courseroles) { + $role_types->{$role} = &Apache::lonnet::plaintext($role,$crstype); + } + $role_types->{'all'} = 'All roles'; + $role_types->{'cr'} = 'Custom role'; + } + if (ref($status_types) eq 'HASH') { + %{$status_types} = ( + 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) { @@ -3836,7 +3890,11 @@ ENDREDIR $env{'user.domain'}, 'CourseBlog_'.$env{'request.course.id'}, $subject,$message,$feedurl,'public'); - $blog='
'.&mt('Added to my course blog').'
'; + if (&Apache::loncommon::course_type() eq 'Community') { + $blog='
'.&mt('Added to my community blog').'
'; + } else { + $blog='
'.&mt('Added to my course blog').'
'; + } } # Receipt screen and redirect back to where came from
- Subject: $subject

+ Subject: $subject

END if ($idx) { if ($attachmenturls) { @@ -3030,7 +3071,7 @@ END
- $lt{'adda'} + $lt{'adda'}