--- loncom/interface/loncoursegroups.pm 2006/02/21 18:56:00 1.6
+++ loncom/interface/loncoursegroups.pm 2006/07/07 19:50:21 1.44
@@ -1,3 +1,6 @@
+# The LearningOnline Network with CAPA
+#
+# $Id: loncoursegroups.pm,v 1.44 2006/07/07 19:50:21 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,14 +33,18 @@ use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::lonnavmaps;
+use Apache::longroup;
+use Apache::portfolio;
use Apache::Constants qw(:common :http);
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
sub handler {
my ($r) = @_;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
-
+
if ($r->header_only) {
return OK;
}
@@ -63,13 +70,18 @@ sub handler {
&Apache::lonnet::allowed('mdg',$env{'request.course.id'});
&Apache::lonhtmlcommon::clear_breadcrumbs();
+ my $gpterm = &Apache::loncommon::group_term();
+ my $ucgpterm = $gpterm;
+ $ucgpterm =~ s/^(\w)/uc($1)/e;
+ my $crstype = &Apache::loncommon::course_type();
+
my %functions = (
email => 'E-mail',
discussion => 'Discussion boards',
chat => 'Chat',
files => 'File repository',
roster => 'Membership roster',
- homepage => 'Group home page',
+ homepage => $ucgpterm.' home page',
);
my %idx = ();
@@ -77,64 +89,75 @@ sub handler {
$idx{fullname} = &Apache::loncoursedata::CL_FULLNAME();
$idx{udom} = &Apache::loncoursedata::CL_SDOM();
$idx{uname} = &Apache::loncoursedata::CL_SNAME();
+ $idx{section} = &Apache::loncoursedata::CL_SECTION();
my $rowColor1 = "#dddddd";
my $rowColor2 = "#eeeeee";
my $action = $env{'form.action'};
+ my $state = $env{'form.state'};
+ if ((!defined($action)) || ($action eq 'view')) {
+ if (!defined($state)) {
+ $state = 'view';
+ }
+ }
if ($action eq 'create' || $action eq 'modify' || $action eq 'view') {
if ($view_permission || $manage_permission) {
- &group_administration($r,$action,$cdom,$cnum,$function,$tabcol,
- \%functions,\%idx,$view_permission,
- $manage_permission,$rowColor1,$rowColor2);
+ &group_administration($r,$action,$state,$cdom,$cnum,$function,
+ $tabcol,\%functions,\%idx,$view_permission,
+ $manage_permission,$rowColor1,$rowColor2,
+ $gpterm,$ucgpterm,$crstype);
} else {
- $r->print(&mt('You do not have group administration '.
- 'privileges in this course'));
+ $r->print(&mt('You do not have [_1] administration '.
+ 'privileges in this [_2]',$gpterm,lc($crstype)));
}
} else {
- &print_main_menu($r,$cdom,$cnum,$function,$tabcol,\%functions,\%idx,
- $view_permission,$manage_permission,$action,
- $rowColor1,$rowColor2);
+ &print_main_menu($r,$cdom,$cnum,\%functions,\%idx,$view_permission,
+ $manage_permission,$action,$state,$gpterm,$ucgpterm,
+ $crstype);
}
return OK;
}
sub print_main_menu {
- my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,
- $manage_permission,$action,$rowColor1,$rowColor2) = @_;
- $r->print(&header('Course Groups',&mt('LON-CAPA Course Groups'),
- undef,undef,undef,undef,$function));
+ my ($r,$cdom,$cnum,$functions,$idx,$view_permission,$manage_permission,
+ $action,$state,$gpterm,$ucgpterm,$crstype) = @_;
+ my $pagename = "$crstype $ucgpterm".'s';
+ my $jscript = qq|
+function changeSort(caller) {
+ document.$state.sortby.value = caller;
+ document.$state.submit();
+}\n|;
+ $r->print(&header($pagename,$jscript,$action,$state));
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/coursegroups",
- text=>"Course Groups",});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs
- (undef,'Course Groups'));
- &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$action,$rowColor1,
- $rowColor2);
+ text=>"$pagename"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs($pagename));
+ &display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission,
+ $manage_permission,$action,$state,$gpterm,$ucgpterm,
+ $crstype);
$r->print(&footer());
return;
}
sub display_groups {
- my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,
- $manage_permission,$action,$rowColor1,$rowColor2) = @_;
+ my ($r,$cdom,$cnum,$functions,$idx,$view_permission,
+ $manage_permission,$action,$state,$gpterm,$ucgpterm,$crstype) = @_;
my %curr_groups = ();
my %grp_info = ();
-
my %actionlinks = (
- modify => ' ' 'Modify',
view => 'View',
delete => 'Delete',
act => 'Action',
- gname => 'Group Name',
+ gname => "$ucgpterm Name",
desc => 'Description',
crea => 'Creator',
crtd => 'Created',
@@ -144,50 +167,70 @@ sub display_groups {
memb => 'Members',
file => 'Files',
dibd => 'Discussion Boards',
- dius => 'Disk Use',
- );
- $r->print('
');
+ dius => 'Disk Use (%)',
+ nogr => 'No '.$gpterm.'s exist.',
+ crng => 'Create a new '.$gpterm,
+ alth => 'Although your current role has privileges'.
+ ' to view any existing '.$gpterm.'s in this'.
+ lc($crstype).', you do not have privileges'.
+ 'to create new '.$gpterm.'s.',
+ );
if ($view_permission) {
if (!defined($action)) {
$action = 'view';
}
- my %curr_groups;
- if (&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum)) {
- $r->print(&Apache::lonhtmlcommon::start_pick_box());
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ if (%curr_groups) {
+ if ($manage_permission) {
+ $r->print('
'.$lt{'crng'}.'');
+ }
+ $r->print('
');
+ $r->print(&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row());
+
$r->print(<<"END");
-
-
- $lt{'act'} |
- $lt{'gname'} |
- $lt{'desc'} |
- $lt{'crea'}
- |
- $lt{'crtd'}
- |
- $lt{'last'}
- |
- $lt{'func'}
- |
- $lt{'quot'} |
- $lt{'memb'} |
- $lt{'file'} |
- $lt{'dibd'} |
- $lt{'dius'} |
-
+ $lt{'act'} |
+ $lt{'gname'} |
+ $lt{'desc'} |
+ $lt{'crea'} |
+ $lt{'crtd'} |
+ $lt{'last'} |
+ $lt{'func'}
+ | $lt{'quot'} |
+ $lt{'memb'} |
+ $lt{'file'} |
+ $lt{'dibd'} |
+ $lt{'dius'} |
END
+ $r->print(&Apache::loncommon::end_data_table_header_row());
my %Sortby = ();
foreach my $group (sort(keys(%curr_groups))) {
%{$grp_info{$group}} =
- &Apache::loncommon::get_group_settings(
+ &Apache::longroup::get_group_settings(
$curr_groups{$group});
my $members_result = &group_members($cdom,$cnum,$group,
\%grp_info);
- my $files_result = &group_files($group,\%grp_info);
+ my $port_path = '/userfiles/groups/'.$group.'/portfolio';
+ my $port_dir = &Apache::loncommon::propath($cdom,$cnum).$port_path;
+ my $totaldirs = 0;
+ my $totalfiles = 0;
+ &group_files($group,$port_dir,\$totalfiles,\$totaldirs);
+ $grp_info{$group}{'totalfiles'} = $totalfiles;
+ $grp_info{$group}{'totaldirs'} = $totaldirs;
+ my $diskuse = &Apache::lonnet::diskusage($cdom,$cnum,$port_dir);
+ if ($grp_info{$group}{'quota'} > 0) {
+ my $pct_use = 0.1 * $diskuse/$grp_info{$group}{'quota'};
+ $grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use);
+ } else {
+ $grp_info{$group}{'diskuse'} = 'N/A';
+ }
+ my ($groupboards,$boardshash)=&Apache::longroup::get_group_bbinfo(
+ $cdom,$cnum,$group);
+ $grp_info{$group}{'boards'} = scalar(@{$groupboards});
if ($env{'form.sortby'} eq 'groupname') {
push(@{$Sortby{$group}},$group);
} elsif ($env{'form.sortby'} eq 'description') {
- push(@{$Sortby{$grp_info{$group}{'description'}}},
- $group);
+ push(@{$Sortby{$grp_info{$group}{'description'}}},$group);
} elsif ($env{'form.sortby'} eq 'creator') {
push(@{$Sortby{$grp_info{$group}{'creator'}}},$group);
} elsif ($env{'form.sortby'} eq 'creation') {
@@ -209,23 +252,17 @@ END
push(@{$Sortby{$group}},$group);
}
}
- my $rowNum = 0;
- my $rowColor;
foreach my $key (sort(keys(%Sortby))) {
foreach my $group (@{$Sortby{$key}}) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
- }
my $description =
- &Apache::lonnet::unescape($grp_info{$group}{'description'});
+ &unescape($grp_info{$group}{'description'});
my $creator = $grp_info{$group}{'creator'};
my $creation = $grp_info{$group}{'creation'};
my $modified = $grp_info{$group}{'modified'};
my $quota = $grp_info{$group}{'quota'};
my $totalmembers = $grp_info{$group}{'totalmembers'};
my $totalfiles = $grp_info{$group}{'totalfiles'};
+ my $totaldirs = $grp_info{$group}{'totaldirs'};
my $boards = $grp_info{$group}{'boards'};
my $diskuse = $grp_info{$group}{'diskuse'};
my $functionality;
@@ -241,43 +278,79 @@ END
if ($action eq 'modify' || $action eq 'delete') {
$link .= $group;
} else {
- $link .= $group.'/grppg?register=1';
+ $link .= $group.'/grppg';
}
- $link .= '">'.$lt{$action}.'';
- $r->print(''.$link.' | '.$group.' | '.$description.' | '.$creator.' | '. &Apache::lonnavmaps::timeToHumanString($creation).' | '. &Apache::lonnavmaps::timeToHumanString($modified).' | '.$functionality.' | '.$quota.' | '.$totalmembers.' | '.$totalfiles.' | '.$boards.' | '.$diskuse.' |
');
- $rowNum ++;
+ $link .= '">'.$lt{$action}.'';
+ if ($action eq 'view') {
+ if (($manage_permission) &&
+ ($env{'form.refpage'} ne 'enrl')) {
+ $link .= ' '.$actionlinks{'modify'}.
+ $group.'">'.$lt{'modify'}.'';
+ }
+ }
+ $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense').
+ ''.$link.' | '.
+ ''.$group.' | '.
+ ''.$description.' | '.
+ ''.$creator.' | '.
+ ''. &Apache::lonnavmaps::timeToHumanString($creation).' | '.
+ ''. &Apache::lonnavmaps::timeToHumanString($modified).' | '.
+ ''.$functionality.' | '.
+ ''.$quota.' | '.
+ ''.$totalmembers.' | '.
+ ''.&mt('Files: ').$totalfiles.' '.&mt('Folders: ').$totaldirs.' | '.
+ ''.$boards.' | '.
+ ''.$diskuse.' | '.
+ &Apache::loncommon::end_data_table_row());
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table());
+ $r->print('');
+ if ($action eq 'view') {
+ if (!defined($state)) {
+ $state = 'view';
}
+ $r->print('');
}
- $r->print('
');
- $r->print(&Apache::lonhtmlcommon::end_pick_box());
} else {
- $r->print('No groups exist');
+ $r->print($lt{'nogr'});
+ if ($manage_permission) {
+ $r->print('
'.$lt{'crng'}.'');
+ } else {
+ $r->print('
'.$lt{'alth'});
+
+ }
}
} else {
my @coursegroups = split(/:/,$env{'request.course.groups'});
if (@coursegroups > 0) {
- my %curr_groups;
- if (&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum)) {
+ $r->print('
');
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ if (%curr_groups) {
foreach my $group (@coursegroups) {
- my %group_info = &Apache::loncommon::get_group_settings(
+ my %group_info = &Apache::longroup::get_group_settings(
$curr_groups{$group});
- my $description = &Apache::lonnet::unescape(
+ my $description = &unescape(
$group_info{description});
my ($uname,$udom) = split(/:/,$group_info{creator});
- $r->print(''.$group,'
'.$description.'
');
+ $r->print(''.$group,'
'.$description.'
');
}
}
} else {
$r->print(&mt('You are not currently a member of any '.
- 'active groups in this course'));
+ 'active [_1]s in this [_2]',$gpterm,
+ lc($crstype)));
}
}
return;
}
sub group_administration {
- my ($r,$action,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$rowColor1,$rowColor2) = @_;
+ my ($r,$action,$state,$cdom,$cnum,$function,$tabcol,$functions,$idx,
+ $view_permission,$manage_permission,$rowColor1,$rowColor2,$gpterm,
+ $ucgpterm,$crstype) = @_;
my %sectioncount = ();
my @tools = ();
my @types = ();
@@ -291,8 +364,8 @@ sub group_administration {
my %memchg;
my @member_changes = ('deletion','expire','activate','reenable',
'changefunc','changepriv');
- my $state = $env{'form.state'};
- my ($groupname,$description,$startdate,$enddate,$granularity,$specificity);
+ my ($groupname,$description,$startdate,$enddate,$granularity,$specificity,
+ $quota,$validate_script);
if (defined($env{'form.groupname'})) {
$groupname = $env{'form.groupname'};
@@ -316,7 +389,9 @@ sub group_administration {
if (defined($env{'form.specificity'})) {
$specificity=$env{'form.specificity'};
}
-
+ if (defined($env{'form.quota'})) {
+ $quota=$env{'form.quota'};
+ }
}
if (($action eq 'create') || (($action eq 'modify')
&& (($state eq 'pick_privs') || ($state eq 'addresult')))) {
@@ -330,7 +405,11 @@ sub group_administration {
if ($action eq 'modify') {
if ($state eq '') {
- $state = 'pick_group';
+ if (defined($env{'form.groupname'})) {
+ $state = 'pick_task';
+ } else {
+ $state = 'pick_group';
+ }
} else {
%stored = &retrieve_settings($cdom,$cnum,$groupname);
if (ref($stored{'types'}) eq 'ARRAY') {
@@ -351,89 +430,68 @@ sub group_administration {
$description = $stored{'description'};
$granularity = $stored{'granularity'};
$specificity = $stored{'specificity'};
+ $quota = $stored{'quota'};
}
}
}
- my %toolprivs = ();
- %{$toolprivs{'email'}} = (
- sgm => 'Send group mail',
- sgb => 'Broadcast mail',
- );
- %{$toolprivs{'discussion'}} = (
- cgb => 'Create boards',
- pgd => 'Post',
- pag => 'Anon. posts',
- rgi => 'Get identities',
- vgb => 'View boards',
- );
- %{$toolprivs{'chat'}} = (
- pgc => 'Chat',
- );
- %{$toolprivs{'files'}} = (
- rgf => 'Retrieve',
- ugf => 'Upload',
- dgf => 'Delete',
- );
- %{$toolprivs{'roster'}} = (
- vgm => 'View',
- );
- %{$toolprivs{'homepage'}} = (
- vgh => 'View page',
- mgh => 'Modify page',
- );
- my %fixedprivs = ();
- %{$fixedprivs{'email'}} = ('sgm' => 1);
- %{$fixedprivs{'discussion'}} = ('vgb' => 1);
- %{$fixedprivs{'chat'}} = ('pgc' => 1);
- %{$fixedprivs{'files'}} = ('rgf' => 1);
- %{$fixedprivs{'roster'}} = ('vgm' => 1);
- %{$fixedprivs{'homepage'}} = ('vgh' => 1);
-
- my %elements = ();
- %{$elements{'create'}} = ();
- %{$elements{'modify'}} = ();
- %{$elements{'create'}{'pick_name'}} = (
- startdate_month => 'selectbox',
- startdate_hour => 'selectbox',
- enddate_month => 'selectbox',
- enddate_hour => 'selectbox',
- startdate_day => 'text',
- startdate_year => 'text',
- startdate_minute => 'text',
- startdate_second => 'text',
- enddate_day => 'text',
- enddate_year => 'text',
- enddate_minute => 'text',
- enddate_second => 'text',
- groupname => 'text',
- description => 'text',
- tool => 'checkbox',
- granularity => 'radio',
- no_end_date => 'checkbox',
- );
- %{$elements{'modify'}{'change_settings'}} = (
- %{$elements{'create'}{'pick_name'}},
- specificity => 'radio',
- defpriv => 'checkbox',
- autorole => 'checkbox',
- autoadd => 'radio',
- autodrop => 'radio',
- );
+ my $toolprivs = &Apache::longroup::get_tool_privs($gpterm);
+
+ my $fixedprivs = &Apache::longroup::get_fixed_privs();
+
+ my %elements =
+ (
+ create => {
+ pick_name => {
+ startdate_month => 'selectbox',
+ startdate_hour => 'selectbox',
+ enddate_month => 'selectbox',
+ enddate_hour => 'selectbox',
+ startdate_day => 'text',
+ startdate_year => 'text',
+ startdate_minute => 'text',
+ startdate_second => 'text',
+ enddate_day => 'text',
+ enddate_year => 'text',
+ enddate_minute => 'text',
+ enddate_second => 'text',
+ groupname => 'text',
+ description => 'text',
+ quota => 'text',
+ tool => 'checkbox',
+ granularity => 'radio',
+ no_end_date => 'checkbox',
+ },
+ pick_members => {
+ member => 'checkbox',
+ defpriv => 'checkbox',
+ },
+ },
+ );
+
+ $elements{'modify'} = {
+ change_settings => {
+ %{$elements{'create'}{'pick_name'}},
+ specificity => 'radio',
+ defpriv => 'checkbox',
+ autorole => 'checkbox',
+ autoadd => 'radio',
+ autodrop => 'radio',
+ },
+ add_members => {
+ types => 'selectbox',
+ roles => 'selectbox',
+ },
+ };
+
if (ref($stored{'autorole'}) eq 'ARRAY') {
foreach my $role (@{$stored{'autorole'}}) {
- $elements{'modify'}{'change_settings'}{'sec_'.$role} = 'selectbox';
+ unless ($role eq 'cc') {
+ $elements{'modify'}{'change_settings'}{'sec_'.$role} =
+ 'selectbox';
+ }
}
}
- %{$elements{'create'}{'pick_members'}} = (
- member => 'checkbox',
- defpriv => 'checkbox',
- );
-
- %{$elements{'modify'}{'add_members'}} = (
- types => 'selectbox',
- roles => 'selectbox',
- );
if (($action eq 'create') && ($state eq 'pick_name')) {
$elements{'create'}{'pick_name'}{'types'} = 'selectbox';
@@ -443,16 +501,16 @@ sub group_administration {
(($state eq 'pick_name') || ($state eq 'pick_privs'))) ||
(($action eq 'modify') && (($state eq 'change_settings') ||
($state eq 'add_members')))) {
- my $numsections = &Apache::loncommon::get_sections($cdom,$cnum,
- \%sectioncount);
- if ($numsections > 0) {
+ %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
+ if (%sectioncount) {
$elements{'create'}{'pick_name'}{'sectionpick'} = 'selectbox';
$elements{'modify'}{'change_mapping'}{'sectionpick'} = 'selectbox';
$elements{'modify'}{'add_members'}{'sectionpick'} = 'selectbox';
}
}
- if ($action eq 'create') {
+ if (($action eq 'create') ||
+ ($action eq 'modify' && $state eq 'pick_members')) {
if (defined($env{'form.types'})) {
@types=&Apache::loncommon::get_env_multiple('form.types');
}
@@ -461,7 +519,7 @@ sub group_administration {
}
if (defined($env{'form.sectionpick'})) {
@sections=&Apache::loncommon::get_env_multiple('form.sectionpick');
- if (grep/^_all$/,@sections) {
+ if (grep/^all$/,@sections) {
@sections = sort {$a cmp $b} keys(%sectioncount);
}
}
@@ -473,6 +531,9 @@ sub group_administration {
}
if ($state eq 'pick_members') {
if ((keys(%users) > 0) && (@tools > 0)) {
+ if ($granularity eq 'Yes') {
+ $elements{$action}{'pick_members'}{'togglefunc'} = 'checkbox';
+ }
foreach my $tool (@tools) {
if ($granularity eq 'Yes') {
$elements{$action}{'pick_members'}{'user_'.$tool} = 'checkbox';
@@ -527,6 +588,9 @@ sub group_administration {
$elements{$action}{'change_members'}{'reenable'} = 'checkbox';
}
if ($numusers) {
+ if ($granularity eq 'Yes') {
+ $elements{$action}{'change_members'}{'togglefunc'} = 'checkbox';
+ }
foreach my $tool (@tools) {
if ($granularity eq 'Yes') {
$elements{$action}{'change_members'}{'user_'.$tool} = 'checkbox';
@@ -539,11 +603,17 @@ sub group_administration {
}
if (($state eq 'pick_privs') || ($state eq 'change_privs') ||
- (($specificity eq 'No') &&
- (($state eq 'result') || ($state eq 'memresult')))) {
+ (($specificity eq 'No') &&
+ ($state eq 'memresult' || $state eq 'result' || $state eq 'addresult'))) {
foreach my $tool (@tools) {
my @values = &Apache::loncommon::get_env_multiple('form.user_'.$tool);
foreach my $user (@values) {
+ if ($state eq 'pick_privs' || $state eq 'result'
+ || $state eq 'addresult') {
+ if (!grep(/^\Q$user\E$/,@members)) {
+ next;
+ }
+ }
unless(exists($usertools{$user}{$tool})) {
$usertools{$user}{$tool} = 1;
}
@@ -575,8 +645,8 @@ sub group_administration {
}
my @currtools = ();
if (@userprivs > 0) {
- foreach my $tool (sort(keys(%fixedprivs))) {
- foreach my $priv (keys(%{$fixedprivs{$tool}})) {
+ foreach my $tool (sort(keys(%{$fixedprivs}))) {
+ foreach my $priv (keys(%{$$fixedprivs{$tool}})) {
if (grep/^$priv$/,@userprivs) {
push(@currtools,$tool);
last;
@@ -646,19 +716,59 @@ sub group_administration {
&& ($specificity eq 'Yes')) {
foreach my $user (sort(keys(%usertools))) {
foreach my $tool (keys(%{$usertools{$user}})) {
- foreach my $priv (keys(%{$toolprivs{$tool}})) {
- unless (exists($fixedprivs{$tool}{$priv})) {
+ foreach my $priv (keys(%{$$toolprivs{$tool}})) {
+ unless (exists($$fixedprivs{$tool}{$priv})) {
$elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox';
}
}
}
}
}
-
+
+ if (($action eq 'create' && $state eq 'pick_name') ||
+ ($action eq 'modify' && $state eq 'change_settings')) {
+ my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,\%stored);
+ my $space_trim = '/^\s*|\s*\$/g,""';
+ my $float_check = '/^([0-9]*\.?[0-9]*)$/';
+ $validate_script = '
+ var newquota = document.'.$state.'.quota.value;
+ newquota.replace('.$space_trim.');
+ if (newquota == "" ) {
+ document.'.$state.'.quota.value = 0;
+ newquota = 0;
+ }
+ var maxposs = '.$maxposs.';
+ if (newquota > maxposs) {
+ alert("The file repository quota you entered for this group ("+newquota+" Mb) exceeds the maximum possible ("+maxposs+" Mb). Please enter a smaller number.");
+ return;
+ }
+ var re_quota = '.$float_check.';
+ var check_quota = newquota.match(re_quota);
+ if (check_quota == null) {
+ alert("The quota you entered contains invalid characters, the quota should only include numbers, with or without a decimal point.");
+ return;
+ }
+ if (newquota == 0) {
+ var warn_zero = 0;
+ for (var i=0; iprint(&header('Course Groups Manager',&mt('LON-CAPA Groups Manager'),
- $jscript,$action,$state,$page,$function,$loaditems));
+ my $crumbtitle = "$crstype $ucgpterm".'s';
+ $r->print(&header("$crumbtitle Manager",
+ $jscript,$action,$state,$page,$loaditems));
if ($env{'form.refpage'} eq 'enrl') {
&Apache::lonhtmlcommon::add_breadcrumb
@@ -713,21 +824,21 @@ function changeSort(caller) {
} else {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/coursegroups",
- text=>"Course Groups",
+ text=>"$crumbtitle",
faq=>9,bug=>'Instructor Interface',});
}
my %trail = ();
%{$trail{'create'}} = &Apache::lonlocal::texthash (
- pick_name => 'Group Settings',
+ pick_name => $ucgpterm.' Settings',
pick_members => 'Select Members',
pick_privs => 'Choose Privileges',
result => 'Creation Complete',
);
%{$trail{'modify'}} = &Apache::lonlocal::texthash(
- pick_group => 'Groups',
+ pick_group => $ucgpterm.'s',
pick_task => 'Choose Task',
- change_settings => 'Group Settings',
+ change_settings => "$ucgpterm Settings",
change_members => 'Modify/Delete Members',
change_privs => 'Change Privileges',
change_mapping => 'Membership Mapping',
@@ -741,7 +852,7 @@ function changeSort(caller) {
my %navbuttons = &Apache::lonlocal::texthash(
gtns => 'Go to next step',
gtps => 'Go to previous step',
- crgr => 'Create group',
+ crgr => 'Create '.$gpterm,
mose => 'Modify settings',
gtpp => 'Go to previous page',
adme => 'Add members',
@@ -753,17 +864,18 @@ function changeSort(caller) {
&Apache::lonhtmlcommon::add_breadcrumb(
{text=>"$trail{$action}{$state}"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
- (undef,'Course Groups Manager'));
+ ("$crumbtitle Manager"));
&display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page,
\%sectioncount,$groupname,$description,$functions,
- \@tools,\%toolprivs,\%fixedprivs,$startdate,$enddate,
+ \@tools,$toolprivs,$fixedprivs,$startdate,$enddate,
\%users,\%userdata,$idx,\%memchg,\%usertools,
$function,$view_permission,$manage_permission,
- \%stored,$granularity,$specificity,\@types,\@roles,
- \@sections,\%states,\%navbuttons,$rowColor1,$rowColor2);
+ \%stored,$granularity,$quota,$specificity,\@types,\@roles,
+ \@sections,\%states,\%navbuttons,$rowColor1,$rowColor2,
+ $gpterm,$ucgpterm,$crstype);
last;
} else {
- if (($state =~ /^\w+result$/) && ($i > 0)) {
+ if (($state eq 'result') && ($i > 0)) {
&Apache::lonhtmlcommon::add_breadcrumb(
{href=>"javascript:backPage(document.$state,'$states{$action}[0]')",
text=>"$trail{$action}{$states{$action}[$i]}"});
@@ -776,12 +888,13 @@ function changeSort(caller) {
}
} elsif (($action eq 'view') && ($view_permission)) {
&Apache::lonhtmlcommon::add_breadcrumb(
- {text=>"View groups"});
+ {text=>"View $gpterm".'s'});
+ my $crumbtitle = "$crstype $ucgpterm".'s Manager';
$r->print(&Apache::lonhtmlcommon::breadcrumbs
- (undef,'Course Groups Manager'));
- &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$action,
- $rowColor1,$rowColor2);
+ (&mt($crumbtitle)));
+ &display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission,
+ $manage_permission,$action,$state,$gpterm,$ucgpterm,
+ $crstype);
}
$r->print(&footer());
@@ -790,55 +903,58 @@ function changeSort(caller) {
sub retrieve_settings {
my ($cdom,$cnum,$groupname) = @_;
- my %groupinfo;
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$groupname);
+
+ return if (!%curr_groups);
+
+ my %groupinfo =
+ &Apache::longroup::get_group_settings($curr_groups{$groupname});
+
my %stored;
- my %curr_groups;
- my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
- $cnum,$groupname);
- if ($numgroups > 0) {
- %groupinfo = &Apache::loncommon::get_group_settings(
- $curr_groups{$groupname});
- $stored{'description'} = &Apache::lonnet::unescape(
- $groupinfo{'description'});
- $stored{'startdate'} = $groupinfo{'startdate'};
- $stored{'enddate'} = $groupinfo{'enddate'};
- if ($stored{'enddate'} == 0) {
- $stored{'no_end_date'} = 1;
- }
- $stored{'granularity'} = $groupinfo{'granularity'};
- $stored{'specificity'} = $groupinfo{'specificity'};
- $stored{'creation'} = $groupinfo{'creation'};
- $stored{'creator'} = $groupinfo{'creator'};
-
- foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
- if ($groupinfo{functions}{$tool} eq 'on') {
- push(@{$stored{tool}},$tool);
- }
- }
- foreach my $role (@{$groupinfo{'roles'}}) {
- push(@{$stored{roles}},$role);
- }
- foreach my $type (@{$groupinfo{'types'}}) {
- push(@{$stored{types}},$type);
- }
- foreach my $section (@{$groupinfo{'sectionpick'}}) {
- push(@{$stored{sectionpick}},$section);
- }
- foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
- push(@{$stored{defpriv}},$defpriv);
- }
- $stored{'autoadd'} = $groupinfo{'autoadd'};
- $stored{'autodrop'} = $groupinfo{'autodrop'};
- if (exists($groupinfo{'autosec'})) {
- foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
- foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
- push (@{$stored{'sec_'.$role}},$section);
- }
- if (@{$groupinfo{'autosec'}{$role}} > 0) {
- push(@{$stored{'autorole'}},$role);
- }
+
+ $stored{'description'} =
+ &unescape($groupinfo{'description'});
+ $stored{'startdate'} = $groupinfo{'startdate'};
+ $stored{'enddate'} = $groupinfo{'enddate'};
+ if ($stored{'enddate'} == 0) {
+ $stored{'no_end_date'} = 1;
+ }
+ $stored{'granularity'} = $groupinfo{'granularity'};
+ $stored{'specificity'} = $groupinfo{'specificity'};
+ $stored{'creation'} = $groupinfo{'creation'};
+ $stored{'creator'} = $groupinfo{'creator'};
+ $stored{'quota'} = $groupinfo{'quota'};
+
+ foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
+ if ($groupinfo{functions}{$tool} eq 'on') {
+ push(@{$stored{tool}},$tool);
+ }
+ }
+ foreach my $role (@{$groupinfo{'roles'}}) {
+ push(@{$stored{roles}},$role);
+ }
+ foreach my $type (@{$groupinfo{'types'}}) {
+ push(@{$stored{types}},$type);
+ }
+ foreach my $section (@{$groupinfo{'sectionpick'}}) {
+ push(@{$stored{sectionpick}},$section);
+ }
+ foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
+ push(@{$stored{defpriv}},$defpriv);
+ }
+ $stored{'autoadd'} = $groupinfo{'autoadd'};
+ $stored{'autodrop'} = $groupinfo{'autodrop'};
+ if (exists($groupinfo{'autosec'})) {
+ foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
+ if (ref($groupinfo{'autosec'}{$role}) eq 'ARRAY') {
+ foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
+ push (@{$stored{'sec_'.$role}},$section);
+ }
+ if (@{$groupinfo{'autosec'}{$role}} > 0) {
+ push(@{$stored{'autorole'}},$role);
+ }
}
- }
+ }
}
return %stored;
}
@@ -847,78 +963,86 @@ sub display_control {
my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$sectioncount,$groupname,
$description,$functions,$tools,$toolprivs,$fixedprivs,$startdate,
$enddate,$users,$userdata,$idx,$memchg,$usertools,$function,
- $view_permission,$manage_permission,$stored,$granularity,$specificity,
- $types,$roles,$sections,$states,$navbuttons,$rowColor1,$rowColor2)=@_;
+ $view_permission,$manage_permission,$stored,$granularity,$quota,
+ $specificity,$types,$roles,$sections,$states,$navbuttons,$rowColor1,
+ $rowColor2,$gpterm,$ucgpterm,$crstype) = @_;
if ($action eq 'create') {
if ($state eq 'pick_name') {
&general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page,
$functions,$tools,$toolprivs,$fixedprivs,
$sectioncount,$stored,$states,$navbuttons,
- $rowColor1,$rowColor2);
+ $rowColor1,$rowColor2,$gpterm,$ucgpterm,
+ $crstype);
} elsif ($state eq 'pick_members') {
&choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
- $groupname,$description,$granularity,
+ $groupname,$description,$granularity,$quota,
$startdate,$enddate,$tools,$fixedprivs,
$toolprivs,$functions,$users,$userdata,$idx,
$stored,$states,$navbuttons,$rowColor1,
- $rowColor2);
+ $rowColor2,$gpterm,$ucgpterm,$crstype);
} elsif ($state eq 'pick_privs') {
&choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
$startdate,$enddate,$tools,$functions,
$toolprivs,$fixedprivs,$userdata,$usertools,
$idx,$states,$stored,$sectioncount,$navbuttons,
- $rowColor1,$rowColor2);
+ $rowColor1,$rowColor2,$gpterm,$ucgpterm,
+ $crstype);
} elsif ($state eq 'result') {
&process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page,
$groupname,$description,$specificity,$userdata,
$startdate,$enddate,$tools,$functions,
$toolprivs,$usertools,$idx,$types,$roles,
$sections,$states,$navbuttons,$memchg,
- $sectioncount,$stored,$rowColor1,$rowColor2);
+ $sectioncount,$stored,$rowColor1,$rowColor2,
+ $gpterm,$ucgpterm,$crstype);
}
} elsif ($action eq 'modify') {
my $groupname = $env{'form.groupname'};
if ($state eq 'pick_group') {
- &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$action,
- $rowColor1,$rowColor2);
+ &display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission,
+ $manage_permission,$action,$state,$gpterm,
+ $ucgpterm,$crstype);
} elsif ($state eq 'pick_task') {
- &modify_menu($r,$groupname,$page);
+ &modify_menu($r,$groupname,$page,$gpterm);
} elsif ($state eq 'change_settings') {
&general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page,
$functions,$tools,$toolprivs,$fixedprivs,
$sectioncount,$stored,$states,$navbuttons,
- $rowColor1,$rowColor2);
+ $rowColor1,$rowColor2,$gpterm,$ucgpterm,
+ $crstype);
} elsif ($state eq 'change_members') {
&change_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
$groupname,$description,$startdate,$enddate,
$tools,$fixedprivs,$functions,$users,
- $userdata,$granularity,$specificity,$idx,
- $states,$navbuttons,$rowColor1,$rowColor2);
+ $userdata,$granularity,$quota,$specificity,
+ $idx,$states,$navbuttons,$rowColor1,$rowColor2,
+ $gpterm,$ucgpterm);
} elsif ($state eq 'add_members') {
&add_members_form($r,$tabcol,$action,$state,$page,$startdate,
$enddate,$groupname,$description,$granularity,
- $sectioncount,$tools,$functions,$stored,$states,
- $navbuttons,$rowColor1,$rowColor2);
+ $quota,$sectioncount,$tools,$functions,$stored,
+ $states,$navbuttons,$rowColor1,$rowColor2,$gpterm,
+ $ucgpterm);
} elsif ($state eq 'pick_members') {
&choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
- $groupname,$description,$granularity,
+ $groupname,$description,$granularity,$quota,
$startdate,$enddate,$tools,$fixedprivs,
$toolprivs,$functions,$users,$userdata,$idx,
$stored,$states,$navbuttons,$rowColor1,
- $rowColor2);
+ $rowColor2,$gpterm,$ucgpterm,$crstype);
} elsif ($state eq 'pick_privs') {
&choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
$startdate,$enddate,$tools,$functions,
$toolprivs,$fixedprivs,$userdata,$usertools,
$idx,$states,$stored,$sectioncount,$navbuttons,
- $rowColor1,$rowColor2);
+ $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
} elsif ($state eq 'change_privs') {
&change_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
$startdate,$enddate,$tools,$functions,
$toolprivs,$fixedprivs,$userdata,$usertools,
$memchg,$idx,$states,$stored,$sectioncount,
- $navbuttons,$rowColor1,$rowColor2);
+ $navbuttons,$rowColor1,$rowColor2,$gpterm,
+ $ucgpterm);
} elsif ($state eq 'chgresult' || $state eq 'memresult' ||
$state eq 'addresult') {
&process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page,
@@ -926,25 +1050,22 @@ sub display_control {
$startdate,$enddate,$tools,$functions,
$toolprivs,$usertools,$idx,$types,$roles,
$sections,$states,$navbuttons,$memchg,
- $sectioncount,$stored,$rowColor1,$rowColor2);
+ $sectioncount,$stored,$rowColor1,$rowColor2,
+ $gpterm,$ucgpterm,$crstype);
}
}
}
sub header {
- my ($bodytitle,$title,$jscript,$action,$state,$page,$function,$loaditems) = @_;
- my $html=&Apache::lonxml::xmlbegin();
- my $bodytag=&Apache::loncommon::bodytag($bodytitle,$function,$loaditems);
+ my ($bodytitle,$jscript,$action,$state,$page,$loaditems) = @_;
+ my $start_page=
+ &Apache::loncommon::start_page($bodytitle,
+ '',
+ {'add_entries' => $loaditems,});
my $output = <<"END";
-$html
-
-$title
-
-
-$bodytag
-
-