version 1.11, 2006/07/28 18:44:27
|
version 1.23, 2010/01/30 18:19:16
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# accessor routines used to provide information about course groups |
# accessor routines used to provide information about course groups |
# |
# |
|
# $Id$ |
|
# |
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees |
# |
# |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
Line 28 package Apache::longroup;
|
Line 30 package Apache::longroup;
|
|
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::lonlocal; |
|
use LONCAPA; |
|
|
############################################### |
############################################### |
=pod |
=pod |
Line 40 Input:
|
Line 44 Input:
|
1. Optional course domain |
1. Optional course domain |
2. Optional course number |
2. Optional course number |
3. Optional group name |
3. Optional group name |
|
4. Optional namespace |
|
|
Course domain and number will be taken from user's |
Course domain and number will be taken from user's |
environment if not supplied. Optional group name will |
environment if not supplied. Optional group name will |
be passed to lonnet::get_coursegroups() as a regexp to |
be passed to lonnet function as a regexp to |
use in the call to the dump function. |
use in the call to the dump function. Optional namespace |
|
will determine whether information is retrieved about current |
|
groups (default) or deleted groups (namespace = deleted_groups). |
|
|
Output |
Output |
Returns hash of groups in the course (subject to the |
Returns hash of groups in a course (subject to the |
optional group name filter). In the hash, the keys are |
optional group name filter). In the hash, the keys are |
group names, and their corresponding values |
group names, and their corresponding values |
are scalars containing group information in XML. This |
are scalars containing group information in XML. This |
Line 55 can be sent to &get_group_settings() to
|
Line 62 can be sent to &get_group_settings() to
|
|
|
Side effects: |
Side effects: |
None. |
None. |
|
|
=cut |
=cut |
|
|
############################################### |
############################################### |
|
|
sub coursegroups { |
sub coursegroups { |
my ($cdom,$cnum,$group) = @_; |
my ($cdom,$cnum,$group,$namespace) = @_; |
if (!defined($cdom) || !defined($cnum)) { |
if (!defined($cdom) || !defined($cnum)) { |
my $cid = $env{'request.course.id'}; |
my $cid = $env{'request.course.id'}; |
|
|
Line 69 sub coursegroups {
|
Line 77 sub coursegroups {
|
$cdom = $env{'course.'.$cid.'.domain'}; |
$cdom = $env{'course.'.$cid.'.domain'}; |
$cnum = $env{'course.'.$cid.'.num'}; |
$cnum = $env{'course.'.$cid.'.num'}; |
} |
} |
my %curr_groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group); |
if (!defined($namespace)) { |
if (my $tmp = &Apache::lonnet::error(%curr_groups)) { |
$namespace = 'coursegroups'; |
undef(%curr_groups); |
} |
&Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom); |
my %groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group, |
|
$namespace); |
|
if (my $tmp = &Apache::lonnet::error(%groups)) { |
|
undef(%groups); |
|
&Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom.' - '.$namespace); |
} |
} |
return %curr_groups; |
if (defined($groups{'group_allfolders'."\0".'locked_folder'})) { |
|
delete($groups{'group_allfolders'."\0".'locked_folder'}); |
|
} |
|
return %groups; |
} |
} |
|
|
############################################### |
############################################### |
|
|
|
=pod |
|
|
=item get_group_settings |
=item get_group_settings |
|
|
Uses TokeParser to extract group information from the |
Uses TokeParser to extract group information from the |
Line 186 Input:
|
Line 203 Input:
|
4. Role |
4. Role |
5. End date of role |
5. End date of role |
6. Start date of role |
6. Start date of role |
|
7. Selfenroll |
|
8. Context |
|
|
Checks to see if role for which assignment is being made is in a course. |
Checks to see if role for which assignment is being made is in a course. |
If so, gathers information about auto-group population settings for |
If so, gathers information about auto-group population settings for |
Line 201 and would trigger membership in teh same
|
Line 220 and would trigger membership in teh same
|
If role is being added, will add any group memberships specified |
If role is being added, will add any group memberships specified |
for auto-group population, unless use is already a group member. |
for auto-group population, unless use is already a group member. |
Uses default group privileges and default start and end group access |
Uses default group privileges and default start and end group access |
times. |
times. |
|
|
|
Flag for selfenroll (value of 1), and context (auto, updatenow, |
|
automated, course, domain etc.) can be used to log the reason for |
|
the role change. |
|
|
Output |
Output |
None |
None |
Line 214 or expire group membership(s) for a user
|
Line 237 or expire group membership(s) for a user
|
=cut |
=cut |
|
|
sub group_changes { |
sub group_changes { |
my ($udom,$uname,$url,$role,$origend,$origstart) = @_; |
my ($udom,$uname,$url,$role,$origend,$origstart,$selfenroll,$context) = @_; |
my $now = time; |
my $now = time; |
my $chgtype; |
my $chgtype; |
if ($origend > 0 && $origend <= $now) { |
if ($origend > 0 && $origend <= $now) { |
Line 232 sub group_changes {
|
Line 255 sub group_changes {
|
my $courseid = $cid; |
my $courseid = $cid; |
$courseid =~ s|^/||; |
$courseid =~ s|^/||; |
$courseid =~ s|/|_|; |
$courseid =~ s|/|_|; |
if ($role =~ /^cr/) { |
|
$role =~ s/\//_/g; |
|
} |
|
my %crshash=&Apache::lonnet::coursedescription($cid); |
my %crshash=&Apache::lonnet::coursedescription($cid); |
$cdom = $crshash{'domain'}; |
$cdom = $crshash{'domain'}; |
$cnum = $crshash{'num'}; |
$cnum = $crshash{'num'}; |
Line 329 sub group_changes {
|
Line 349 sub group_changes {
|
$add,$uname.':'.$udom, |
$add,$uname.':'.$udom, |
$settings{$add}{'enddate'}, |
$settings{$add}{'enddate'}, |
$settings{$add}{'startdate'}, |
$settings{$add}{'startdate'}, |
$group_privs) eq 'ok') { |
$group_privs,$selfenroll,$context) eq 'ok') { |
my %usersettings; |
my %usersettings; |
$usersettings{$add.':'.$uname.':'.$udom} = |
$usersettings{$add.':'.$uname.':'.$udom} = |
$addgroup{$add}; |
$addgroup{$add}; |
Line 398 sub group_changes {
|
Line 418 sub group_changes {
|
$cnum,$drop, |
$cnum,$drop, |
$uname.':'.$udom,$now, |
$uname.':'.$udom,$now, |
$dropstart{$drop}, |
$dropstart{$drop}, |
$currpriv{$drop}) |
$currpriv{$drop}, |
|
$selfenroll,$context) |
eq 'ok') { |
eq 'ok') { |
my %usersettings; |
my %usersettings; |
$usersettings{$drop.':'.$uname.':'.$udom} = |
$usersettings{$drop.':'.$uname.':'.$udom} = |
Line 420 sub group_changes {
|
Line 441 sub group_changes {
|
|
|
sub get_fixed_privs { |
sub get_fixed_privs { |
my $fixedprivs = { |
my $fixedprivs = { |
email => {sgm => 1}, |
email => {sgm => 1}, |
discussion => {vgb => 1}, |
discussion => {vgb => 1}, |
chat => {pgc => 1}, |
chat => {pgc => 1}, |
files => {rgf => 1}, |
files => {rgf => 1}, |
roster => {vgm => 1}, |
roster => {vgm => 1}, |
homepage => {vgh => 1}, |
homepage => {vgh => 1}, |
}; |
}; |
return $fixedprivs; |
return $fixedprivs; |
} |
} |
Line 435 sub get_fixed_privs {
|
Line 456 sub get_fixed_privs {
|
sub get_tool_privs { |
sub get_tool_privs { |
my ($gpterm) = @_; |
my ($gpterm) = @_; |
my $toolprivs = { |
my $toolprivs = { |
email => { |
email => { |
sgm => 'Send '.$gpterm.' mail', |
sgm => 'Send '.$gpterm.' message', |
sgb => 'Broadcast mail', |
sgb => 'Broadcast message', |
}, |
}, |
discussion => { |
discussion => { |
cgb => 'Create boards', |
cgb => 'Create boards', |
Line 447 sub get_tool_privs {
|
Line 468 sub get_tool_privs {
|
vgb => 'View boards', |
vgb => 'View boards', |
}, |
}, |
chat => { |
chat => { |
pgc => 'Chat', |
pgc => 'Chat Room', |
}, |
}, |
files => { |
files => { |
rgf => 'Retrieve', |
rgf => 'Retrieve', |
Line 626 sub get_bbfolder_url {
|
Line 647 sub get_bbfolder_url {
|
|
|
sub get_group_bbinfo { |
sub get_group_bbinfo { |
my ($cdom,$cnum,$group,$boardurl) = @_; |
my ($cdom,$cnum,$group,$boardurl) = @_; |
|
my @groupboards = (); |
|
my %boardshash = (); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my @groupboards; |
if (defined($navmap)) { |
my %boardshash; |
my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group); |
my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group); |
if ($grpbbmap) { |
if ($grpbbmap) { |
my $bbfolderres = $navmap->getResourceByUrl($grpbbmap); |
my $bbfolderres = $navmap->getResourceByUrl($grpbbmap); |
if ($bbfolderres) { |
if ($bbfolderres) { |
my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0); |
my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0); |
foreach my $res (@boards) { |
foreach my $res (@boards) { |
my $url = $res->src(); |
my $url = $res->src(); |
if ($url =~ m|^(/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard)|) { |
if ($url =~ m|^(/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard)|) { |
if ($boardurl) { |
if ($boardurl) { |
if ($boardurl =~ /^\Q$1\E/) { |
if ($boardurl =~ /^\Q$1\E/) { |
push(@groupboards,$res->symb()); |
push(@groupboards,$res->symb()); |
$boardshash{$res->symb()} = { |
$boardshash{$res->symb()} = { |
|
title => $res->title(), |
title => $res->title(), |
url => $res->src(), |
url => $res->src(), |
}; |
}; |
last; |
last; |
} |
} |
} else { |
} else { |
push(@groupboards,$res->symb()); |
push(@groupboards,$res->symb()); |
$boardshash{$res->symb()} = { |
$boardshash{$res->symb()} = { |
title => $res->title(), |
title => $res->title(), |
url => $res->src(), |
url => $res->src(), |
}; |
}; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
undef($navmap); |
|
} else { |
|
&Apache::lonnet::logthis('Retrieval of group boards failed - could not create navmap object for group: '.$group.' in course: '.$cdom.':'.$cnum); |
} |
} |
undef($navmap); |
|
return (\@groupboards,\%boardshash); |
return (\@groupboards,\%boardshash); |
} |
} |
|
|