--- loncom/interface/lonuserutils.pm 2010/11/15 17:57:35 1.109.2.10
+++ loncom/interface/lonuserutils.pm 2012/04/25 21:22:01 1.138
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.109.2.10 2010/11/15 17:57:35 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.138 2012/04/25 21:22:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,6 @@ use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::longroup;
-use Apache::lonnavmaps;
use LONCAPA qw(:DEFAULT :match);
###############################################################
@@ -296,7 +295,7 @@ sub hidden_input {
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,$formname,
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,
$can_assign)=@_;
my $javascript;
#
@@ -327,32 +326,9 @@ sub print_upload_manager_header {
$password_choice = 'int';
}
#
- my ($sectionjs,$groupslist);
+ my $groupslist;
if ($context eq 'course') {
$groupslist = &get_groupslist();
- if ($env{'form.context'} eq 'requestcrs') {
- $sectionjs = <<"ENDJS";
-
-function toggleSectionsDefault() {
- var usingsecs;
- if (document.$formname.usesection.length > 1) {
- for (var i=0; i '
.&mt('Change authentication for existing users in domain "[_1]" to these settings?'
@@ -905,17 +857,12 @@ sub print_upload_manager_footer {
.' '."\n".
- &mt('This will not take effect if the user already exists.');
- my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($defdom);
- if ($authnum > 1) {
- $Str .= &Apache::loncommon::help_open_topic('Auth_Options');
- }
- $Str .= " \n".$date_table." \n".$date_table."'.
&mt('Identify fields in uploaded list')."
\n");
- $r->print(&mt('Enter as many fields as you can.').'
'.
- &mt('The system will inform you and bring you back to this page,').
- '
'.&mt('if the data selected are insufficient to add users.')."
\n");
+ $r->print(&mt('Enter as many fields as you can.
The system will inform you and bring you back to this page,
if the data selected are insufficient to add users.')."
\n");
$r->print(&hidden_input('action','upload').
&hidden_input('state','got_file').
&hidden_input('associate','').
&hidden_input('datatoken',$datatoken).
&hidden_input('fileupload',$env{'form.fileupload'}).
&hidden_input('upfiletype',$env{'form.upfiletype'}).
- &hidden_input('upfile_associate',$env{'form.upfile_associate'}).
- &hidden_input('context',$env{'form.context'}));
+ &hidden_input('upfile_associate',$env{'form.upfile_associate'}));
$r->print('
');
$r->print('
print("
\n".
'');
}
@@ -415,13 +388,9 @@ sub javascript_validations {
if ($context eq 'course') {
if ($env{'request.course.sec'} eq '') {
$setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');';
- if ($env{'form.context'} eq 'requestcrs') {
- $setsections_js = &newsections_javascript($param{'formname'});
- } else {
- $setsections_js =
- &setsections_javascript($param{'formname'},$groupslist,
- $mode,'',$crstype);
- }
+ $setsections_js =
+ &setsections_javascript($param{'formname'},$groupslist,
+ $mode,'',$crstype);
} else {
$setsection_call = "'ok'";
}
@@ -549,9 +518,7 @@ END
END
} else {
$section_checks = §ion_check_js();
-
- unless ($env{'form.context'} eq 'requestcrs') {
- $optional_checks = (<'.&mt('Options').'
'
.&Apache::lonhtmlcommon::start_pick_box();
- if ($env{'form.context'} eq 'requestcrs') {
- $Str .= &Apache::lonhtmlcommon::row_title(&mt('Default password'));
- } else {
- $Str .= &Apache::lonhtmlcommon::row_title(&mt('Login Type'));
- }
+
+ $Str .= &Apache::lonhtmlcommon::row_title(&mt('Login Type'));
if ($context eq 'domain') {
$Str .= '
'.
- &mt('Will you be using sections?').' '.
- ''.
- ' '.&mt('Yes').''.
- ' ';
- } else {
- $Str .= &Apache::lonhtmlcommon::row_title(
+ $Str .= &Apache::lonhtmlcommon::row_title(
&mt('Default role and section'))
- .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.');
- }
+ .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.');
} else {
$Str .= &Apache::lonhtmlcommon::row_title(
&mt('Default role and/or section(s)'))
@@ -997,22 +931,11 @@ sub print_upload_manager_footer {
}
} else {
my ($cnum,$cdom) = &get_course_identity();
- my ($rowtitle,$closure);
- if ($env{'form.context'} eq 'requestcrs') {
- $closure = 1;
- $rowtitle = &mt('default section name (letters/numbers only)');
- } else {
- $rowtitle = &mt('section');
- }
+ my $rowtitle = &mt('section');
my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle,
- $permission,$context,'upload',$crstype,
- $env{'form.context'}).
- &Apache::lonhtmlcommon::row_closure($closure);
- if ($env{'form.context'} eq 'requestcrs') {
- $Str .= ''.$secbox.'
'
- .$lt{'stus'}
- .&Apache::lonhtmlcommon::row_closure();
- }
+ $Str .= &Apache::lonhtmlcommon::row_title(&mt('Full Update'))
+ .'
'
+ .$lt{'stus'}
+ .&Apache::lonhtmlcommon::row_closure();
}
if ($context eq 'course' || $context eq 'domain') {
- unless ($env{'form.context'} eq 'requestcrs') {
- $Str .= &forceid_change($context);
- }
+ $Str .= &forceid_change($context);
}
$Str .= &Apache::lonhtmlcommon::end_pick_box();
@@ -1081,7 +1000,7 @@ sub forceid_change {
###############################################################
###############################################################
sub print_upload_manager_form {
- my ($r,$context,$permission,$crstype,$formname) = @_;
+ my ($r,$context,$permission,$crstype) = @_;
my $firstLine;
my $datatoken;
if (!$env{'form.datatoken'}) {
@@ -1129,13 +1048,12 @@ sub print_upload_manager_form {
#
my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($defdom);
&print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context,
- $permission,$crstype,$formname,\%can_assign);
+ $permission,$crstype,\%can_assign);
my $i;
my $keyfields;
if ($total>=0) {
my @field=
(['username',&mt('Username'), $env{'form.username_choice'}],
- ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
['names',&mt('Last Name, First Names'),$env{'form.names_choice'}],
['fname',&mt('First Name'), $env{'form.fname_choice'}],
['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}],
@@ -1143,6 +1061,7 @@ sub print_upload_manager_form {
['gen', &mt('Generation'), $env{'form.gen_choice'}],
['id', &mt('Student/Employee ID'),$env{'form.id_choice'}],
['sec', &mt('Section'), $env{'form.sec_choice'}],
+ ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
['email',&mt('E-mail Address'), $env{'form.email_choice'}],
['role',&mt('Role'), $env{'form.role_choice'}],
['domain',&mt('Domain'), $env{'form.domain_choice'}],
@@ -1335,10 +1254,8 @@ sub default_role_selector {
'exs' => "Existing sections",
'new' => "New section",
);
- $options = '
' + .&list_submit_button(&mt('Update Display')) + ."
\n" + ); } my ($indexhash,$keylist) = &make_keylist_array(); my (%userlist,%userinfo,$clearcoursepick); @@ -1620,9 +1542,11 @@ sub print_userlist { $title = &mt('Select Communities'); $warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.'); } + my @standardnames = &Apache::loncommon::get_standard_codeitems(); my $courseform = &Apache::lonhtmlcommon::course_selection($formname,$numcodes, - $codetitles,$idlist,$idlist_titles,$crstype); + $codetitles,$idlist,$idlist_titles,$crstype, + \@standardnames); $r->print(''.&Apache::lonhtmlcommon::start_pick_box()."\n".
&Apache::lonhtmlcommon::start_pick_box()."\n".
&Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n".
@@ -1840,7 +1764,7 @@ sub role_filter {
$role_select .= '';
$output = '';
+ .' ';
}
return $output;
}
@@ -1880,7 +1804,7 @@ sub section_group_filter {
}
if (@options > 0) {
my $currsel;
- $markup = ''.$lt{'owin'}.' ';
+ $output .= ''.$lt{'owin'}.' ';
}
$output .= "\n".' '."\n".
&Apache::loncommon::start_data_table().
@@ -2584,32 +2491,27 @@ END
}
}
foreach my $item (@cols) {
- if (grep(/^\Q$item\E$/,@sortable)) {
- $output .= "$lt{$item} \n";
- } else {
- $output .= "$lt{$item} \n";
- }
+ $output .= "$lt{$item} \n";
}
my %role_types = &role_type_names();
if ($context eq 'course' && $mode ne 'autoenroll') {
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
# Clicker display on or off?
- if ($clickersupport) {
- my %clicker_options = (
- 'on' => 'Show',
- 'off' => 'Hide',
- );
- my $clickerchg = 'on';
- if ($displayclickers eq 'on') {
- $clickerchg = 'off';
- }
- $output .= ' '."\n".' '
- .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'
+ my %clicker_options = (
+ 'on' => 'Show',
+ 'off' => 'Hide',
+ );
+ my $clickerchg = 'on';
+ if ($displayclickers eq 'on') {
+ $clickerchg = 'off';
+ }
+ $output .= ' '."\n".' '
+ .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'
,''
,'')
."\n".' '."\n";
- }
+
# Photo display on or off?
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
my %photo_options = &Apache::lonlocal::texthash(
@@ -2648,18 +2550,14 @@ END
$CSVfile = undef;
}
#
- if ($clickersupport) {
- push @cols,'clicker';
- }
+ push @cols,'clicker';
# Write headers and data to file
print $CSVfile '"'.$results_description.'"'."\n";
print $CSVfile '"'.join('","',map {
&Apache::loncommon::csv_translate($lt{$_})
} (@cols))."\"\n";
} elsif ($mode eq 'excel') {
- if ($clickersupport) {
- push @cols,'clicker';
- }
+ push @cols,'clicker';
# Create the excel spreadsheet
($excel_workbook,$excel_filename,$format) =
&Apache::loncommon::create_workbook($r);
@@ -2695,40 +2593,6 @@ END
Future => 'Future',
Expired => 'Expired',
);
- # If this is for a single course get last course "log-in" and submissions.
- my (%crslogins,%stusubmissions,%elapsed,$numparts,%nummultipart,$multipart);
- my $now = time;
- if ($context eq 'course') {
- if ($custommenu) {
- %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);
- %stusubmissions=&Apache::lonnet::dump('nohist_submissiontracker',$cdom,$cnum);
- %elapsed = &Apache::lonlocal::texthash(
- -1 => 'more than a month ago',
- 2592000 => 'within last 30 days',
- 604800 => 'within last 7 days',
- 86400 => 'within last 24 hours',
- );
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (defined($navmap)) {
- my @allres=$navmap->retrieveResources('/uploaded/'.$cdom.'/'.$cnum.'/default_1261144274.sequence',sub { $_[0]->is_problem() },0);
- foreach my $resource (@allres) {
- my @parts = $resource->parts();
- my $count = scalar(@parts);
- if ($count > 1) {
- $nummultipart{$count} ++;
- }
- $numparts += $count;
- }
- if (keys(%nummultipart) > 0) {
- $multipart = '
'.'contains';
- foreach my $key (sort {$a <=> $b} keys(%nummultipart)) {
- $multipart .= " nummultipart{$key} multipart questions (with $key parts)";
- }
- }
- }
- }
- }
-
# Get groups, role, permanent e-mail so we can sort on them if
# necessary.
foreach my $user (keys(%{$userlist})) {
@@ -2865,42 +2729,16 @@ END
$in{'clicker'} = $clickers;
my $role = $in{'role'};
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype);
- if (! defined($in{'start'}) || $in{'start'} == 0) {
- $in{'start'} = &mt('none');
- } else {
- $in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'});
- }
- if (! defined($in{'end'}) || $in{'end'} == 0) {
- $in{'end'} = &mt('none');
- } else {
- $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
- }
- if ($context eq 'course') {
- if ($custommenu) {
- my $lastlogin = $crslogins{$in{'username'}.':'.$in{'domain'}.':'.$in{'section'}.':'.$role};
- if ($lastlogin ne '') {
- my $sincelogin = $now - $lastlogin;
- if ($sincelogin < 86400) {
- $in{'lastlogin'} = $elapsed{'86400'};
- } elsif ($sincelogin < 604800) {
- $in{'lastlogin'} = $elapsed{'604800'};
- } elsif ($sincelogin < 2592000 ) {
- $in{'lastlogin'} = $elapsed{'2592000'};
- } else {
- $in{'lastlogin'} = $elapsed{'-1'};
- }
- }
+ unless ($mode eq 'excel') {
+ if (! defined($in{'start'}) || $in{'start'} == 0) {
+ $in{'start'} = &mt('none');
+ } else {
+ $in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'});
}
- if ($role eq 'st') {
- my $numsub = $stusubmissions{$in{'username'}.':'.$in{'domain'}."\0attempts"} +
- $stusubmissions{$in{'username'}.':'.$in{'domain'}."\0surveysubs"};
- if (!$numsub) {
- $in{'submissions'} = 'not attempted';
- } elsif ($numsub < $numparts) {
- $in{'submissions'} = 'incomplete ('.$numsub.'/'.$numparts.')';
- } else {
- $in{'submissions'} = 'completed';
- }
+ if (! defined($in{'end'}) || $in{'end'} == 0) {
+ $in{'end'} = &mt('none');
+ } else {
+ $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
}
}
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
@@ -2976,27 +2814,19 @@ END
$showitem = $ltstatus{$in{$item}};
}
$r->print(''.$showitem.' '."\n");
- } elsif ($item eq 'submissions') {
- if ($in{$item} =~ /^incomplete/) {
- $r->print(''.$in{$item}.$multipart.' ');
- } else {
- $r->print(''.$in{$item}.' '."\n");
- }
} else {
$r->print(''.$in{$item}.' '."\n");
}
}
if (($context eq 'course') && ($mode ne 'autoenroll')) {
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
- if ($clickersupport) {
- if ($displayclickers eq 'on') {
- my $clickers =
+ if ($displayclickers eq 'on') {
+ my $clickers =
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
- if ($clickers!~/\w/) { $clickers='-'; }
- $r->print(''.$clickers.' ');
- } else {
- $r->print(' ');
- }
+ if ($clickers!~/\w/) { $clickers='-'; }
+ $r->print(''.$clickers.' ');
+ } else {
+ $r->print(' ');
}
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {
@@ -3011,16 +2841,6 @@ END
} elsif ($mode eq 'csv') {
next if (! defined($CSVfile));
# no need to bother with $linkto
- if (! defined($in{'start'}) || $in{'start'} == 0) {
- $in{'start'} = &mt('none');
- } else {
- $in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'});
- }
- if (! defined($in{'end'}) || $in{'end'} == 0) {
- $in{'end'} = &mt('none');
- } else {
- $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
- }
my @line = ();
foreach my $item (@cols) {
push @line,&Apache::loncommon::csv_translate($in{$item});
@@ -3030,9 +2850,9 @@ END
my $col = 0;
foreach my $item (@cols) {
if ($item eq 'start' || $item eq 'end') {
- if (defined($item) && $item != 0) {
+ if ((defined($in{$item})) && ($in{$item} != 0)) {
$excel_sheet->write($row,$col++,
- &Apache::lonstathelpers::calc_serial($in{item}),
+ &Apache::lonstathelpers::calc_serial($in{$item}),
$format->{'date'});
} else {
$excel_sheet->write($row,$col++,'none');
@@ -3187,7 +3007,7 @@ sub print_username_link {
$output = $in->{'username'};
} else {
$output = '{'username'}','$in->{'domain'}'".')" />'.
+ "'$in->{'username'}','$in->{'domain'}'".')">'.
$in->{'username'}.'';
}
return $output;
@@ -3417,9 +3237,9 @@ ENDJS
my %lt = &Apache::lonlocal::texthash (
chac => 'Access dates to apply for selected users',
chse => 'Changes in section affiliation to apply to selected users',
- fors => 'For student roles changing the section, will result in a section switch as students may only be in one section of a course at a time.',
- forn => 'For a role in a course that is not a student role, a user may have roles in more than one section of a course at a time.',
- reta => "Retain each user's current section affiliations?",
+ fors => 'For student roles, changing the section will result in a section switch as students may only be in one section of a course at a time.',
+ forn => 'For a course role that is not "student", users may have roles in more than one section at a time.',
+ reta => "Retain each user's current section affiliations?",
dnap => '(Does not apply to student roles).',
);
my ($date_items,$headertext);
@@ -3437,14 +3257,13 @@ ENDJS
$permission,$crstype);
}
$output .= ''.$headertext.'
'.
- '
\n".&mt('Processed [quant,_1,user].',$counts{'user'}). "
\n"); if ($counts{'role'} > 0) { - if (&Apache::loncommon::needs_gci_custom()) { - $r->print("\n". - &mt('[quant,_1,student] enrolled in Concept Test.',$counts{'role'}). - "
\n"); - } else { - $r->print("\n". - &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.&mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.')."
\n"); - } + $r->print("\n". + &mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.&mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.')."
\n"); } else { - if (&Apache::loncommon::needs_gci_custom()) { - $r->print(''.&mt('No students enrolled').'
'); - } else { - $r->print(''.&mt('No roles added').'
'); - } + $r->print(''.&mt('No roles added').'
'); } if ($counts{'auth'} > 0) { $r->print("\n".
@@ -4735,10 +4508,9 @@ sub print_drop_menu {
# ================================================================== Phase four
sub update_user_list {
- my ($r,$context,$setting,$choice) = @_;
+ my ($r,$context,$setting,$choice,$crstype) = @_;
my $now = time;
my $count=0;
- my $crstype;
if ($context eq 'course') {
$crstype = &Apache::loncommon::course_type();
}
@@ -4753,7 +4525,7 @@ sub update_user_list {
'reenable' => 'Re-enabled',
'activate' => 'Activated',
'chgdates' => 'Changed Access Dates for',
- 'chgsec' => 'Changed section for',
+ 'chgsec' => 'Changed section(s) for',
'drop' => 'Dropped',
},
error => {'revoke' => 'revoking',
@@ -4770,8 +4542,9 @@ 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);
+ my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype,
+ @sections,$scopestem,$singlesec,$showsecs,$warn_singlesec,
+ $nothingtodo,$keepnosection);
if ($choice eq 'drop') {
($uname,$udom,$sec) = split(/:/,$item,-1);
$role = 'st';
@@ -4870,14 +4643,23 @@ sub update_user_list {
} elsif ($choice eq 'chgsec') {
my (@newsecs,$revresult,$nochg,@retained);
if (($role ne 'cc') && ($role ne 'co')) {
- @newsecs = split(/,/,$env{'form.newsecs'});
+ 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);
+ }
+ }
}
# remove existing section if not to be retained.
- if (!$env{'form.retainsec'}) {
+ if (!$env{'form.retainsec'} || ($role eq 'st')) {
if ($sec eq '') {
if (@newsecs == 0) {
- $result = &mt('No change in section assignment (none)');
+ $result = 'ok';
$nochg = 1;
+ $nothingtodo = 1;
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
@@ -4904,13 +4686,23 @@ sub update_user_list {
} else {
if ($sec eq '') {
$nochg = 1;
- } else {
+ $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) {
+ if ($nochg) {
+ $result = 'ok';
+ $nothingtodo = 1;
+ } else {
if ($role eq 'st') {
$result =
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid,'',$context);
@@ -4919,22 +4711,58 @@ 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) {
+ 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);
+
}
}
}
}
+ unless ($role eq 'st') {
+ unless ($showsecs) {
+ my @tolist = sort(@shownew,@retained);
+ if ($keepnosection) {
+ push(@tolist,&mt('No section'));
+ }
+ $showsecs = join(', ',@tolist);
+ }
+ }
}
}
my $extent = $scope;
@@ -4945,13 +4773,48 @@ sub update_user_list {
}
}
if ($result eq 'ok' || $result eq 'ok:') {
- $r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for [_3]",
- $plrole,$extent,$uname.':'.$udom).'
');
- $count++;
+ 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('