--- loncom/interface/lonuserutils.pm 2010/11/15 17:57:35 1.109.2.10
+++ loncom/interface/lonuserutils.pm 2013/01/23 17:48:37 1.147
@@ -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.147 2013/01/23 17:48:37 bisitz 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,66 +326,55 @@ 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('Total number of records found in file: [_1]'
- ,''.$distotal.'')
- ." '.
+ &mt('Total number of records found in file: [_1]'
+ ,''.$distotal.'').
+ " '.&mt('None found').' '.
+ &mt('Enter as many fields as you can.').' '
.&mt('Change authentication for existing users in domain "[_1]" to these settings?'
@@ -905,17 +872,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('Identify fields in uploaded list')."
\n".
+ '
'.
+ &mt('The system will inform you and bring you back to this page,[_1]if the data selected are insufficient to add users.','
').
+ "
');
- $r->print('
print(
+ '
'
+ );
+ $r->print(
+ ''
+ );
}
###############################################################
@@ -415,13 +403,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 +533,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 +946,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 +1015,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 +1063,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 +1076,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'}],
@@ -1163,7 +1097,6 @@ sub print_upload_manager_form {
$keyfields=join(',',sort(keys(%sone)));
}
}
- $r->print('');
&print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,
$context,$permission,$crstype);
}
@@ -1335,10 +1268,8 @@ sub default_role_selector {
'exs' => "Existing sections",
'new' => "New section",
);
- $options = '
'.&Apache::lonhtmlcommon::start_pick_box()."\n". &Apache::lonhtmlcommon::start_pick_box()."\n". &Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n". @@ -1638,10 +1582,10 @@ sub print_userlist { $clearcoursepick = 1; } if (($env{'form.coursepick'}) && (!$clearcoursepick)) { - $r->print('
'."\n") if $msg;
} else {
# Print out the available choices
my $usercount;
@@ -1787,7 +1733,7 @@ sub print_userlist {
$permission,$env{'form.Status'},\%userlist,$keylist);
}
if (!$usercount) {
- $r->print('
'
+ $r->print('
'
.&mt('There are no users matching the search criteria.')
.''
);
@@ -1795,6 +1741,7 @@ sub print_userlist {
}
$r->print('');
+ return;
}
sub role_filter {
@@ -1807,11 +1754,11 @@ sub role_filter {
my ($role_select);
if ($context eq 'domain') {
$role_select = &domain_roles_select();
- $output = '';
+ .'';
} else {
- $role_select = '
');
+ $r->print(''.$results_description.'
');
}
my ($output,$actionselect,%canchange,%canchangesec);
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
@@ -2536,6 +2555,12 @@ END
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
$canchangesec{$role} = $env{'request.course.sec'};
}
+ } elsif ((($role eq 'co') && ($crstype eq 'Community')) ||
+ (($role eq 'cc') && ($crstype eq 'Course'))) {
+ if (&is_courseowner($env{'request.course.id'},
+ $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'})) {
+ $canchange{$role} = 1;
+ }
}
}
}
@@ -2568,9 +2593,13 @@ END
if ($env{'form.userwin'}) {
$checkwin = ' checked="checked"';
}
- $output .= ''.$lt{'owin'}.' ';
+ $output .=
+ ''
+ .' ';
}
- $output .= "\n".' '."\n".
+ $output .= "\n".'
'."\n".
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row();
if ($mode eq 'autoenroll') {
@@ -2584,50 +2613,9 @@ 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'
- ,''
- ,'')
- ."\n".' '."\n";
- }
- # Photo display on or off?
- if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
- my %photo_options = &Apache::lonlocal::texthash(
- 'on' => 'Show',
- 'off' => 'Hide',
- );
- my $photochg = 'on';
- if ($displayphotos eq 'on') {
- $photochg = 'off';
- }
- $output .= ' '."\n".' '.
- ''.
- $photo_options{$photochg}.' '.$lt{'photo'}."\n".
- ' '."\n";
- }
- }
- }
$output .= &Apache::loncommon::end_data_table_header_row();
# Done with the HTML header line
} elsif ($mode eq 'csv') {
@@ -2648,18 +2636,12 @@ END
$CSVfile = undef;
}
#
- if ($clickersupport) {
- 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';
- }
# Create the excel spreadsheet
($excel_workbook,$excel_filename,$format) =
&Apache::loncommon::create_workbook($r);
@@ -2695,40 +2677,11 @@ 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 this is for a single course get last course "log-in".
+ my %crslogins;
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)";
- }
- }
- }
- }
+ %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);
}
-
# Get groups, role, permanent e-mail so we can sort on them if
# necessary.
foreach my $user (keys(%{$userlist})) {
@@ -2812,7 +2765,7 @@ END
}
}
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
- if (($displayphotos eq 'on') && ($role eq 'st')) {
+ if ((grep/^photo$/,@cols) && ($role eq 'st')) {
$userlist->{$user}->[$index{'photo'}] =
&Apache::lonnet::retrievestudentphoto($udom,$uname,'jpg');
$userlist->{$user}->[$index{'thumbnail'}] =
@@ -2865,42 +2818,22 @@ 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'});
+ unless ($mode eq 'excel') {
+ 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'};
- }
- }
- }
- 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';
- }
+ my $lastlogin = $crslogins{$in{'username'}.':'.$in{'domain'}.':'.$in{'section'}.':'.$role};
+ if ($lastlogin ne '') {
+ $in{'lastlogin'} = &Apache::lonlocal::locallocaltime($lastlogin);
}
}
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
@@ -2947,17 +2880,26 @@ END
if ($showcheckbox) {
$checkval = $user;
if ($context eq 'course') {
- if ($role eq 'st') {
- $checkval .= ':st';
- }
- $checkval .= ':'.$in{'section'};
- if ($role eq 'st') {
- $checkval .= ':'.$in{'type'}.':'.
- $in{'lockedtype'};
- }
+ if (($role eq 'co' || $role eq 'cc') &&
+ ($user =~ /^\Q$env{'user.name'}:$env{'user.domain'}:$role\E/)) {
+ $showcheckbox = 0;
+ } else {
+ if ($role eq 'st') {
+ $checkval .= ':st';
+ }
+ $checkval .= ':'.$in{'section'};
+ if ($role eq 'st') {
+ $checkval .= ':'.$in{'type'}.':'.
+ $in{'lockedtype'};
+ }
+ }
+ }
+ if ($showcheckbox) {
+ $r->print('');
+ } else {
+ $r->print(' ');
}
- $r->print('');
} else {
$r->print(' ');
}
@@ -2976,51 +2918,34 @@ 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') {
+ } elsif ($item eq 'photo') {
+ if (($context eq 'course') && ($mode ne 'autoenroll') &&
+ ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) {
+ if ($role eq 'st') {
+ $r->print('');
+ } else {
+ $r->print(' ');
+ }
+ }
+ } elsif ($item eq 'clicker') {
+ if (($context eq 'course') && ($mode ne 'autoenroll')) {
+ if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
my $clickers =
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
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 '') {
- $r->print(' ');
- } else {
- $r->print(' ');
- }
- }
+ $r->print(' '."\n");
+ }
+ }
+ } else {
+ $r->print(''.$in{$item}.' '."\n");
}
}
$r->print(&Apache::loncommon::end_data_table_row());
} 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 +2955,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 +3112,7 @@ sub print_username_link {
$output = $in->{'username'};
} else {
$output = '{'username'}','$in->{'domain'}'".')" />'.
+ "'$in->{'username'}','$in->{'domain'}'".')">'.
$in->{'username'}.'';
}
return $output;
@@ -3220,15 +3145,20 @@ sub select_actions {
}
if ($context eq 'course') {
if ($env{'form.showrole'} ne 'Any') {
- if (!&Apache::lonnet::allowed('c'.$env{'form.showrole'},
- $env{'request.course.id'})) {
- if ($env{'request.course.sec'} eq '') {
- return;
- } else {
- if (!&Apache::lonnet::allowed('c'.$env{'form.showrole'},$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- return;
- }
- }
+ my $showactions;
+ if (&Apache::lonnet::allowed('c'.$env{'form.showrole'},
+ $env{'request.course.id'})) {
+ $showactions = 1;
+ } elsif ($env{'request.course.sec'} ne '') {
+ if (&Apache::lonnet::allowed('c'.$env{'form.showrole'},$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $showactions = 1;
+ }
+ }
+ unless ($showactions) {
+ unless (&is_courseowner($env{'request.course.id'},
+ $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'})) {
+ return;
+ }
}
}
}
@@ -3417,9 +3347,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 +3367,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". @@ -4596,7 +4483,7 @@ sub upfile_drop_add { if (! defined($classlist)) { $r->print('
'. ''. - &mt('There are no students with current/future access to the course.'). + ''.&mt('There are no students with current/future access to the course.').'
'. ''."\n"); } elsif (ref($classlist) eq 'HASH') { # Remove the students we just added from the list of students. @@ -4720,11 +4607,13 @@ sub print_drop_menu { ''."\n"); + $r->print( + &Apache::lonhtmlcommon::actionbox( + [''.$linktext.'']) + .''."\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 { @@ -5167,24 +5170,29 @@ 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 on member role at a time.', - youh => 'You had selected ', + inco => 'In each community, each user may only have one member role at a time.', + youh => 'You had selected', secs => 'sections.', plmo => 'Please modify your selections so they include no more than one section.', mayn => 'may not be used as the name for a section, as it is a reserved word.', 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