--- loncom/interface/lonuserutils.pm 2007/12/05 19:11:37 1.10
+++ loncom/interface/lonuserutils.pm 2007/12/22 22:42:58 1.29
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.10 2007/12/05 19:11:37 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.29 2007/12/22 22:42:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,8 +46,7 @@ sub modifystudent {
# if $csec is undefined, drop the student from all the courses matching
# this one. If $csec is defined, drop them from all other sections of
# this course and add them to section $csec
- my $cdom = $env{'course.'.$courseid.'.domain'};
- my $cnum = $env{'course.'.$courseid.'.num'};
+ my ($cnum,$cdom) = &get_course_identity($courseid);
my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
my ($tmp) = keys(%roles);
# Bail out if we were unable to get the students roles
@@ -69,7 +68,8 @@ sub modifystudent {
my $reply=&Apache::lonnet::modifystudent
# dom name id mode pass f m l g
($udom,$unam,'', '', '',undef,undef,undef,undef,
- $section,time,undef,undef,$desiredhost);
+ $section,time,undef,undef,$desiredhost,'','manual',
+ '',$courseid);
$result .= $reply.':';
}
}
@@ -96,7 +96,7 @@ sub modifyuserrole {
}
} elsif ($context eq 'domain') {
$scope = '/'.$env{'request.role.domain'}.'/';
- } elsif ($context eq 'construction_space') {
+ } elsif ($context eq 'author') {
$scope = '/'.$env{'user.domain'}.'/'.$env{'user.name'};
}
if ($context eq 'domain') {
@@ -127,6 +127,7 @@ sub modifyuserrole {
$email,$role,$start,$end);
if ($userresult eq 'ok') {
if ($role ne '') {
+ $role =~ s/_/\//g;
$roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope,
$role,$end,$start);
}
@@ -136,22 +137,30 @@ sub modifyuserrole {
sub propagate_id_change {
my ($uname,$udom,$user) = @_;
- my (@types,@roles,@cdoms);
+ my (@types,@roles);
@types = ('active','future');
@roles = ('st');
my $idresult;
my %roleshash = &Apache::lonnet::get_my_roles($uname,
- $udom,'userroles',\@types,\@roles,\@cdoms);
+ $udom,'userroles',\@types,\@roles);
+ my %args = (
+ one_time => 1,
+ );
foreach my $item (keys(%roleshash)) {
- my ($cnum,$cdom,$role) = split(/:/,$item);
+ my ($cnum,$cdom,$role) = split(/:/,$item,-1);
my ($start,$end) = split(/:/,$roleshash{$item});
if (&Apache::lonnet::is_course($cdom,$cnum)) {
- my %userupdate;
- my $result = &update_classlist($cdom,$cnum,$udom,$uname,\%userupdate);
+ my $result = &update_classlist($cdom,$cnum,$udom,$uname,$user);
+ my %coursehash =
+ &Apache::lonnet::coursedescription($cdom.'_'.$cnum,\%args);
+ my $cdesc = $coursehash{'description'};
+ if ($cdesc eq '') {
+ $cdesc = $cdom.'_'.$cnum;
+ }
if ($result eq 'ok') {
- $idresult .= "Classlist change: $uname:$udom - class -> $cnum:$cdom\n";
+ $idresult .= &mt('Classlist update for "[_1]" in "[_2]".',$uname.':'.$udom,$cdesc).'
'."\n";
} else {
- $idresult .= "Error - $result -during classlist update for $uname:$udom in $cnum:$cdom\n";
+ $idresult .= &mt('Error: "[_1]" during classlist update for "[_2]" in "[_3]".',$result,$uname.':'.$udom,$cdesc).'
'."\n";
}
}
}
@@ -203,7 +212,7 @@ sub domain_roles_select {
# domain context
#
# Role types
- my @roletypes = ('domain','construction_space','course');
+ my @roletypes = ('domain','author','course');
my %lt = &role_type_names();
#
# build up the menu information to be passed to
@@ -225,11 +234,11 @@ sub domain_roles_select {
my @roles;
if ($roletype eq 'domain') {
@roles = &domain_roles();
- } elsif ($roletype eq 'construction_space') {
+ } elsif ($roletype eq 'author') {
@roles = &construction_space_roles();
} else {
- @roles = &course_roles('domain');
- unshift(@roles,'cr');
+ my $custom = 1;
+ @roles = &course_roles('domain',undef,$custom);
}
my $order = ['Any',@roles];
$select_menus{$roletype}->{'order'} = $order;
@@ -246,7 +255,7 @@ sub domain_roles_select {
}
my $result = &Apache::loncommon::linked_select_forms
('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'},
- 'roletype','showrole',\%select_menus,['domain','construction_space','course']);
+ 'roletype','showrole',\%select_menus,['domain','author','course']);
return $result;
}
@@ -258,7 +267,7 @@ sub hidden_input {
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context)=@_;
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_;
my $javascript;
#
if (! exists($env{'form.upfile_associate'})) {
@@ -288,9 +297,14 @@ sub print_upload_manager_header {
$password_choice = 'int';
}
#
+ my $groupslist;
+ if ($context eq 'course') {
+ $groupslist = &get_groupslist();
+ }
my $javascript_validations =
- &javascript_validations('auth',$krbdefdom,$password_choice,undef,
- $env{'request.role.domain'});
+ &javascript_validations('upload',$krbdefdom,$password_choice,undef,
+ $env{'request.role.domain'},$context,
+ $permission,$groupslist);
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':'');
$r->print(&mt('Total number of records found in file: [_1].',$distotal).
"
\n");
@@ -317,26 +331,51 @@ sub print_upload_manager_header {
###############################################################
###############################################################
sub javascript_validations {
- my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain)=@_;
- my $authheader;
- if ($mode eq 'auth') {
- my %param = ( formname => 'studentform',
- kerb_def_dom => $krbdefdom,
- curr_authtype => $curr_authtype);
- $authheader = &Apache::loncommon::authform_header(%param);
- } elsif ($mode eq 'createcourse') {
- my %param = ( formname => 'ccrs',
- kerb_def_dom => $krbdefdom,
- curr_authtype => $curr_authtype );
- $authheader = &Apache::loncommon::authform_header(%param);
- } elsif ($mode eq 'modifycourse') {
- my %param = ( formname => 'cmod',
+ my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
+ $context,$permission,$groupslist)=@_;
+
+ my %param = (
kerb_def_dom => $krbdefdom,
- mode => 'modifycourse',
curr_authtype => $curr_authtype,
- curr_autharg => $curr_authfield );
- $authheader = &Apache::loncommon::authform_header(%param);
+ );
+ if ($mode eq 'createuser') {
+ $param{'formname'} = 'cu';
+ } elsif ($mode eq 'upload') {
+ $param{'formname'} = 'studentform';
+ } elsif ($mode eq 'singlestudent') {
+ $param{'formname'} = 'cu';
+ } elsif ($mode eq 'createcourse') {
+ $param{'formname'} = 'ccrs';
+ } elsif ($mode eq 'modifycourse') {
+ $param{'formname'} = 'cmod';
+ $param{'mode'} = 'modifycourse',
+ $param{'curr_autharg'} = $curr_authfield;
+ }
+
+ my ($setsection_call,$setsections_js);
+ my $finish = " vf.submit();\n";
+ if ($mode eq 'upload') {
+ if (($context eq 'course') || ($context eq 'domain')) {
+ if ($context eq 'course') {
+ if ($env{'request.course.sec'} eq '') {
+ $setsection_call = 'setSections(document.'.$param{'formname'}.');';
+ $setsections_js =
+ &setsections_javascript($param{'formname'},$groupslist,
+ $mode);
+ } else {
+ $setsection_call = "'ok'";
+ }
+ } elsif ($context eq 'domain') {
+ $setsection_call = 'setCourse()';
+ $setsections_js = &dc_setcourse_js($param{'formname'},$mode);
+ }
+ $finish = " var checkSec = $setsection_call\n".
+ " if (checkSec == 'ok') {\n".
+ " vf.submit();\n".
+ " }\n";
+ }
}
+ my $authheader = &Apache::loncommon::authform_header(%param);
my %alert = &Apache::lonlocal::texthash
(username => 'You need to specify the username field.',
@@ -351,8 +390,9 @@ sub javascript_validations {
continue => 'Continue adding users?',
);
-# my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
my $function_name =(<'.&mt('Settings for assigning roles:').'
'."\n".
&mt('Pick the action to take on roles for these users:').'
';
}
- if ($context eq 'construction_space') {
+ if ($context eq 'author') {
$Str .= ''.&mt('Default role')."
\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 .= '
';
- my ($options,$cb_script,$coursepick) = &default_role_selector($context,'defaultrole',1);
- if ($context eq 'domain') {
- $Str .= ''.&mt('Domain Level').'
'.$options.'
'.&mt('Course Level').'
'.$cb_script.$coursepick;
- } elsif ($context eq 'construction_space') {
- $Str .= $options;
- } else {
- $Str .= '
';
+ $Str .= ''.&mt('role').': '.
- $options.' '.
- ''.&mt('section').':
'.&mt('Default role and/or section(s)')."
\n".
+ &mt('Role and/or section(s) for users without values specified in the uploaded file.');
}
- if ($context eq 'course') {
- $Str .= "".&mt('Full Update')."
\n".
- ''."\n";
}
+ $output .= '';
return $output;
}
###############################################################
###############################################################
sub print_upload_manager_form {
- my ($r,$context) = @_;
+ my ($r,$context,$permission) = @_;
my $firstLine;
my $datatoken;
if (!$env{'form.datatoken'}) {
@@ -808,7 +844,8 @@ sub print_upload_manager_form {
my ($krbdef,$krbdefdom) =
&Apache::loncommon::get_kerberos_defaults($defdom);
#
- &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context);
+ &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context,
+ $permission);
my $i;
my $keyfields;
if ($total>=0) {
@@ -842,11 +879,14 @@ sub print_upload_manager_form {
}
$r->print('
';
+ my $result = &Apache::lonhtmlcommon::start_pick_box()."\n";
+ $result .= &Apache::lonhtmlcommon::row_title(&mt('Starting Date'),
+ 'LC_oddrow_value')."\n".
+ $startform."\n".
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::row_title(&mt('Ending Date'),
+ 'LC_oddrow_value')."\n".
+ $endform.' '.$perpetual.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box();
if ($dateDefault) {
$result .= $dateDefault.'
'."\n";
}
@@ -942,19 +997,19 @@ sub make_dates_default {
my ($startdate,$enddate,$context) = @_;
my $result = '';
if ($context eq 'course') {
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my ($cnum,$cdom) = &get_course_identity();
my $put_result = &Apache::lonnet::put('environment',
{'default_enrollment_start_date'=>$startdate,
- 'default_enrollment_end_date' =>$enddate},$dom,$crs);
+ 'default_enrollment_end_date' =>$enddate},$cdom,$cnum);
if ($put_result eq 'ok') {
- $result .= "Set default start and end dates for course
";
+ $result .= &mt('Set default start and end access dates for course.').
+ '
'."\n";
#
# Refresh the course environment
&Apache::lonnet::coursedescription($env{'request.course.id'},
{'freshen_cache' => 1});
} else {
- $result .= &mt('Unable to set default dates for course').":".$put_result.
+ $result .= &mt('Unable to set default access dates for course.').":".$put_result.
'
';
}
}
@@ -965,7 +1020,7 @@ sub default_role_selector {
my ($context,$checkpriv) = @_;
my %customroles;
my ($options,$coursepick,$cb_jscript);
- if ($context ne 'construction_space') {
+ if ($context ne 'author') {
%customroles = &my_custom_roles();
}
@@ -979,7 +1034,7 @@ sub default_role_selector {
' '."\n";
if ($context eq 'course') {
$options .= &default_course_roles($context,$checkpriv,%customroles);
- } elsif ($context eq 'construction_space') {
+ } elsif ($context eq 'author') {
my @roles = &construction_space_roles($checkpriv);
foreach my $role (@roles) {
my $plrole=&Apache::lonnet::plaintext($role);
@@ -992,33 +1047,36 @@ sub default_role_selector {
$options .= ' ';
}
my $courseform = &Apache::loncommon::selectcourse_link
- ('studentform','defaultcourse','defaultdomain','defaultdesc',"$env{'request.role.domain'}",undef,'Course');
+ ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course');
$cb_jscript =
- &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'defaultsec','studentform');
+ &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform');
$coursepick = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
''.$courseform.' '.$lt{'rol'}.' '.
''.$lt{'grs'}.' '.
&Apache::loncommon::end_data_table_header_row().
&Apache::loncommon::start_data_table_row()."\n".
- ''."\n".
+ ' '."\n".
' '.
' '.
+ ''.
+ ''.
+ ''.
+ ''.
+ ''.
+ ''.
&Apache::loncommon::end_data_table_row().
- &Apache::loncommon::end_data_table()."\n".
- ''.
- '';
+ &Apache::loncommon::end_data_table()."\n";
}
$options .= '';
return ($options,$cb_jscript,$coursepick);
@@ -1027,17 +1085,21 @@ sub default_role_selector {
sub default_course_roles {
my ($context,$checkpriv,%customroles) = @_;
my $output;
- my @roles = &course_roles($context,$checkpriv);
+ my $custom = 1;
+ my @roles = &course_roles($context,$checkpriv,$custom);
foreach my $role (@roles) {
- my $plrole=&Apache::lonnet::plaintext($role);
- $output .= ' ';
+ if ($role ne 'cr') {
+ my $plrole=&Apache::lonnet::plaintext($role);
+ $output .= ' ';
+ }
}
if (keys(%customroles) > 0) {
- my %customroles = &my_custom_roles();
- foreach my $cust (sort(keys(%customroles))) {
- my $custrole='cr_cr_'.$env{'user.domain'}.
- '_'.$env{'user.name'}.'_'.$cust;
- $output .= ' ';
+ if (grep(/^cr$/,@roles)) {
+ foreach my $cust (sort(keys(%customroles))) {
+ my $custrole='cr_'.$env{'user.domain'}.
+ '_'.$env{'user.name'}.'_'.$cust;
+ $output .= ' ';
+ }
}
}
return $output;
@@ -1045,7 +1107,7 @@ sub default_course_roles {
sub construction_space_roles {
my ($checkpriv) = @_;
- my @allroles = ('ca','aa');
+ my @allroles = &roles_by_context('author');
my @roles;
if ($checkpriv) {
foreach my $role (@allroles) {
@@ -1061,7 +1123,7 @@ sub construction_space_roles {
sub domain_roles {
my ($checkpriv) = @_;
- my @allroles = ('dc','li','dg','au','sc');
+ my @allroles = &roles_by_context('domain');
my @roles;
if ($checkpriv) {
foreach my $role (@allroles) {
@@ -1076,8 +1138,8 @@ sub domain_roles {
}
sub course_roles {
- my ($context,$checkpriv) = @_;
- my @allroles = ('st','ta','ep','in','cc');
+ my ($context,$checkpriv,$custom) = @_;
+ my @allroles = &roles_by_context('course',$custom);
my @roles;
if ($context eq 'domain') {
@roles = @allroles;
@@ -1088,10 +1150,10 @@ sub course_roles {
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) {
push(@roles,$role);
} else {
- if ($role ne 'cc' && $env{'request.course.section'} ne '') {
- if (!&Apache::lonnet::allowed('c'.$role,
+ if ($role ne 'cc' && $env{'request.course.sec'} ne '') {
+ if (&Apache::lonnet::allowed('c'.$role,
$env{'request.course.id'}.'/'.
- $env{'request.course.section'})) {
+ $env{'request.course.sec'})) {
push(@roles,$role);
}
}
@@ -1107,17 +1169,18 @@ sub course_roles {
sub curr_role_permissions {
my ($context,$setting,$checkpriv) = @_;
+ my $custom = 1;
my @roles;
- if ($context eq 'construction_space') {
+ if ($context eq 'author') {
@roles = &construction_space_roles($checkpriv);
} elsif ($context eq 'domain') {
if ($setting eq 'course') {
- @roles = &course_roles($context,$checkpriv);
+ @roles = &course_roles($context,$checkpriv,$custom);
} else {
@roles = &domain_roles($checkpriv);
}
} elsif ($context eq 'course') {
- @roles = &course_roles($context,$checkpriv);
+ @roles = &course_roles($context,$checkpriv,$custom);
}
return @roles;
}
@@ -1149,7 +1212,11 @@ sub print_userlist {
($env{'form.Status'});
if ($env{'form.showrole'} eq '') {
- $env{'form.showrole'} = 'Any';
+ if ($context eq 'course') {
+ $env{'form.showrole'} = 'st';
+ } else {
+ $env{'form.showrole'} = 'Any';
+ }
}
if (! defined($env{'form.output'}) ||
$env{'form.output'} !~ /^(csv|excel|html)$/ ) {
@@ -1211,19 +1278,20 @@ sub print_userlist {
if ($role eq $env{'form.showrole'}) {
$roleselected = ' selected="selected" ';
}
- my $plrole=&Apache::lonnet::plaintext($role);
+ my $plrole;
+ if ($role eq 'cr') {
+ $plrole = &mt('Custom role');
+ } else {
+ $plrole=&Apache::lonnet::plaintext($role);
+ }
$role_select .= '';
}
- $roleselected = '';
- if ($env{'form.showrole'} eq 'cr') {
- $roleselected = ' selected="selected" ';
- }
- $role_select .= ''.
- '';
+ $role_select .= '';
$r->print(''.
'
'.
- $lt{'exs'}.' '.
' '.
''.$lt{'new'}.' '.
- '
'.
''.
- '
'.&list_submit_button(&mt('Update Display')). "\n
\n"); + if ($env{'form.coursepick'}) { + $r->print('';
- my @linkdests = ('aboutme');
- if ($permission->{'cusr'}) {
- push (@linkdests,'modify');
- $output .= ''.$lt{'link'}.': ';
- my $usernamelink = $env{'form.usernamelink'};
- if ($usernamelink eq '') {
- $usernamelink = 'aboutme';
- }
- foreach my $item (@linkdests) {
- my $checkedstr = '';
- if ($item eq $usernamelink) {
- $checkedstr = ' checked="checked" ';
- }
- $output .= '
';
- } else {
- $output .= &mt("Click on a username to view the user's personal page.").'
';
- }
+ $output = '
';
+ my @linkdests = ('aboutme');
+ if ($permission->{'cusr'}) {
+ push (@linkdests,'modify');
+ $output .= ''.$lt{'link'}.': ';
+ my $usernamelink = $env{'form.usernamelink'};
+ if ($usernamelink eq '') {
+ $usernamelink = 'aboutme';
+ }
+ foreach my $item (@linkdests) {
+ my $checkedstr = '';
+ if ($item eq $usernamelink) {
+ $checkedstr = ' checked="checked" ';
+ }
+ $output .= '
';
+ } else {
+ $output .= &mt("Click on a username to view the user's personal page.").'
';
+ }
+ if ($actionselect) {
+ $output .= <<"END";
+$lt{'ac'}: $actionselect
+ +END + my @allroles; + if ($env{'form.showrole'} eq 'Any') { + my $custom = 1; + if ($context eq 'domain') { + @allroles = &roles_by_context($setting,$custom); + } else { + @allroles = &roles_by_context($context,$custom); + } + } else { + @allroles = ($env{'form.showrole'}); + } + foreach my $role (@allroles) { + if ($context eq 'domain') { + if ($setting eq 'domain') { + if (&Apache::lonnet::allowed('c'.$role, + $env{'request.role.domain'})) { + $canchange{$role} = 1; + } + } + } elsif ($context eq 'author') { + if (&Apache::lonnet::allowed('c'.$role, + $env{'user.domain'}.'/'.$env{'user.name'})) { + $canchange{$role} = 1; + } + } elsif ($context eq 'course') { + if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) { + $canchange{$role} = 1; + } elsif ($env{'request.course.sec'} ne '') { + if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { + $canchangesec{$role} = $env{'request.course.sec'}; + } + } + } + } + } } $output .= "\n
\n". &Apache::loncommon::start_data_table(). @@ -1878,15 +2073,16 @@ END
'.&mt('manual').' | |
'.&Apache::lonhtmlcommon::start_pick_box()."\n"; + if ($mode eq 'upload') { + my ($options,$cb_script,$coursepick) = + &default_role_selector($context,1); + $secbox .= &Apache::lonhtmlcommon::row_title('role','LC_oddrow_value'). + $options. &Apache::lonhtmlcommon::row_closure(1)."\n"; + } + $secbox .= &Apache::lonhtmlcommon::row_title($rowtitle,'LC_oddrow_value')."\n"; + if ($env{'request.course.sec'} eq '') { + $secbox .= '
'.&mt('Existing sections')."\n".
+ ' '.$sections_select.' | '.
+ &mt('New section').' '."\n". + ''."\n". + ''."\n". + ' |
@@ -2306,9 +2877,9 @@ my %lt=&Apache::lonlocal::texthash('usrn
'groups' => "active groups",
);
if ($nosort) {
- $r->print(&Apache::loncommon::start_data_table());
+ $r->print(&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row());
$r->print(<
$lt{'usrn'}
$lt{'dom'}
@@ -2318,32 +2889,32 @@ my %lt=&Apache::lonlocal::texthash('usrn
$lt{'start'}
$lt{'end'}
$lt{'groups'}
-
END
-
+ $r->print(&Apache::loncommon::end_data_table_header_row());
} else {
- $r->print(&Apache::loncommon::start_data_table());
+ $r->print(&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row());
$r->print(<
+
- $lt{'usrn'}
+ $lt{'usrn'}
- $lt{'dom'}
+ $lt{'dom'}
- ID
+ ID
- $lt{'sn'}
+ $lt{'sn'}
- $lt{'sec'}
+ $lt{'sec'}
- $lt{'start'}
+ $lt{'start'}
- $lt{'end'}
+ $lt{'end'}
- $lt{'groups'}
+ $lt{'groups'}
-
END
+ $r->print(&Apache::loncommon::end_data_table_header_row());
}
#
# Sort the students
@@ -2390,16 +2961,23 @@ END
}
my $status = $sdata->[$index{'status'}];
next if ($status ne 'Active');
+ if ($env{'request.course.sec'} ne '') {
+ if ($section ne $env{'request.course.sec'}) {
+ next;
+ }
+ }
+ my $studentkey = $student.':'.$section;
+ my $startitem = '';
#
$r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
-
+
$username
$domain
$id
$name
$section
- $start
+ $start $startitem
$end
$active_groups
END
@@ -2407,7 +2985,7 @@ END
}
$r->print(&Apache::loncommon::end_data_table().'
');
%lt=&Apache::lonlocal::texthash(
- 'dp' => "Expire Users' Roles",
+ 'dp' => "Drop Students",
'ca' => "check all",
'ua' => "uncheck all",
);
@@ -2449,7 +3027,7 @@ sub print_first_users_upload_form {
# ================================================= Drop/Add from uploaded file
sub upfile_drop_add {
- my ($r,$context) = @_;
+ my ($r,$context,$permission) = @_;
&Apache::loncommon::load_tmp_file($r);
my @userdata=&Apache::loncommon::upfile_record_sep();
if($env{'form.noFirstLine'}){shift(@userdata);}
@@ -2464,6 +3042,10 @@ sub upfile_drop_add {
$fields{$env{'form.f'.$i}}=$keyfields[$i];
}
}
+ if ($env{'form.fullup'} ne 'yes') {
+ $r->print('
'.&mt('No roles added').'
'); } if ($counts{'auth'} > 0) { $r->print("\n". &mt('Authentication changed for [_1] existing users.', $counts{'auth'})."
\n"); } - if (keys(%alerts) > 0) { - if (ref($alerts{'username'}) eq 'HASH') { - foreach my $dom (sort(keys(%{$alerts{'username'}}))) { - my $count; - if (ref($alerts{'username'}{$dom}) eq 'HASH') { - $count = keys(%{$alerts{'username'}{$dom}}); - } - my $domdesc = &Apache::lonnet::domain($domain,'description'); - if (ref($curr_rules{$dom}) eq 'HASH') { - $r->print(&Apache::loncommon::instrule_disallow_msg( - 'username',$domdesc,$count,'upload')); - } - $r->print(&Apache::loncommon::user_rule_formats($dom, - $domdesc,$curr_rules{$dom}{'username'}, - 'username')); - } - } - if (ref($alerts{'id'}) eq 'HASH') { - foreach my $dom (sort(keys(%{$alerts{'id'}}))) { - my $count; - if (ref($alerts{'id'}{$dom}) eq 'HASH') { - $count = keys(%{$alerts{'id'}{$dom}}); - } - my $domdesc = &Apache::lonnet::domain($domain,'description'); - if (ref($curr_rules{$dom}) eq 'HASH') { - $r->print(&Apache::loncommon::instrule_disallow_msg( - 'id',$domdesc,$count,'upload')); - } - $r->print(&Apache::loncommon::user_rule_formats($dom, - $domdesc,$curr_rules{$dom}{'id'},'id')); - } - } - } - $r->print(''); + $r->print(&print_namespacing_alerts($domain,\%alerts,\%curr_rules)); ##################################### - # Drop students # + # Display list of students to drop # ##################################### if ($env{'form.fullup'} eq 'yes') { - $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.
')); + } + # Flush the course logs so reverse user roles immediately updated + &Apache::lonnet::flushcourselogs(); + } + if ($env{'form.makedatesdefault'}) { + if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { + $r->print(&make_dates_default($startdate,$enddate,$context)); } } - $r->print(''.&mt('Dropped [_1] user(s).',$count).'
'); - $r->print(''.&mt('Re-enrollment will re-activate data.')) if ($count);
}
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.'').'
';
}
@@ -3009,16 +3969,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 = '