$lt{'rev'} $lt{'ren'} $lt{'del'} $lt{'rol'} $lt{'e
xt'} $lt{'sta'} $lt{'end'}
END
- foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
+ foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
if ($output{$type}) {
$r->print($output{$type}."\n");
}
@@ -853,12 +947,11 @@ ENDDROW
$r->print($domaintext);
}
#
-# Course level
+# Course and group levels
#
- my $num_sections;
if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
- $r->print(&course_level_dc($1));
+ $r->print(&course_level_dc($1,'Course'));
$r->print(' '."\n");
} else {
$r->print(&course_level_table(%inccourses));
@@ -883,6 +976,7 @@ sub update_user_data {
$title='Modify User Privileges';
}
$r->print(&Apache::loncommon::start_page($title));
+ my %disallowed;
# Check Inputs
if (! $env{'form.ccuname'} ) {
$r->print($error.&mt('No login name specified').'.'.$end);
@@ -1104,22 +1198,23 @@ END
&Apache::lonnet::critical('put:'.
$env{'course.'.$cid.'.domain'}.':'.
$env{'course.'.$cid.'.num'}.':classlist:'.
- &Apache::lonnet::escape($env{'form.ccuname'}.':'.
+ &escape($env{'form.ccuname'}.':'.
$env{'form.ccdomain'}).'='.
- &Apache::lonnet::escape($now.':'),
+ &escape($now.':'),
$env{'course.'.$cid.'.home'}).' ');
}
}
if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
# Revoke custom role
- $r->print(&mt('Revoking custom role').
+ $r->print(&mt('Revoking custom role:').
' '.$4.' by '.$3.'@'.$2.' in '.$1.': '.
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$3,$4).
' ');
}
} elsif ($_=~/^form\.del/) {
- if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
+ if ($_=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
+# Delete standard role
$r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$now,0,1).' ');
@@ -1130,16 +1225,26 @@ END
&Apache::lonnet::critical('put:'.
$env{'course.'.$cid.'.domain'}.':'.
$env{'course.'.$cid.'.num'}.':classlist:'.
- &Apache::lonnet::escape($env{'form.ccuname'}.':'.
+ &escape($env{'form.ccuname'}.':'.
$env{'form.ccdomain'}).'='.
- &Apache::lonnet::escape($now.':'),
+ &escape($now.':'),
$env{'course.'.$cid.'.home'}).' ');
}
- }
+ }
+ if ($_=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+# Delete custom role
+ $r->print(&mt('Deleting custom role [_1] by [_2]@[_3] in [_4]',
+ $rolename,$rnam,$rdom,$url).': '.
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1).' ');
+ }
} elsif ($_=~/^form\.ren/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
- if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
+# Re-enable standard role
+ if ($_=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
my $url = $1;
my $role = $2;
my $logmsg;
@@ -1159,11 +1264,20 @@ END
} else {
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$role,0,$now);
- $output = &mt('Re-Enabling [_1] in [_2]: [_3]',
+ $output = &mt('Re-enabling [_1] in [_2]: [_3] ',
$role,$url,$result).' ';
}
$r->print($output);
- }
+ }
+# Re-enable custom role
+ if ($_=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+ my $result = &Apache::lonnet::assigncustomrole(
+ $env{'form.ccdomain'}, $env{'form.ccuname'},
+ $url,$rdom,$rnam,$rolename,0,$now);
+ $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : [_5] ',
+ $rolename,$rnam,$rdom,$url,$result).' ');
+ }
} elsif ($_=~/^form\.act/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
@@ -1186,8 +1300,15 @@ END
if ($num_sections == 0) {
$r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
} else {
- foreach (sort {$a cmp $b} keys %sections) {
- my $securl = $url.'/'.$_;
+ my %curr_groups =
+ &Apache::longroup::coursegroups($one,$two);
+ foreach my $sec (sort {$a cmp $b} keys %sections) {
+ if (($sec eq 'none') || ($sec eq 'all') ||
+ exists($curr_groups{$sec})) {
+ $disallowed{$sec} = $url;
+ next;
+ }
+ my $securl = $url.'/'.$sec;
$r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
}
}
@@ -1209,10 +1330,17 @@ END
if ($num_sections == 0) {
$r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
} else {
+ my %curr_groups =
+ &Apache::longroup::coursegroups($one,$two);
my $emptysec = 0;
foreach my $sec (sort {$a cmp $b} keys %sections) {
$sec =~ s/\W//g;
- if ($sec ne '') {
+ if ($sec ne '') {
+ if (($sec eq 'none') || ($sec eq 'all') ||
+ exists($curr_groups{$sec})) {
+ $disallowed{$sec} = $url;
+ next;
+ }
my $securl = $url.'/'.$sec;
$r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
} else {
@@ -1255,7 +1383,15 @@ END
} else {
$r->print(''.&mt('ERROR').': '.&mt('Unknown command').' '.$_.'
');
}
- }
+ foreach my $key (sort(keys(%disallowed))) {
+ if (($key eq 'none') || ($key eq 'all')) {
+ $r->print(''.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
+ } else {
+ $r->print('
'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key));
+ }
+ $r->print(' '.&mt('Please go back and choose a different section name.').'
');
+ }
+ }
} # End of foreach (keys(%env))
# Flush the course logs so reverse user roles immediately updated
&Apache::lonnet::flushcourselogs();
@@ -1341,7 +1477,7 @@ sub commit_studentrole {
}
} else {
$$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed";
- $result = "Error: incomplete course id\n";
+ $result = "error: incomplete course id\n";
}
return $result;
}
@@ -1450,7 +1586,7 @@ sub custom_role_editor {
}
my %lt=&Apache::lonlocal::texthash(
'prv' => "Privilege",
- 'crl' => "Course Level",
+ 'crl' => "Course/Group Level",
'dml' => "Domain Level",
'ssl' => "System Level"
);
@@ -1462,16 +1598,17 @@ sub custom_role_editor {
$area Domain: $domain
ENDEXTENT
if ($_ ne 'cc') {
- if ($num_sections > 0) {
- my $currsec = &course_sections($num_sections,\%sections_count,$protectedcourse.'_'.$_);
+ if (%sections_count) {
+ my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$_);
$table .=
''.
''.$lt{'exs'}.' '.
@@ -1677,8 +1815,8 @@ ENDTIMEENTRY
$plrole
$area
END
- if ($num_sections > 0) {
- my $currsec = &course_sections($num_sections,\%sections_count,$customrole);
+ if (%sections_count) {
+ my $currsec = &course_sections(\%sections_count,$customrole);
$table.=
''.
''.$lt{'exs'}.' '.
@@ -1717,10 +1855,10 @@ ENDTABLE
}
sub course_sections {
- my ($num_sections,$sections_count,$role) = @_;
+ my ($sections_count,$role) = @_;
my $output = '';
my @sections = (sort {$a <=> $b} keys %{$sections_count});
- if ($num_sections == 1) {
+ if (scalar(@sections) == 1) {
$output = ''."\n".
' Select '."\n".
' No section '."\n".
@@ -1728,7 +1866,7 @@ sub course_sections {
} else {
$output = ''."\n";
foreach (@sections) {
$output .= ''.$_." \n";
@@ -1745,14 +1883,12 @@ sub course_level_dc {
' '.
' ';
my $courseform=''.&Apache::loncommon::selectcourse_link
- ('cu','dccourse','dcdomain','coursedesc').' ';
-
- my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,$dcdom);
+ ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').'';
+ my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom);
my %lt=&Apache::lonlocal::texthash(
- 'crl' => "Course Level",
- 'crt' => "Course Title",
+ 'typ' => "Type",
'rol' => "Role",
- 'grs' => "Group/Section",
+ 'grs' => "Section",
'exs' => "Existing sections",
'new' => "Define new section",
'sta' => "Start",
@@ -1760,11 +1896,11 @@ sub course_level_dc {
'ssd' => "Set Start Date",
'sed' => "Set End Date"
);
- my $header = ''.$lt{'crl'}.' '.
+ my $header = ''.&mt('Course Level').' '.
''.$courseform.' '.$lt{'rol'}.' '.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' ';
- my $otheritems = ' '.
+ my $otheritems = ' '."\n".
''."\n";
- foreach ('st','ta','ep','ad','in','cc') {
+ foreach ('st','ta','ep','in','cc') {
my $plrole=&Apache::lonnet::plaintext($_);
$otheritems .= ' '.$plrole;
}
@@ -1781,7 +1917,8 @@ sub course_level_dc {
' <--'.&mt('Pick course first').' '.
' '.
' '.$lt{'new'}.' '.
- ' '.
+ ' '.
+ ' '.
'
';
$otheritems .= <