version 1.2, 2006/05/18 13:49:10
|
version 1.5, 2006/06/26 22:20:57
|
Line 23
|
Line 23
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
|
package Apache::longroup; |
package Apache::longroup; |
|
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
Line 45 Course domain and number will be taken f
|
Line 45 Course domain and number will be taken f
|
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::get_coursegroups() as a regexp to |
use in the call to the dump function. |
use in the call to the dump function. |
|
|
Output |
Output |
Returns hash of groups in the course (subject to the |
Returns hash of groups in the course (subject to the |
optional group name filter). In the hash, the keys are |
optional group name filter). In the hash, the keys are |
Line 70 sub coursegroups {
|
Line 70 sub coursegroups {
|
$cnum = $env{'course.'.$cid.'.num'}; |
$cnum = $env{'course.'.$cid.'.num'}; |
} |
} |
my %curr_groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group); |
my %curr_groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group); |
my ($tmp) = keys(%curr_groups); |
if (my $tmp = &Apache::lonnet::error(%curr_groups)) { |
if ($tmp=~/^(con_lost|no_such_host|error: [^2] )/) { |
undef(%curr_groups); |
undef(%curr_groups); |
&Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom); |
&logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom); |
|
} elsif ($tmp=~/^error: 2 /) { |
|
undef(%curr_groups); |
|
} |
} |
return %curr_groups; |
return %curr_groups; |
} |
} |
Line 83 sub coursegroups {
|
Line 80 sub coursegroups {
|
############################################### |
############################################### |
|
|
=item get_group_settings |
=item get_group_settings |
|
|
Uses TokeParser to extract group information from the |
Uses TokeParser to extract group information from the |
XML used to describe course groups. |
XML used to describe course groups. |
|
|
Input: |
Input: |
Scalar containing XML - as retrieved from &coursegroups(). |
Scalar containing XML - as retrieved from &coursegroups(). |
|
|
Output: |
Output: |
Hash containing group information as key=values for (a), and |
Hash containing group information as key=values for (a), and |
hash of hashes for (b) |
hash of hashes for (b) |
|
|
Keys (in two categories): |
Keys (in two categories): |
(a) groupname, creator, creation, modified, startdate,enddate. |
(a) groupname, creator, creation, modified, startdate,enddate. |
Corresponding values are name of the group, creator of the group |
Corresponding values are name of the group, creator of the group |
(username:domain), UNIX time for date group was created, and |
(username:domain), UNIX time for date group was created, and |
settings were last modified, and default start and end access |
settings were last modified, and default start and end access |
times for group members. |
times for group members. |
|
|
(b) functions returned in hash of hashes. |
(b) functions returned in hash of hashes. |
Outer hash key is functions. |
Outer hash key is functions. |
Inner hash keys are chat,discussion,email,files,homepage,roster. |
Inner hash keys are chat,discussion,email,files,homepage,roster. |
Corresponding values are either on or off, depending on |
Corresponding values are either on or off, depending on |
whether this type of functionality is available for the group. |
whether this type of functionality is available for the group. |
|
|
=cut |
=cut |
|
|
############################################### |
############################################### |
Line 155 sub get_group_settings {
|
Line 152 sub get_group_settings {
|
} elsif ($token->[1] eq 'role') { |
} elsif ($token->[1] eq 'role') { |
$role = ''; |
$role = ''; |
} |
} |
|
|
} |
} |
} |
} |
return %content; |
return %content; |
Line 176 sub check_group_access {
|
Line 172 sub check_group_access {
|
############################################### |
############################################### |
|
|
=pod |
=pod |
|
|
=item group_changes |
=item group_changes |
|
|
Add or drop group memberships in a course as a result of |
Add or drop group memberships in a course as a result of |
changes in a user's roles/sections. Called by |
changes in a user's roles/sections. Called by |
&Apache::lonnet:assignrole() |
&Apache::lonnet:assignrole() |
|
|
Input: |
Input: |
1. User's domain |
1. User's domain |
2. User's username |
2. User's username |
Line 273 sub group_changes {
|
Line 269 sub group_changes {
|
if (@changegroups > 0) { |
if (@changegroups > 0) { |
my %currpriv; |
my %currpriv; |
my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,$cid); |
my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,$cid); |
my ($tmp) = keys(%roleshash); |
if (my $tmp = &Apache::lonnet::error(%roleshash)) { |
if ($tmp=~/^error:/) { |
|
&Apache::lonnet::logthis('Error retrieving roles: '.$tmp. |
&Apache::lonnet::logthis('Error retrieving roles: '.$tmp. |
' for '.$uname.':'.$udom); |
' for '.$uname.':'.$udom); |
} else { |
} else { |