--- loncom/interface/lonfeedback.pm 2006/06/30 04:49:03 1.207 +++ loncom/interface/lonfeedback.pm 2006/07/17 23:02:33 1.208 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.207 2006/06/30 04:49:03 albertel Exp $ +# $Id: lonfeedback.pm,v 1.208 2006/07/17 23:02:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,7 @@ use Apache::lonenc(); use Apache::lonrss(); use HTML::LCParser(); use Apache::lonspeller(); +use Apache::longroup; use Cwd; use lib '/home/httpd/lib/perl/'; use LONCAPA; @@ -73,7 +74,7 @@ sub discussion_visible { } sub list_discussion { - my ($mode,$status,$ressymb,$imsextras)=@_; + my ($mode,$status,$ressymb,$imsextras,$group)=@_; my $outputtarget=$env{'form.grade_target'}; if (defined($env{'form.export'})) { if($env{'form.export'}) { @@ -86,6 +87,11 @@ sub list_discussion { } } if (not &discussion_visible($status)) { return ''; } + if ($group ne '' && $mode eq 'board') { + if (&check_group_priv($group,'vgb') ne 'ok') { + return ''; + } + } my @bgcols = ("#cccccc","#eeeeee"); my $discussiononly=0; if ($mode eq 'board') { $discussiononly=1; } @@ -129,7 +135,7 @@ sub list_discussion { my @posters = split/\&/,$dischash{$userpickkey}; # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts. - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','totposters']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','grouppick','totposters']); my $sortposts = $env{'form.sortposts'}; my $statusfilter = $env{'form.statusfilter'}; my @sectionpick = (); @@ -138,6 +144,13 @@ sub list_discussion { } else { $sectionpick[0] = $env{'form.sectionpick'}; } + my @grouppick = (); + if ($env{'form.grouppick'} =~ /,/) { + @grouppick = split/,/,$env{'form.grouppick'}; + } else { + $grouppick[0] = $env{'form.grouppick'}; + } + my @rolefilter = (); if ($env{'form.rolefilter'} =~ /,/) { @rolefilter = split/,/,$env{'form.rolefilter'}; @@ -154,13 +167,15 @@ sub list_discussion { } } + my $cdom = $env{'course.'.$cid.'.domain'}; + my $cnum = $env{'course.'.$cid.'.num'}; + # Get information about students and non-students in course for filtering display of posts my %roleshash = (); my %roleinfo = (); + my ($classgroups,$studentgroups); if ($env{'form.rolefilter'}) { - %roleshash = &Apache::lonnet::dump('nohist_userroles', - $env{'course.'.$cid.'.domain'}, - $env{'course.'.$cid.'.num'}); + %roleshash = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); foreach (keys %roleshash) { my ($role,$uname,$udom,$sec) = split/:/,$_; if ($role =~ /^cr/) { @@ -176,9 +191,8 @@ sub list_discussion { push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status; } } - my ($classlist) = &Apache::loncoursedata::get_classlist( - $env{'course.'.$cid.'.domain'}, - $env{'course.'.$cid.'.num'}); + my ($classlist,$keylist) = + &Apache::loncoursedata::get_classlist($cdom,$cnum); my $sec_index = &Apache::loncoursedata::CL_SECTION(); my $status_index = &Apache::loncoursedata::CL_STATUS(); while (my ($student,$data) = each %$classlist) { @@ -186,6 +200,9 @@ sub list_discussion { $data->[$status_index]); push @{$roleinfo{$student}}, 'st:'.$section.':'.$status; } + ($classgroups,$studentgroups) = + &Apache::loncoursedata::get_group_memberships($classlist,$keylist, + $cdom,$cnum); } # Get discussion display default settings for user @@ -225,7 +242,15 @@ sub list_discussion { } $visit ++; - my $seeid=&Apache::lonnet::allowed('rin',$crs); + my $seeid; + if (($group ne '') && ($mode eq 'board') && + ($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; + } + } else { + $seeid=&Apache::lonnet::allowed('rin',$crs); + } my @discussionitems=(); my %shown = (); my @posteridentity=(); @@ -252,7 +277,7 @@ sub list_discussion { $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,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt); + &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); my $discussion=''; my $manifestfile; @@ -261,6 +286,11 @@ sub list_discussion { my $imsresources; my $copyresult; + my $grp_arg; + if ($group ne '') { + $grp_arg = &grp_args($group); + } + my $function = &Apache::loncommon::get_users_function(); my $color = &Apache::loncommon::designparm($function.'.tabbg', $env{'user.domain'}); @@ -325,6 +355,9 @@ sub list_discussion { if ($newpostsflag) { $chglink .= '&previous='.$prevread; } + if ($group ne '') { + $chglink.='&'.$grp_arg; + } if ($visible) { # Print the discusssion @@ -403,16 +436,25 @@ imscp_v1p1.xsd http://www.imsglobal.org/ if ($newpostsflag) { $discussion .= '&previous='.$prevread; } + if ($group ne '') { + $discussion .= '&'.$grp_arg; + } $discussion .='">'.&mt('Threaded View').' '. ''.&mt('Chronological View').' '.&mt('Sorting/Filtering options').'  '; } else { $discussion .= '
';
@@ -766,16 +799,75 @@ ENDDISCUSS
return $discussion;
}
+sub postingform_display {
+ my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum,
+ $currnewattach,$currdelold,$group) = @_;
+ my $newattachmsg;
+ my $postingform = (< +Note: in anonymous discussion, your name is visible only +to course faculty +Title: + +ENDDISCUSS + if ($env{'form.origpage'}) { + $postingform .= ''."\n"; + foreach my $att (@{$currnewattach}) { + $postingform .= ''."\n"; + } + } + if (exists($env{'form.ref'})) { + $postingform .= ''; + } + if ($group ne '') { + $postingform .=''; + } + $postingform .= "\n"; + if ($outputtarget ne 'tex') { + $postingform .= &generate_attachments_button('',$attachnum,$ressymb, + $now,$currnewattach, + $currdelold,'',$mode); + if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) { + $newattachmsg = ' New attachments '; + if (@{$currnewattach} > 1) { + $newattachmsg .= '
'."\n"; + } + } + $postingform .= $newattachmsg; + $postingform .= &generate_preview_button(); + } + return $postingform; +} + 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,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt) = @_; + 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 @original=(); my @index=(); + my $skipgrpcheck = 0; my $symb=&Apache::lonenc::check_decrypt($ressymb); my $escsymb=&escape($ressymb); my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); + if ((@{$grouppick} == 0) || (grep/^all$/,@{$grouppick})) { + $skipgrpcheck = 1; + } if ($contrib{'version'}) { my $oldest = $contrib{'1:timestamp'}; if ($prevread eq '0') { @@ -783,7 +875,8 @@ sub build_posting_display { } my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp); if ($sortposts) { - ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter); + ($skiptest,$roleregexp,$secregexp,$statusregexp) = + &filter_regexp($rolefilter,$sectionpick,$statusfilter); $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; } for (my $id=1;$id<=$contrib{'version'};$id++) { @@ -872,7 +965,7 @@ sub build_posting_display { @{$$subjectsort{$subject}} = ("$idx"); } } - if ((!$contrib{$idx.':anonymous'}) || ($seeid)) { + if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) { $sender=&Apache::loncommon::aboutmewrapper( $plainname, $contrib{$idx.':sendername'}, @@ -913,14 +1006,18 @@ sub build_posting_display { } else { @{$$namesort{$lastname}{$firstname}} = ("$idx"); } - if (&editing_allowed()) { + 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 ($group ne '') { + $sender.='&'.&grp_args($group); + } + $sender .= '" '.$target.'>'.&mt('Edit').''; + unless ($seeid) { $sender.=" '; @@ -943,6 +1040,9 @@ sub build_posting_display { if ($$newpostsflag) { $sender .= '&previous='.$prevread; } + if ($group ne '') { + $sender.='&'.&grp_args($group); + } $sender .= '">'.&mt('Hide').''; } $sender.=' '.&mt('Delete').''; } } else { @@ -977,16 +1080,27 @@ sub build_posting_display { @{$$namesort{'__anon'}{'__anon'}} = ("$idx"); } } - if (&discussion_open($status) && - &Apache::lonnet::allowed('pch', - $env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { - $sender.=' '.&mt('Reply').''; + } elsif (&Apache::lonnet::allowed('pch', + $env{'request.course.id'}. + ($env{'request.course.sec'}?'/'. + $env{'request.course.sec'}:''))) { + $sender.=' '.&mt('Reply').''; } - $sender .= '" '.$target.'>'.&mt('Reply').''; } if ($viewgrades) { $vgrlink=&Apache::loncommon::submlink('Submissions', @@ -1043,7 +1157,7 @@ sub build_posting_display { my $uname = $contrib{$idx.':sendername'}; my $udom = $contrib{$idx.':senderdomain'}; my $poster = $uname.':'.$udom; - if (defined($env{'form.totposters'})) { + if ($env{'form.totposters'} ne '') { if ($totposters == 0) { $$shown{$idx} = 0; } elsif ($totposters > 0) { @@ -1068,6 +1182,23 @@ sub build_posting_display { } } } + if ($$shown{$idx} && !$skipgrpcheck) { + my $showflag = 0; + if (ref($$classgroups{$poster}{active}) eq 'HASH') { + foreach my $grp (@{$grouppick}) { + if (grep/^\Q$grp\E$/, + keys(%{$$classgroups{$poster}{active}})) { + $showflag = 1; + last; + } + } + } + if ($showflag) { + $$shown{$idx} = 1; + } else { + $$shown{$idx} = 0; + } + } } else { $$shown{$idx} = 1; } @@ -1098,7 +1229,11 @@ 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] .= ' '.&mt('Display all versions').''; } $$discussionitems[$idx].=' '.&mt('Earlier version(s) were posted on: '); if ($contrib{$idx.':history'} =~ m/:/) { @@ -1161,6 +1296,7 @@ sub filter_regexp { $secregexp .= '[^:]*'; } } + if (defined($statusfilter) && $statusfilter ne '') { if ($statusfilter eq 'all') { $statusregexp = '[^:]+'; @@ -1181,7 +1317,7 @@ sub get_post_contents { %{$$imsfiles{$idx}}=(); if ($type eq 'allversions') { unless($seeid) { - $discussion=&mt('You do not have privileges to view all versions of posts.').&mt('Please select a different role'); + $discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.'); return $discussion; } } @@ -1308,7 +1444,7 @@ sub replicate_attachments { sub mail_screen { my ($r,$feedurl,$options) = @_; if (exists($env{'form.origpage'})) { - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']); } my $title=&Apache::lonnet::gettitle($feedurl); @@ -1550,6 +1686,12 @@ Attachment (128 KB max size): END } + if (exists($env{'form.group'})) { + $r->print(''); + } + if (exists($env{'form.ref'})) { + $r->print(''); + } $r->print(< $end_page -END + "); return; } @@ -1807,6 +1957,9 @@ sub print_sortfilter_options { my @sections; my $section_sel = ''; my $numvisible = 5; + my @groups; + my $group_sel = ''; + my $numgroupvis = 5; my %sectioncount = &Apache::loncommon::get_sections(); if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section @@ -1823,7 +1976,33 @@ sub print_sortfilter_options { foreach (@sections) { $section_sel .= " $_\n"; } - + + if (&check_group_priv() eq 'ok') { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); + @groups = sort {$a cmp $b} keys(%curr_groups); + if (scalar(@groups) < 4) { + $numgroupvis = scalar(@groups) + 1; + } + unshift(@groups,'all'); # Put 'all' at the front of the list + } else { + my @coursegroups = split(/:/,$env{'request.course.groups'}); + if (@coursegroups > 0) { + @coursegroups = sort {$a cmp $b} @coursegroups; + @groups = ('all',@coursegroups); + if (scalar(@groups) < 4) { + $numgroupvis = scalar(@groups) + 1; + } + } else { + @groups = ('all'); + $numgroupvis = 1; + } + } + foreach (@groups) { + $group_sel .= " $_\n"; + } + my $function = &Apache::loncommon::get_users_function(); my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg', $env{'user.domain'}); @@ -1836,6 +2015,7 @@ sub print_sortfilter_options { 'spur' => 'Specific user roles', 'sprs' => 'Specific role status', 'spse' => 'Specific sections', + 'spgr' => 'Specific groups', 'psub' => 'Pick specific users (by name)', 'shal' => 'Show a list of current posters' ); @@ -1867,6 +2047,17 @@ function verifyFilter() { if (secnum == 0) { document.modifyshown.sectionpick.options[0].selected = true } + + var grpnum = 0 + for (var i=0; i |
$lt{'spse'} |
|
+ $lt{'spgr'} |
+ |
$lt{'psub'} |
| |||||||||
+ | - | + | - | + | - | + | - | + | + + | ++ |