--- loncom/interface/lonfeedback.pm 2006/05/09 20:00:44 1.198
+++ loncom/interface/lonfeedback.pm 2006/08/08 19:02:04 1.214
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.198 2006/05/09 20:00:44 albertel Exp $
+# $Id: lonfeedback.pm,v 1.214 2006/08/08 19:02:04 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,10 @@ 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;
sub discussion_open {
my ($status,$symb)=@_;
@@ -71,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'}) {
@@ -84,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; }
@@ -127,21 +135,13 @@ 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 = ();
- if ($env{'form.sectionpick'} =~ /,/) {
- @sectionpick = split/,/,$env{'form.sectionpick'};
- } else {
- $sectionpick[0] = $env{'form.sectionpick'};
- }
- my @rolefilter = ();
- if ($env{'form.rolefilter'} =~ /,/) {
- @rolefilter = split/,/,$env{'form.rolefilter'};
- } else {
- $rolefilter[0] = $env{'form.rolefilter'};
- }
+ my @sectionpick = split(/,/,$env{'form.sectionpick'});
+ my @grouppick = split(/,/,$env{'form.grouppick'});
+ my @rolefilter = split(/,/,$env{'form.rolefilter'});
+
my $totposters = $env{'form.totposters'};
$previous = $env{'form.previous'};
if ($previous > 0) {
@@ -152,13 +152,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/) {
@@ -174,9 +176,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) {
@@ -184,6 +185,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
@@ -223,7 +227,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=();
@@ -250,7 +262,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;
@@ -323,6 +335,7 @@ sub list_discussion {
if ($newpostsflag) {
$chglink .= '&previous='.$prevread;
}
+ $chglink.=&group_args($group);
if ($visible) {
# Print the discusssion
@@ -394,23 +407,26 @@ imscp_v1p1.xsd http://www.imsglobal.org/
$discussion.='
$end_page
-END
+");
}
sub print_showposters {
@@ -1974,19 +2124,36 @@ sub print_showposters {
$crs.='_'.$env{'request.course.sec'};
}
$crs=~s/\_/\//g;
- my $seeid=&Apache::lonnet::allowed('rin',$crs);
+ my $seeid;
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ 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$|)) {
+ if (&check_group_priv($group,'dgp') eq 'ok') {
+ $seeid = 1;
+ }
+ } else {
+ $seeid=&Apache::lonnet::allowed('rin',$crs);
+ }
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
+ $cdom,$cnum);
my %namesort = ();
my %postcounts = ();
+ my %lt = &Apache::lonlocal::texthash(
+ sele => 'Select',
+ full => 'Fullname',
+ usdo => 'Username/domain',
+ post => 'Posts',
+ );
if ($contrib{'version'}) {
for (my $idx=1;$idx<=$contrib{'version'};$idx++) {
my $hidden=($contrib{'hidden'}=~/\.$idx\./);
my $deleted=($contrib{'deleted'}=~/\.$idx\./);
unless ((($hidden) && (!$seeid)) || ($deleted)) {
- 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'}:'')))) {
my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'});
my $lastname = $names{'lastname'};
my $firstname = $names{'firstname'};
@@ -2021,10 +2188,10 @@ $start_page
$table_start
- No. |
- Select |
- Fullname(Username/domain) |
- Posts |
+ # |
+ $lt{'sele'} |
+ $lt{'full'} ($lt{'usdo'}) |
+ $lt{'post'} |
END
my $count = 0;
@@ -2135,18 +2302,18 @@ ENDFAILREDIR
}
sub redirect_back {
- my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
+ my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group) = @_;
my $sorttag = '';
my $roletag = '';
my $statustag = '';
my $sectag = '';
+ my $grptag = '';
my $userpicktag = '';
my $qrystr = '';
my $prevtag = '';
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
-
&dewrapper(\$feedurl);
if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
if ($previous > 0) {
@@ -2185,6 +2352,20 @@ sub redirect_back {
$feedurl .= '§ionpick='.$sectionpick;
$sectag = '';
}
+ if (ref($grouppick) eq 'ARRAY') {
+ $feedurl .= '&grouppick=';
+ $sectag .= '';
+ } else {
+ $feedurl .= '&grouppick='.$grouppick;
+ $grptag = '';
+ }
if (ref($rolefilter) eq 'ARRAY') {
$feedurl .= '&rolefilter=';
$roletag .= '';
}
}
+ my $grouptag;
+ if ($group ne '') {
+ $grouptag = ''; my $refarg;
+ if (exists($env{'form.ref'})) {
+ $refarg = '&ref='.$env{'form.ref'};
+ $grouptag .= '';
+ }
+ if ($feedurl =~ /\?/) {
+ $feedurl .= '&group='.$group.$refarg;
+ } else {
+ $feedurl .= '?group='.$group.$refarg;
+ }
+ }
$feedurl=&Apache::lonenc::check_encrypt($feedurl);
my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
- my %onload = ('onload' => "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }");
+ 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,
- {'redirect' => [2,$feedurl],
+ &Apache::loncommon::start_page('Feedback sent',undef,
+ {'redirect' => [0,$feedurl],
'only_body' => 1,
'add_entries' => \%onload});
my $end_page = &Apache::loncommon::end_page();
-
$r->print(<
@@ -2226,7 +2423,9 @@ $sorttag
$statustag
$roletag
$sectag
+$grptag
$userpicktag
+$grouptag
$end_page
ENDREDIR
@@ -2236,9 +2435,15 @@ sub no_redirect_back {
my ($r,$feedurl) = @_;
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',
- 'add_entries' => {'onload' => "if (window.name!='loncapaclient') { self.window.close(); }"});
+ 'add_entries' => \%onload,);
if ($feedurl !~ m{^/adm/feedback}) {
$body_options{'rediect'} = [2,$feedurl];
@@ -2267,23 +2472,23 @@ sub screen_header {
unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) {
$msgoptions=
- '