\n".
- &mt('Choose the role to assign to users without one specified in the uploaded file');
+ &mt('Choose the role to assign to users without a value specified in the uploaded file');
} elsif ($context eq 'course') {
$Str .= '
'.&mt('Default role and section')."
\n".
- &mt('Choose the role and/or section to assign to users without one 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 .= '
'.&mt('Default role and/or section')." \n".
- &mt('Role and/or section for users without one in the uploaded file.');
+ $Str .= '
'.&mt('Default role and/or section(s)')." \n".
+ &mt('Role and/or section(s) for users without values specified in the uploaded file.');
}
- $Str .= '
';
- my ($options,$cb_script,$coursepick) = &default_role_selector($context,'defaultrole',1);
- if ($context eq 'domain') {
- $Str .= ''.&mt('Domain Level').' '.$options.'
\n".
- &mt('Roles added for [_1] users. If user is active, the new role will be available when the user next logs in to LON-CAPA.',$counts{'role'})."
\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 {
+ $r->print('
'.&mt('No roles added').'
');
}
if ($counts{'auth'} > 0) {
$r->print("
\n".
@@ -3209,23 +3542,22 @@ sub upfile_drop_add {
$counts{'auth'})."
\n");
}
$r->print(&print_namespacing_alerts($domain,\%alerts,\%curr_rules));
- $r->print('');
#####################################
- # Drop students #
+ # Display list of students to drop #
#####################################
if ($env{'form.fullup'} eq 'yes') {
- $r->print('
'.&mt('Dropping Students')."
\n");
+ $r->print('
'.&mt('Students to Drop')."
\n");
# Get current classlist
- my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ my $classlist = &Apache::loncoursedata::get_classlist();
if (! defined($classlist)) {
- $r->print(&mt('There are no students currently enrolled.').
- "\n");
+ $r->print(''.
+ ''.
+ &mt('There are no students with current/future access to the course.').
+ ''."\n");
} else {
# Remove the students we just added from the list of students.
- foreach (@userdata) {
- my %entries=&Apache::loncommon::record_sep($_);
+ foreach my $line (@userdata) {
+ my %entries=&Apache::loncommon::record_sep($line);
unless (($entries{$fields{'username'}} eq '') ||
(!defined($entries{$fields{'username'}}))) {
delete($classlist->{$entries{$fields{'username'}}.
@@ -3233,10 +3565,13 @@ sub upfile_drop_add {
}
}
# Print out list of dropped students.
- &show_drop_list($r,$classlist,$keylist,'nosort');
+ &show_drop_list($r,$classlist,'nosort',$permission);
}
}
} # end of unless
+ if ($env{'form.fullup'} ne 'yes') {
+ $r->print('');
+ }
}
sub print_namespacing_alerts {
@@ -3280,8 +3615,8 @@ sub print_namespacing_alerts {
}
sub user_change_result {
- my ($r,$userresult,$authresult,$roleresult,$counts,$flushc,$username,
- $userchg) = @_;
+ my ($r,$userresult,$authresult,$roleresult,$idresult,$counts,$flushc,
+ $username,$userchg) = @_;
my $okresult = 0;
if ($userresult ne 'ok') {
if ($userresult =~ /^error:(.+)$/) {
@@ -3322,6 +3657,9 @@ sub user_change_result {
$flushc=0;
}
}
+ if ($idresult) {
+ $r->print($idresult);
+ }
return $flushc;
}
@@ -3330,14 +3668,12 @@ sub print_drop_menu {
my ($r,$context,$permission) = @_;
$r->print('
'.&mt("Drop Students").'
'."\n".
''. &Apache::loncommon::end_page());
return;
}
@@ -3349,10 +3685,10 @@ sub update_user_list {
my $now = time;
my $count=0;
my @changelist;
- if ($choice ne '') {
- @changelist = &Apache::loncommon::get_env_multiple('form.actionlist');
- } else {
+ if ($choice eq 'drop') {
@changelist = &Apache::loncommon::get_env_multiple('form.droplist');
+ } else {
+ @changelist = &Apache::loncommon::get_env_multiple('form.actionlist');
}
my %result_text = ( ok => { 'revoke' => 'Revoked',
'delete' => 'Deleted',
@@ -3419,7 +3755,6 @@ sub update_user_list {
}
}
my $plrole = &Apache::lonnet::plaintext($role);
- my ($uid,$first,$middle,$last,$gene,$sec);
my $start = $env{'form.'.$item.'_start'};
my $end = $env{'form.'.$item.'_end'};
if ($choice eq 'drop') {
@@ -3439,16 +3774,12 @@ sub update_user_list {
&Apache::lonnet::revokerole($udom,$uname,$scope,$role);
}
} elsif ($choice eq 'delete') {
- $start = -1;
- $end = -1;
if ($role eq 'st') {
-# FIXME - how does role deletion affect classlist?
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
- } else {
- $result =
- &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now,
- 0,1);
- }
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid);
+ }
+ $result =
+ &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now,
+ $start,1);
} else {
#reenable, activate, change access dates or change section
if ($choice ne 'chgsec') {
@@ -3490,27 +3821,36 @@ sub update_user_list {
$nochg = 1;
}
} else {
- if (!grep(/^\Q$sec\E$/,@newsecs)) {
- $revresult =
- &Apache::lonnet::revokerole($udom,$uname,$scope,$role);
+ if (@newsecs > 0) {
+ if (grep(/^\Q$sec\E$/,@newsecs)) {
+ push(@retained,$sec);
+ } else {
+ $revresult =
+ &Apache::lonnet::revokerole($udom,$uname,
+ $scope,$role);
+ }
} else {
- push(@retained,$sec);
+ $revresult =
+ &Apache::lonnet::revokerole($udom,$uname,
+ $scope,$role);
}
}
} else {
- push(@retained,$sec);
+ if ($sec eq '') {
+ $nochg = 1;
+ } else {
+ push(@retained,$sec);
+ }
}
# add new sections
if (@newsecs == 0) {
if (!$nochg) {
- if ($sec ne '') {
- if ($role eq 'st') {
- $result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid);
- } else {
- my $newscope = $scopestem;
- $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start);
- }
+ if ($role eq 'st') {
+ $result =
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid);
+ } else {
+ my $newscope = $scopestem;
+ $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start);
}
}
} else {
@@ -3544,11 +3884,11 @@ sub update_user_list {
$count++;
} else {
$r->print(
- &mt("Error $result_text{'error'}{$choice} [_1] in [_2] for [_3]:[_4]",
+ &mt("Error $result_text{'error'}{$choice} [_1] in [_2] for [_3]: [_4].",
$plrole,$extent,$uname.':'.$udom,$result).' ');
}
}
- $r->print('
'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,users].",$count).'
');
+ $r->print('
'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,no users].",$count).'
');
if ($count > 0) {
if ($choice eq 'revoke' || $choice eq 'drop') {
$r->print('
'.&mt('Re-enabling will re-activate data for the role.
'));
@@ -3558,23 +3898,20 @@ sub update_user_list {
}
if ($env{'form.makedatesdefault'}) {
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') {
- $r->print(&make_dates_default($startdate,$enddate));
+ $r->print(&make_dates_default($startdate,$enddate,$context));
}
}
}
sub classlist_drop {
- my ($scope,$uname,$udom,$now,$action) = @_;
+ my ($scope,$uname,$udom,$now) = @_;
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
- my $cid=$cdom.'_'.$cnum;
- my $user = $uname.':'.$udom;
- if ($action eq 'drop') {
+ if (&Apache::lonnet::is_course($cdom,$cnum)) {
+ my $user = $uname.':'.$udom;
if (!&active_student_roles($cnum,$cdom,$uname,$udom)) {
my $result =
&Apache::lonnet::cput('classlist',
- { $user => $now },
- $env{'course.'.$cid.'.domain'},
- $env{'course.'.$cid.'.num'});
+ { $user => $now },$cdom,$cnum);
return &mt('Drop from classlist: [_1]',
''.$result.'').' ';
}
@@ -3644,16 +3981,26 @@ sub course_sections {
my ($sections_count,$role) = @_;
my $output = '';
my @sections = (sort {$a <=> $b} keys %{$sections_count});
- if (scalar(@sections) == 1) {
+ my $numsec = scalar(@sections);
+ if ($numsec <= 1) {
$output = ''."\n".
- ' '."\n".
- ' '."\n".
+ ' '."\n".
+ ' '."\n";
+ if ($numsec == 1) {
+ $output .=
' '."\n";
+ }
} else {
$output = ''."\n";
+ if ($role eq 'st') {
+ $output .= '>'."\n".
+ ' '."\n".
+ ' \n";
+ } else {
+ $output .= 'multiple="multiple" size="'.$multiple.'">'."\n";
+ }
foreach my $sec (@sections) {
$output .= '\n";
}
@@ -3673,16 +4020,27 @@ sub get_groupslist {
}
sub setsections_javascript {
- my ($form,$groupslist) = @_;
- my ($checkincluded,$finish,$roleplace,$setsection_js);
- if ($form eq 'cu') {
+ my ($formname,$groupslist,$mode) = @_;
+ my ($checkincluded,$finish,$rolecode,$setsection_js);
+ if ($mode eq 'upload') {
+ $checkincluded = 'formname.name == "'.$formname.'"';
+ $finish = "return 'ok';";
+ $rolecode = "var role = formname.defaultrole.options[formname.defaultrole.selectedIndex].value;\n";
+ } elsif ($formname eq 'cu') {
$checkincluded = 'formname.elements[i-1].checked == true';
$finish = 'formname.submit()';
- $roleplace = 3;
+ $rolecode = "var match = str.split('_');
+ var role = match[3];\n";
+ } elsif ($formname eq 'enrollstudent') {
+ $checkincluded = 'formname.name == "'.$formname.'"';
+ $finish = 'formname.submit()';
+ $rolecode = "var match = str.split('_');
+ var role = match[1];\n";
} else {
- $checkincluded = 'formname.name == "'.$form.'"';
+ $checkincluded = 'formname.name == "'.$formname.'"';
$finish = "seccheck = 'ok';";
- $roleplace = 1;
+ $rolecode = "var match = str.split('_');
+ var role = match[1];\n";
$setsection_js = "var seccheck = 'alert';";
}
my %alerts = &Apache::lonlocal::texthash(
@@ -3707,8 +4065,7 @@ function setSections(formname) {
var checkcurr = str.match(re1);
if (checkcurr != null) {
if ($checkincluded) {
- var match = str.split('_');
- var role = match[$roleplace];
+ $rolecode
if (role == 'cc') {
alert("$alerts{'secd'}\\n$alerts{'accr'}");
}
@@ -3783,6 +4140,9 @@ sub can_create_user {
my ($dom,$context,$usertype) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
my $cancreate = 1;
+ if (&Apache::lonnet::allowed('mau',$dom)) {
+ return $cancreate;
+ }
if (ref($domconf{'usercreation'}) eq 'HASH') {
if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') {
if ($context eq 'course' || $context eq 'author') {
@@ -3937,7 +4297,8 @@ sub get_permission {
} else {
my @allroles = &roles_by_context($context);
foreach my $role (@allroles) {
- if (&Apache::lonnet::allowed('c'.$role,$env{'request.role.domain'})) { $permission{'cusr'} = 1;
+ if (&Apache::lonnet::allowed('c'.$role,$env{'request.role.domain'})) {
+ $permission{'cusr'} = 1;
last;
}
}
@@ -3966,6 +4327,27 @@ sub authorpriv {
|| (&Apache::lonnet::allowed('caa',$audom.'/'.$auname))) { return ''; } return 1;
}
+sub roles_on_upload {
+ my ($context,%customroles) = @_;
+ my (@possible_roles,@permitted_roles);
+ if ($context eq 'domain') {
+ @possible_roles = &curr_role_permissions($context,undef,1);
+ push(@possible_roles,&curr_role_permissions($context,'course',1));
+ } else {
+ @possible_roles = &curr_role_permissions($context,undef,1);
+ }
+ my $custom_ok = 0;
+ foreach my $role (@possible_roles) {
+ if ($role eq 'cr') {
+ $custom_ok = 1;
+ push(@permitted_roles,keys(%customroles));
+ } else {
+ push(@permitted_roles,$role);
+ }
+ }
+ return ($custom_ok,@permitted_roles);
+}
+
sub get_course_identity {
my ($cid) = @_;
my ($cnum,$cdom,$cdesc);
@@ -4125,6 +4507,5 @@ sub sectioncheck_alerts {
return %alerts;
}
-
1;