'
@@ -3807,7 +3803,7 @@ sub upfile_drop_add {
} elsif ($setting eq 'course') {
$defaultrole = $env{'form.courserole'};
$defaultsec = $env{'form.sections'};
- }
+ }
} elsif ($context eq 'author') {
$defaultrole = $env{'form.defaultrole'};
} elsif ($context eq 'course') {
@@ -4159,7 +4155,7 @@ sub upfile_drop_add {
$role = 'cr_'.$env{'user.domain'}.'_'.
$env{'user.name'}.'_'.$role;
}
- if (($role ne 'cc') && ($role ne 'co')) {
+ if (($role ne 'cc') && ($role ne 'co')) {
if (@secs > 1) {
$multiple = 1;
foreach my $sec (@secs) {
@@ -4386,9 +4382,10 @@ sub print_drop_menu {
# ================================================================== Phase four
sub update_user_list {
- my ($r,$context,$setting,$choice,$crstype) = @_;
+ my ($r,$context,$setting,$choice) = @_;
my $now = time;
my $count=0;
+ my $crstype;
if ($context eq 'course') {
$crstype = &Apache::loncommon::course_type();
}
@@ -4403,7 +4400,7 @@ sub update_user_list {
'reenable' => 'Re-enabled',
'activate' => 'Activated',
'chgdates' => 'Changed Access Dates for',
- 'chgsec' => 'Changed section(s) for',
+ 'chgsec' => 'Changed section for',
'drop' => 'Dropped',
},
error => {'revoke' => 'revoking',
@@ -4420,9 +4417,8 @@ sub update_user_list {
($startdate,$enddate) = &get_dates_from_form();
}
foreach my $item (@changelist) {
- my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype,
- @sections,$scopestem,$singlesec,$showsecs,$warn_singlesec,
- $nothingtodo,$keepnosection);
+ my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype,@sections,
+ $scopestem);
if ($choice eq 'drop') {
($uname,$udom,$sec) = split(/:/,$item,-1);
$role = 'st';
@@ -4521,23 +4517,14 @@ sub update_user_list {
} elsif ($choice eq 'chgsec') {
my (@newsecs,$revresult,$nochg,@retained);
if (($role ne 'cc') && ($role ne 'co')) {
- my @secs = sort(split(/,/,$env{'form.newsecs'}));
- if (@secs) {
- my %curr_groups = &Apache::longroup::coursegroups();
- foreach my $sec (@secs) {
- next if (($sec =~ /\W/) || ($sec eq 'none') ||
- (exists($curr_groups{$sec})));
- push(@newsecs,$sec);
- }
- }
+ @newsecs = split(/,/,$env{'form.newsecs'});
}
# remove existing section if not to be retained.
- if (!$env{'form.retainsec'} || ($role eq 'st')) {
+ if (!$env{'form.retainsec'}) {
if ($sec eq '') {
if (@newsecs == 0) {
- $result = 'ok';
+ $result = &mt('No change in section assignment (none)');
$nochg = 1;
- $nothingtodo = 1;
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
@@ -4564,23 +4551,13 @@ sub update_user_list {
} else {
if ($sec eq '') {
$nochg = 1;
- $keepnosection = 1;
} else {
push(@retained,$sec);
}
}
# add new sections
- my (@diffs,@shownew);
- if (@retained) {
- @diffs = &Apache::loncommon::compare_arrays(\@retained,\@newsecs);
- } else {
- @diffs = @newsecs;
- }
if (@newsecs == 0) {
- if ($nochg) {
- $result = 'ok';
- $nothingtodo = 1;
- } else {
+ if (!$nochg) {
if ($role eq 'st') {
$result =
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid,'',$context);
@@ -4589,41 +4566,15 @@ sub update_user_list {
$result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start,'','',$context);
}
}
- $showsecs = &mt('No section');
- } elsif (@diffs == 0) {
- $result = 'ok';
- $nothingtodo = 1;
} else {
foreach my $newsec (@newsecs) {
if (!grep(/^\Q$newsec\E$/,@retained)) {
if ($role eq 'st') {
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context);
- if (@newsecs > 1) {
- my $showsingle;
- if ($newsec eq '') {
- $showsingle = &mt('No section');
- } else {
- $showsingle = $newsec;
- }
- if ($crstype eq 'Community') {
- $warn_singlesec = &mt('Although more than one section was indicated, a role was only added for the first section - [_1], as each community member may only be in one section at a time.','
'.$showsingle.'');
- } else {
- $warn_singlesec = &mt('Although more than one section was indicated, a role was only added for the first section - [_1], as each student may only be in one section of a course at a time.','
'.$showsingle.'');
- }
- $showsecs = $showsingle;
- last;
- } else {
- if ($newsec eq '') {
- $showsecs = &mt('No section');
- } else {
- $showsecs = $newsec;
- }
- }
} else {
my $newscope = $scopestem;
if ($newsec ne '') {
$newscope .= '/'.$newsec;
- push(@shownew,$newsec);
}
$result = &Apache::lonnet::assignrole($udom,$uname,
$newscope,$role,$end,$start);
@@ -4631,15 +4582,6 @@ sub update_user_list {
}
}
}
- unless ($role eq 'st') {
- unless ($showsecs) {
- my @tolist = sort(@shownew,@retained);
- if ($keepnosection) {
- push(@tolist,&mt('No section'));
- }
- $showsecs = join(', ',@tolist);
- }
- }
}
}
my $extent = $scope;
@@ -4650,48 +4592,13 @@ sub update_user_list {
}
}
if ($result eq 'ok' || $result eq 'ok:') {
- my $dates;
- if (($choice eq 'chgsec') || ($choice eq 'chgdates')) {
- $dates = &dates_feedback($start,$end,$now);
- }
- if ($choice eq 'chgsec') {
- if ($nothingtodo) {
- $r->print(&mt("Section assignment for role of '[_1]' in [_2] for '[_3]' unchanged.",$plrole,$extent,'
'.
- &Apache::loncommon::plainname($uname,$udom).
- '').' ');
- if ($sec eq '') {
- $r->print(&mt('[_1]No section[_2] - [_3]','
','',$dates));
- } else {
- $r->print(&mt('Section(s): [_1] - [_2]',
- '
'.$showsecs.'',$dates));
- }
- $r->print('
');
- } else {
- $r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for '[_3]' to [_4] - [_5]",$plrole,$extent,
- '
'.&Apache::loncommon::plainname($uname,$udom).'',
- '
'.$showsecs.'',$dates).'
');
- $count ++;
- }
- if ($warn_singlesec) {
- $r->print('
'.$warn_singlesec.'
');
- }
- } elsif ($choice eq 'chgdates') {
- $r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for '[_3]' - [_4]",$plrole,$extent,
- '
'.&Apache::loncommon::plainname($uname.':'.$udom).'',
- $dates).'
');
- $count ++;
- } else {
- $r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for '[_3]'.",$plrole,$extent,
- '
'.&Apache::loncommon::plainname($uname.':'.$udom).'').
- '
');
- $count ++;
- }
+ $r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for [_3]",
+ $plrole,$extent,$uname.':'.$udom).'
');
+ $count++;
} else {
$r->print(
- &mt("Error $result_text{'error'}{$choice} [_1] in [_2] for '[_3]': [_4].",
- $plrole,$extent,
- '
'.&Apache::loncommon::plainname($uname.':'.$udom).'',
- $result).'
');
+ &mt("Error $result_text{'error'}{$choice} [_1] in [_2] for [_3]: [_4].",
+ $plrole,$extent,$uname.':'.$udom,$result).'
');
}
}
$r->print('
'."\n");
}
-sub dates_feedback {
- my ($start,$end,$now) = @_;
- my $dates;
- if ($start < $now) {
- if ($end == 0) {
- $dates .= &mt('role(s) active now; no end date');
- } elsif ($end > $now) {
- $dates = &mt('role(s) active now; ends [_1].',&Apache::lonlocal::locallocaltime($end));
- } else {
- $dates = &mt('role(s) expired: [_1].',&Apache::lonlocal::locallocaltime($end));
- }
- } else {
- if ($end == 0 || $end > $now) {
- $dates = &mt('future role(s); starts: [_1].',&Apache::lonlocal::locallocaltime($start));
- } else {
- $dates = &mt('role(s) expired: [_1].',&Apache::lonlocal::locallocaltime($end));
- }
- }
- return $dates;
-}
-
sub classlist_drop {
my ($scope,$uname,$udom,$now) = @_;
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
@@ -4928,7 +4814,7 @@ sub setsections_javascript {
accr => 'A course coordinator role will be added with access to all sections.',
acor => 'A coordinator role will be added with access to all sections',
inea => 'In each course, each user may only have one student role at a time.',
- inec => 'In each community, each user may only have one member role at a time.',
+ inec => 'In each community, each user may only have on member role at a time.',
youh => 'You had selected ',
secs => 'sections.',
plmo => 'Please modify your selections so they include no more than one section.',
@@ -4936,21 +4822,16 @@ sub setsections_javascript {
plch => 'Please choose a different section name.',
mnot => 'may not be used as a section name, as it is the name of a course group.',
secn => 'Section names and group names must be distinct. Please choose a different section name.',
- nonw => 'Section names may only contain letters or numbers.',
);
$setsection_js .= <<"ENDSECCODE";
function setSections(formname,crstype) {
var re1 = /^currsec_/;
- var re2 =/\\W/;
- var trimleading = /^\\s+/;
- var trimtrailing = /\\s+\$/;
var groups = new Array($groupslist);
for (var i=0;i
0) {
- alert("$alerts{'nonw'}\\n$alerts{'plch'}");
- return;
+ }
+ if (numsec > 0) {
+ if (formname.elements[i+1].value != "" && formname.elements[i+1].value != null) {
+ sections = sections + "," + formname.elements[i+1].value;
}
- numsec = numsec + validsecs.length;
}
+ else {
+ sections = formname.elements[i+1].value;
+ }
+ var newsecs = formname.elements[i+1].value;
+ var numsplit;
+ if (newsecs != null && newsecs != "") {
+ numsplit = newsecs.split(/,/g);
+ numsec = numsec + numsplit.length;
+ }
+
if ((role == 'st') && (numsec > 1)) {
if (crstype == 'Community') {
alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
@@ -5023,36 +4882,25 @@ function setSections(formname,crstype) {
alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
}
return;
- } else {
- if (validsecs != null) {
- for (var j=0; j 'You must select a course or community in the current domain',
inea => 'In each course, each user may only have one student role at a time',
- inco => 'In each community, each user may only have one member role at a time',
+ inco => 'In each community, each user may only have one member role at a time',
youh => 'You had selected',
sect => 'sections',
plsm => 'Please modify your selections so they include no more than one section',