--- loncom/interface/lonuserutils.pm 2010/11/15 18:50:37 1.97.2.25 +++ loncom/interface/lonuserutils.pm 2009/08/28 22:47:07 1.98 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.97.2.25 2010/11/15 18:50:37 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.98 2009/08/28 22:47:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,8 +47,7 @@ sub modifystudent { # this one. If $csec is defined, drop them from all other sections of # this course and add them to section $csec my ($cnum,$cdom) = &get_course_identity($courseid); - my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); - my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra); + my %roles = &Apache::lonnet::dump('roles',$udom,$unam); my ($tmp) = keys(%roles); # Bail out if we were unable to get the students roles return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); @@ -92,7 +91,7 @@ sub modifyuserrole { if ($setting eq 'course' || $context eq 'course') { $scope = '/'.$cid; $scope =~ s/\_/\//g; - if (($role ne 'cc') && ($role ne 'co') && ($sec ne '')) { + if ($role ne 'cc' && $sec ne '') { $scope .='/'.$sec; } } elsif ($context eq 'domain') { @@ -236,7 +235,7 @@ sub domain_roles_select { # domain context # # Role types - my @roletypes = ('domain','author','course','community'); + my @roletypes = ('domain','author','course'); my %lt = &role_type_names(); # # build up the menu information to be passed to @@ -248,10 +247,6 @@ sub domain_roles_select { foreach my $roletype (@roletypes) { # set up the text for this domain $select_menus{$roletype}->{'text'}= $lt{$roletype}; - my $crstype; - if ($roletype eq 'community') { - $crstype = 'Community'; - } # we want a choice of 'default' as the default in the second menu if ($env{'form.roletype'} ne '') { $select_menus{$roletype}->{'default'} = $env{'form.showrole'}; @@ -266,7 +261,7 @@ sub domain_roles_select { @roles = &construction_space_roles(); } else { my $custom = 1; - @roles = &course_roles('domain',undef,$custom,$roletype); + @roles = &course_roles('domain',undef,$custom); } my $order = ['Any',@roles]; $select_menus{$roletype}->{'order'} = $order; @@ -276,15 +271,14 @@ sub domain_roles_select { &mt('Custom role'); } else { $select_menus{$roletype}->{'select2'}->{$role} = - &Apache::lonnet::plaintext($role,$crstype); + &Apache::lonnet::plaintext($role); } } $select_menus{$roletype}->{'select2'}->{'Any'} = &mt('Any'); } my $result = &Apache::loncommon::linked_select_forms ('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'}, - 'roletype','showrole',\%select_menus, - ['domain','author','course','community']); + 'roletype','showrole',\%select_menus,['domain','author','course']); return $result; } @@ -296,8 +290,7 @@ sub hidden_input { } sub print_upload_manager_header { - my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype, - $can_assign)=@_; + my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_; my $javascript; # if (! exists($env{'form.upfile_associate'})) { @@ -311,9 +304,9 @@ sub print_upload_manager_header { } } if ($env{'form.upfile_associate'} eq 'reverse') { - $javascript=&upload_manager_javascript_reverse_associate($can_assign); + $javascript=&upload_manager_javascript_reverse_associate(); } else { - $javascript=&upload_manager_javascript_forward_associate($can_assign); + $javascript=&upload_manager_javascript_forward_associate(); } # # Deal with restored settings @@ -334,7 +327,7 @@ sub print_upload_manager_header { my $javascript_validations = &javascript_validations('upload',$krbdefdom,$password_choice,undef, $env{'request.role.domain'},$context, - $groupslist,$crstype); + $groupslist); my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); $r->print('

' .&mt('Total number of records found in file: [_1]' @@ -367,7 +360,7 @@ sub print_upload_manager_header { ############################################################### sub javascript_validations { my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain, - $context,$groupslist,$crstype)=@_; + $context,$groupslist)=@_; my %param = ( kerb_def_dom => $krbdefdom, curr_authtype => $curr_authtype, @@ -388,10 +381,10 @@ sub javascript_validations { if (($context eq 'course') || ($context eq 'domain')) { if ($context eq 'course') { if ($env{'request.course.sec'} eq '') { - $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');'; + $setsection_call = 'setSections(document.'.$param{'formname'}.');'; $setsections_js = &setsections_javascript($param{'formname'},$groupslist, - $mode,'',$crstype); + $mode); } else { $setsection_call = "'ok'"; } @@ -534,7 +527,6 @@ END if (message!='') { message+='\\n'; } - message+='$alert{'section'}'; } if (foundemail==0) { if (message!='') { @@ -588,46 +580,6 @@ END ############################################################### ############################################################### sub upload_manager_javascript_forward_associate { - my ($can_assign) = @_; - my ($auth_update,$numbuttons,$argreset); - if (ref($can_assign) eq 'HASH') { - if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) { - $argreset .= " vf.krbarg.value='';\n"; - $numbuttons ++ ; - } - if ($can_assign->{'int'}) { - $argreset .= " vf.intarg.value='';\n"; - $numbuttons ++; - } - if ($can_assign->{'loc'}) { - $argreset .= " vf.locarg.value='';\n"; - $numbuttons ++; - } - if (!$can_assign->{'int'}) { - my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.\n'). - &mt('Your current role does not have rights to create users with that authentication type.'); - $auth_update = <<"END"; - // Currently the initial password field is only supported for internal auth - // (see bug 6368). - if (nw==9) { - eval('vf.f'+tf+'.selectedIndex=0;') - alert('$warning'); - } -END - } elsif ($numbuttons > 1) { - $auth_update = <<"END"; - // If we set the password, make the password form below correspond to - // the new value. - if (nw==9) { - changed_radio('int',document.studentform); - set_auth_radio_buttons('int',document.studentform); -$argreset - } - -END - } - } - return(<{'krb4'} || $can_assign->{'krb5'}) { - $argreset .= " vf.krbarg.value='';\n"; - $numbuttons ++ ; - } - if ($can_assign->{'int'}) { - $argreset .= " vf.intarg.value='';\n"; - $numbuttons ++; - } - if ($can_assign->{'loc'}) { - $argreset .= " vf.locarg.value='';\n"; - $numbuttons ++; - } - if (!$can_assign->{'int'}) { - my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). - &mt('Your current role does not have rights to create users with that authentication type.'); - $auth_update = <<"END"; - // Currently the initial password field is only supported for internal auth - // (see bug 6368). - if (tf==8 && nw!=0) { - eval('vf.f'+tf+'.selectedIndex=0;') - alert('$warning'); - } -END - } elsif ($numbuttons > 1) { - $auth_update = <<"END"; - // initial password specified, pick internal authentication - if (tf==8 && nw!=0) { - changed_radio('int',document.studentform); - set_auth_radio_buttons('int',document.studentform); -$argreset - } - -END - } - } - return(<=2) && (tf<=5) && (nw!=0)) { eval('vf.f1.selectedIndex=0;') } - $auth_update + // intial password specified, pick internal authentication + if (tf==8 && nw!=0) { + changed_radio('int',document.studentform); + set_auth_radio_buttons('int',document.studentform); + vf.krbarg.value=''; + vf.intarg.value=''; + vf.locarg.value=''; + } } function clearpwd(vf) { @@ -817,7 +743,7 @@ ENDPICK ############################################################### ############################################################### sub print_upload_manager_footer { - my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission,$crstype) = @_; + my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission) = @_; my $form = 'document.studentform'; my $formname = 'studentform'; my ($krbdef,$krbdefdom) = @@ -835,7 +761,7 @@ sub print_upload_manager_footer { my $intform = &Apache::loncommon::authform_internal(%param); my $locform = &Apache::loncommon::authform_local(%param); my $date_table = &date_setting_table(undef,undef,$context,undef, - $formname,$permission,$crstype); + $formname,$permission); my $Str = "\n".'

'; $Str .= &hidden_input('nfields',$i); @@ -899,7 +825,7 @@ sub print_upload_manager_footer { .' '.&mt('Add a domain role').'' .'   ' + .' '.&mt('Add a course role').'' .''; } elsif ($context eq 'author') { $Str .= &Apache::lonhtmlcommon::row_title( @@ -934,26 +860,15 @@ sub print_upload_manager_footer { my ($cnum,$cdom) = &get_course_identity(); my $rowtitle = &mt('section'); my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle, - $permission,$context,'upload',$crstype); + $permission,$context,'upload'); $Str .= $secbox .&Apache::lonhtmlcommon::row_closure(); - my %lt; - if ($crstype eq 'Community') { - %lt = &Apache::lonlocal::texthash ( - disp => 'Display members with current/future access who are not in the uploaded file', - stus => 'Members selected from this list can be dropped.' - ); - } else { - %lt = &Apache::lonlocal::texthash ( - disp => 'Display students with current/future access who are not in the uploaded file', - stus => 'Students selected from this list can be dropped.' - ); - } + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Full Update')) - .'
'); &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear, - $context,$permission,$crstype); + $context,$permission); } sub setup_date_selectors { @@ -1159,7 +1073,7 @@ sub get_dates_from_form { } sub date_setting_table { - my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission,$crstype) = @_; + my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission) = @_; my $nolink; if ($bulkaction) { $nolink = 1; @@ -1176,13 +1090,9 @@ sub date_setting_table { ($env{'form.action'} eq 'upload')) { if ($env{'request.course.sec'} eq '') { $dateDefault = ''. - ''; + ''; } } } @@ -1211,7 +1121,7 @@ sub date_setting_table { } sub make_dates_default { - my ($startdate,$enddate,$context,$crstype) = @_; + my ($startdate,$enddate,$context) = @_; my $result = ''; if ($context eq 'course') { my ($cnum,$cdom) = &get_course_identity(); @@ -1219,34 +1129,26 @@ sub make_dates_default { {'default_enrollment_start_date'=>$startdate, 'default_enrollment_end_date' =>$enddate},$cdom,$cnum); if ($put_result eq 'ok') { - if ($crstype eq 'Community') { - $result .= &mt('Set default start and end access dates for community.'); - } else { - $result .= &mt('Set default start and end access dates for course.'); - } - $result .= '
'."\n"; + $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 { - if ($crstype eq 'Community') { - $result .= &mt('Unable to set default access dates for community'); - } else { - $result .= &mt('Unable to set default access dates for course'); - } - $result .= ':'.$put_result.'
'; + $result .= &mt('Unable to set default access dates for course.').":".$put_result. + '
'; } } return $result; } sub default_role_selector { - my ($context,$checkpriv,$crstype) = @_; + my ($context,$checkpriv) = @_; my %customroles; my ($options,$coursepick,$cb_jscript); if ($context ne 'author') { - %customroles = &my_custom_roles($crstype); + %customroles = &my_custom_roles(); } my %lt=&Apache::lonlocal::texthash( @@ -1258,7 +1160,7 @@ sub default_role_selector { $options = ''."\n". + ''."\n". ''. ''. '
'. @@ -1299,7 +1201,6 @@ sub default_role_selector { $env{'request.role.domain'}.'" />'. ''. ''. - ''. '
'. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table()."\n"; @@ -1309,13 +1210,13 @@ sub default_role_selector { } sub default_course_roles { - my ($context,$checkpriv,$crstype,%customroles) = @_; + my ($context,$checkpriv,%customroles) = @_; my $output; my $custom = 1; - my @roles = &course_roles($context,$checkpriv,$custom,lc($crstype)); + my @roles = &course_roles($context,$checkpriv,$custom); foreach my $role (@roles) { if ($role ne 'cr') { - my $plrole=&Apache::lonnet::plaintext($role,$crstype); + my $plrole=&Apache::lonnet::plaintext($role); $output .= ' '; } } @@ -1364,14 +1265,8 @@ sub domain_roles { } sub course_roles { - my ($context,$checkpriv,$custom,$roletype) = @_; - my $crstype; - if ($roletype eq 'community') { - $crstype = 'Community' ; - } else { - $crstype = 'Course'; - } - my @allroles = &roles_by_context('course',$custom,$crstype); + my ($context,$checkpriv,$custom) = @_; + my @allroles = &roles_by_context('course',$custom); my @roles; if ($context eq 'domain') { @roles = @allroles; @@ -1382,7 +1277,7 @@ sub course_roles { if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) { push(@roles,$role); } else { - if ((($role ne 'cc') && ($role ne 'co')) && ($env{'request.course.sec'} ne '')) { + if ($role ne 'cc' && $env{'request.course.sec'} ne '') { if (&Apache::lonnet::allowed('c'.$role, $env{'request.course.id'}.'/'. $env{'request.course.sec'})) { @@ -1400,19 +1295,19 @@ sub course_roles { } sub curr_role_permissions { - my ($context,$setting,$checkpriv,$type) = @_; + my ($context,$setting,$checkpriv) = @_; my $custom = 1; my @roles; if ($context eq 'author') { @roles = &construction_space_roles($checkpriv); } elsif ($context eq 'domain') { if ($setting eq 'course') { - @roles = &course_roles($context,$checkpriv,$custom,$type); + @roles = &course_roles($context,$checkpriv,$custom); } else { @roles = &domain_roles($checkpriv); } } elsif ($context eq 'course') { - @roles = &course_roles($context,$checkpriv,$custom,$type); + @roles = &course_roles($context,$checkpriv,$custom); } return @roles; } @@ -1420,14 +1315,10 @@ sub curr_role_permissions { # ======================================================= Existing Custom Roles sub my_custom_roles { - my ($crstype) = @_; my %returnhash=(); my %rolehash=&Apache::lonnet::dump('roles'); - foreach my $key (keys(%rolehash)) { + foreach my $key (keys %rolehash) { if ($key=~/^rolesdef\_(\w+)$/) { - if ($crstype eq 'Community') { - next if ($rolehash{$key} =~ /bre\&S/); - } $returnhash{$1}=$1; } } @@ -1516,50 +1407,26 @@ sub print_userlist { ''); return; } - if (!(($context eq 'domain') && - (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { - $r->print( - "\n

\n" - .'

' - .&list_submit_button(&mt('Update Display')) - ."

\n" - ); + if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { + $r->print(' '.&list_submit_button(&mt('Update Display')). + "\n

\n"); } my ($indexhash,$keylist) = &make_keylist_array(); - my (%userlist,%userinfo,$clearcoursepick); - if (($context eq 'domain') && - ($env{'form.roletype'} eq 'course') || - ($env{'form.roletype'} eq 'community')) { - my ($crstype,$numcodes,$title,$warning); - if ($env{'form.roletype'} eq 'course') { - $crstype = 'Course'; - $numcodes = $totcodes; - $title = &mt('Select Courses'); - $warning = &mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.'); - } elsif ($env{'form.roletype'} eq 'community') { - $crstype = 'Community'; - $numcodes = 0; - $title = &mt('Select Communities'); - $warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.'); - } + my (%userlist,%userinfo); + if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { my $courseform = - &Apache::lonhtmlcommon::course_selection($formname,$numcodes, - $codetitles,$idlist,$idlist_titles,$crstype); + &Apache::lonhtmlcommon::course_selection($formname,$totcodes, + $codetitles,$idlist,$idlist_titles); $r->print('

'.&Apache::lonhtmlcommon::start_pick_box()."\n". &Apache::lonhtmlcommon::start_pick_box()."\n". - &Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n". + &Apache::lonhtmlcommon::row_title(&mt('Select Course(s)'), + 'LC_oddrow_value')."\n". $courseform."\n". &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::end_pick_box().'

'. - '

'. - &list_submit_button(&mt('Update Display')). - "\n".'

'.$warning.''."\n"); - $clearcoursepick = 0; - if (($env{'form.origroletype'} ne '') && - ($env{'form.origroletype'} ne $env{'form.roletype'})) { - $clearcoursepick = 1; - } - if (($env{'form.coursepick'}) && (!$clearcoursepick)) { + '

'.&list_submit_button(&mt('Update Display')). + "\n".'

'.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').''."\n"); + if ($env{'form.coursepick'}) { $r->print('
'.&mt('Searching').' ...
 
'); } } else { @@ -1632,9 +1499,8 @@ sub print_userlist { } } } - } elsif (($env{'form.roletype'} eq 'course') || - ($env{'form.roletype'} eq 'community')) { - if (($env{'form.coursepick'}) && (!$clearcoursepick)) { + } elsif ($env{'form.roletype'} eq 'course') { + if ($env{'form.coursepick'}) { my %courses = &process_coursepick(); my %allusers; my $hidepriv = 1; @@ -1645,8 +1511,7 @@ sub print_userlist { my (@roles,@sections,%access,%users,%userdata, %statushash); if ($env{'form.showrole'} eq 'Any') { - @roles = &course_roles($context,undef,$custom, - $env{'form.roletype'}); + @roles = &course_roles($context,undef,$custom); } else { @roles = ($env{'form.showrole'}); } @@ -1692,8 +1557,6 @@ sub print_userlist { $r->print(&mt('There are no authors or co-authors to display.')."\n"); } elsif ($env{'form.roletype'} eq 'course') { $r->print(&mt('There are no course users to display')."\n"); - } elsif ($env{'form.roletype'} eq 'community') { - $r->print(&mt('There are no community users to display')."\n"); } } elsif ($context eq 'course') { $r->print(&mt('There are no course users to display.')."\n"); @@ -1736,16 +1599,7 @@ sub role_filter { $role_select = ''."\n"; + $markup = ''."\n"; - $output .= (' 'x3).'' - .'' - .' '; + $output .= (' 'x3).''; } } return $output; @@ -1872,8 +1724,7 @@ sub gather_userinfo { $indexhash,$uniqid,$userlist); } } - } elsif (($env{'form.roletype'} eq 'course') || - ($env{'form.roletype'} eq 'community')) { + } elsif ($env{'form.roletype'} eq 'course') { ($userdata{'username'},$userdata{'domain'},$userdata{'role'}) = split(/:/,$item); if (ref($rolehash->{$item}) eq 'HASH') { @@ -1923,8 +1774,7 @@ sub gather_userinfo { sub build_user_record { my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_; next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1'); - if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course') - && ($env{'form.roletype'} eq 'community')))) { + if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { &process_date_info($userdata); } my $username = $userdata->{'username'}; @@ -2039,17 +1889,13 @@ sub process_coursepick { my $coursefilter = $env{'form.coursepick'}; my $cdom = $env{'request.role.domain'}; my %courses; - my $crssrch = 'Course'; - if ($env{'form.roletype'} eq 'community') { - $crssrch = 'Community'; - } if ($coursefilter eq 'all') { %courses = &Apache::lonnet::courseiddump($cdom,'.','.','.','.','.', - undef,undef,$crssrch); + undef,undef,'Course'); } elsif ($coursefilter eq 'category') { my $instcode = &instcode_from_coursefilter(); %courses = &Apache::lonnet::courseiddump($cdom,'.','.',$instcode,'.','.', - undef,undef,$crssrch); + undef,undef,'Course'); } elsif ($coursefilter eq 'specific') { if ($env{'form.coursetotal'} > 1) { my @course_ids = split(/&&/,$env{'form.courselist'}); @@ -2193,10 +2039,9 @@ sub show_users_list { $sortby = 'username'; } my $setting = $env{'form.roletype'}; - my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype); + my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers); if ($context eq 'course') { $cid = $env{'request.course.id'}; - $crstype = &Apache::loncommon::course_type(); ($cnum,$cdom) = &get_course_identity($cid); ($classgroups) = &Apache::loncoursedata::get_group_memberships( $userlist,$keylist,$cdom,$cnum); @@ -2231,12 +2076,6 @@ function photowindow(photolink) { END } - } elsif ($context eq 'domain') { - if ($setting eq 'community') { - $crstype = 'Community'; - } elsif ($setting eq 'course') { - $crstype = 'Course'; - } } if ($mode ne 'autoenroll' && $mode ne 'pickauthor') { my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript(); @@ -2333,8 +2172,6 @@ END ); if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { $lt{'extent'} = &mt('Course(s): description, section(s), status'); - } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') { - $lt{'extent'} = &mt('Communities: description, section(s), status'); } elsif ($context eq 'author') { $lt{'extent'} = &mt('Author'); } @@ -2346,21 +2183,18 @@ END if ($context eq 'course') { push(@cols,'section'); } - if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course') - && ($env{'form.roletype'} eq 'community'))) { + if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) { push(@cols,('start','end')); } if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') { push(@cols,'role'); } if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' || - $env{'form.roletype'} eq 'course' || - $env{'form.roletype'} eq 'community')) { + $env{'form.roletype'} eq 'course')) { push (@cols,'extent'); } - if (($statusmode eq 'Any') && - (!($context eq 'domain' && (($env{'form.roletype'} eq 'course') - || ($env{'form.roletype'} eq 'community'))))) { + if (($statusmode eq 'Any') && + (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) { push(@cols,'status'); } if ($context eq 'course') { @@ -2373,24 +2207,19 @@ END if ($env{'form.showrole'} eq 'cr') { $rolefilter = &mt('custom'); } elsif ($env{'form.showrole'} ne 'Any') { - $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'},$crstype); + $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'}); } my $results_description; if ($mode ne 'autoenroll') { $results_description = &results_header_row($rolefilter,$statusmode, - $context,$permission,$mode,$crstype); - + $context,$permission,$mode); $r->print(''.$results_description.'

'); } my ($output,$actionselect,%canchange,%canchangesec); if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { if ($mode ne 'autoenroll' && $mode ne 'pickauthor') { if ($permission->{'cusr'}) { - unless (($context eq 'domain') && - (($setting eq 'course') || ($setting eq 'community'))) { - $actionselect = - &select_actions($context,$setting,$statusmode,$formname); - } + $actionselect = &select_actions($context,$setting,$statusmode,$formname); } $r->print(< @@ -2401,7 +2230,7 @@ END END if ($actionselect) { $output .= <<"END"; -
$lt{'ac'} +
$lt{'ac'} $actionselect

 
@@ -2410,9 +2239,9 @@ END if ($env{'form.showrole'} eq 'Any') { my $custom = 1; if ($context eq 'domain') { - @allroles = &roles_by_context($setting,$custom,$crstype); + @allroles = &roles_by_context($setting,$custom); } else { - @allroles = &roles_by_context($context,$custom,$crstype); + @allroles = &roles_by_context($context,$custom); } } else { @allroles = ($env{'form.showrole'}); @@ -2446,7 +2275,7 @@ END } } } - $output .= '
'.$lt{'link'}.''. + $output .= '
'.$lt{'link'}.''. ''; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { @@ -2457,6 +2286,7 @@ END $env{'request.course.sec'})) { push(@linkdests,'track'); } + $output .= '
'; my $usernamelink = $env{'form.usernamelink'}; if ($usernamelink eq '') { @@ -2473,7 +2303,7 @@ END if ($env{'form.userwin'}) { $checkwin = ' checked="checked"'; } - $output .= ''.$lt{'owin'}.'
'; + $output .= ''.$lt{'owin'}.'
'; } $output .= "\n".''."\n". &Apache::loncommon::start_data_table(). @@ -2483,7 +2313,11 @@ END $lt{'type'} "; } else { - $output .= "\n".' '."\n"; + if ($mode eq 'pickauthor') { + $output .= "\n".' '."\n"; + } else { + $output .= "\n".''.&mt('Count').''."\n"; + } if ($actionselect) { $output .= ''.&mt('Select').''."\n"; } @@ -2538,13 +2372,9 @@ END time.'_'.rand(1000000000).'.csv'; unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) { $r->log_error("Couldn't open $CSVfilename for output $!"); - $r->print( - '

' - .&mt('Problems occurred in writing the CSV file.') - .' '.&mt('This error has been logged.') - .' '.&mt('Please alert your LON-CAPA administrator.') - .'

' - ); + $r->print(&mt('Problems occurred in writing the CSV file. ' + .'This error has been logged. ' + .'Please alert your LON-CAPA administrator.')); $CSVfile = undef; } # @@ -2618,8 +2448,7 @@ END } } elsif ($env{'form.roletype'} eq 'author') { ($uname,$udom,$role) = split(/:/,$user,-1); - } elsif (($env{'form.roletype'} eq 'course') || - ($env{'form.roletype'} eq 'community')) { + } elsif ($env{'form.roletype'} eq 'course') { ($uname,$udom,$role) = split(/:/,$user); } } else { @@ -2726,7 +2555,7 @@ END if ($clickers!~/\w/) { $clickers='-'; } $in{'clicker'} = $clickers; my $role = $in{'role'}; - $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); + $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]); if (! defined($in{'start'}) || $in{'start'} == 0) { $in{'start'} = &mt('none'); } else { @@ -3013,7 +2842,7 @@ sub print_username_link { $output = $in->{'username'}; } else { $output = '{'username'}','$in->{'domain'}'".')">'. + "'$in->{'username'}','$in->{'domain'}'".')" />'. $in->{'username'}.''; } return $output; @@ -3024,7 +2853,6 @@ sub role_type_names { 'domain' => 'Domain Roles', 'author' => 'Co-Author Roles', 'course' => 'Course Roles', - 'community' => 'Community Roles', ); return %lt; } @@ -3161,7 +2989,7 @@ ENDTWO } sub date_section_selector { - my ($context,$permission,$crstype) = @_; + my ($context,$permission) = @_; my $callingform = $env{'form.callingform'}; my $formname = 'dateselect'; my $groupslist = &get_groupslist(); @@ -3186,7 +3014,7 @@ END } else { opener.document.$callingform.retainsec.value = formname.retainsec.value; } - setSections(formname,'$crstype'); + setSections(formname); if (seccheck == 'ok') { opener.document.$callingform.newsecs.value = formname.sections.value; } @@ -3243,10 +3071,10 @@ 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 course role that is not "student", users may have roles in more than one section at a time.', + 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?", - dnap => '(Does not apply to student roles).', + dnap => '(Does not apply to student roles).', ); my ($date_items,$headertext); if ($env{'form.bulkaction'} eq 'chgsec') { @@ -3260,18 +3088,13 @@ ENDJS } $date_items = &date_setting_table($starttime,undef,$context, $env{'form.bulkaction'},$formname, - $permission,$crstype); + $permission); } $output .= '

'.$headertext.'

'. - '
'."\n". + ''."\n". $date_items; if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') { my ($cnum,$cdom) = &get_course_identity(); - if ($crstype eq 'Community') { - $lt{'fors'} = &mt('For member roles, changing the section will result in a section switch, as members may only be in one section of a community at a time.'); - $lt{'forn'} = &mt('For a community role that is not "member", users may have roles in more than one section at a time.'); - $lt{'dnap'} = &mt('(Does not apply to member roles).'); - } my $info; if ($env{'form.showrole'} eq 'st') { $output .= '

'.$lt{'fors'}.'

'; @@ -3297,7 +3120,7 @@ ENDJS $info = ''; } my $rowtitle = &mt('New section to assign'); - my $secbox = §ion_picker($cdom,$cnum,$env{'form.showrole'},$rowtitle,$permission,$context,'',$crstype); + my $secbox = §ion_picker($cdom,$cnum,$env{'form.showrole'},$rowtitle,$permission,$context); $output .= $info.$secbox; } $output .= '

'. @@ -3307,13 +3130,13 @@ ENDJS } sub section_picker { - my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode,$crstype) = @_; + my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode) = @_; my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); my $sections_select .= &course_sections(\%sections_count,$role); - my $secbox = '

'.&Apache::lonhtmlcommon::start_pick_box()."\n"; + my $secbox = '

'.&Apache::lonhtmlcommon::start_pick_box()."\n"; if ($mode eq 'upload') { my ($options,$cb_script,$coursepick) = - &default_role_selector($context,1,$crstype); + &default_role_selector($context,1); $secbox .= &Apache::lonhtmlcommon::row_title(&mt('role'),'LC_oddrow_value'). $options. &Apache::lonhtmlcommon::row_closure(1)."\n"; } @@ -3323,7 +3146,7 @@ sub section_picker { ''.&mt('Existing sections')."\n". '
'.$sections_select.''. &mt('New section').'
'."\n". - ''."\n". + ''."\n". ''."\n". ''."\n"; } else { @@ -3332,55 +3155,31 @@ sub section_picker { $env{'request.course.sec'}; } $secbox .= &Apache::lonhtmlcommon::row_closure(1)."\n". - &Apache::lonhtmlcommon::end_pick_box().'

'; + &Apache::lonhtmlcommon::end_pick_box().'

'; return $secbox; } sub results_header_row { - my ($rolefilter,$statusmode,$context,$permission,$mode,$crstype) = @_; + my ($rolefilter,$statusmode,$context,$permission,$mode) = @_; my ($description,$showfilter); if ($rolefilter ne 'Any') { $showfilter = $rolefilter; } if ($context eq 'course') { if ($mode eq 'csv' || $mode eq 'excel') { - if ($crstype eq 'Community') { - $description = &mt('Community - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' '; - } else { - $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' '; - } + $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' '; } if ($statusmode eq 'Expired') { - if ($crstype eq 'Community') { - $description .= &mt('Users in community with expired [_1] roles',$showfilter); - } else { - $description .= &mt('Users in course with expired [_1] roles',$showfilter); - } + $description .= &mt('Users in course with expired [_1] roles',$showfilter); } elsif ($statusmode eq 'Future') { - if ($crstype eq 'Community') { - $description .= &mt('Users in community with future [_1] roles',$showfilter); - } else { - $description .= &mt('Users in course with future [_1] roles',$showfilter); - } + $description .= &mt('Users in course with future [_1] roles',$showfilter); } elsif ($statusmode eq 'Active') { - if ($crstype eq 'Community') { - $description .= &mt('Users in community with active [_1] roles',$showfilter); - } else { - $description .= &mt('Users in course with active [_1] roles',$showfilter); - } + $description .= &mt('Users in course with active [_1] roles',$showfilter); } else { if ($rolefilter eq 'Any') { - if ($crstype eq 'Community') { - $description .= &mt('All users in community'); - } else { - $description .= &mt('All users in course'); - } + $description .= &mt('All users in course'); } else { - if ($crstype eq 'Community') { - $description .= &mt('All users in community with [_1] roles',$rolefilter); - } else { - $description .= &mt('All users in course with [_1] roles',$rolefilter); - } + $description .= &mt('All users in course with [_1] roles',$rolefilter); } } my $constraint; @@ -3388,7 +3187,7 @@ sub results_header_row { if ($viewablesec ne '') { if ($env{'form.showrole'} eq 'st') { $constraint = &mt('only users in section "[_1]"',$viewablesec); - } elsif (($env{'form.showrole'} ne 'cc') && ($env{'form.showrole'} ne 'co')) { + } elsif ($env{'form.showrole'} ne 'cc') { $constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec); } if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) { @@ -3473,32 +3272,22 @@ sub results_header_row { if ($rolefilter eq 'Any') { $description .= &mt('All users with co-author roles in domain',$showfilter); } else { - $description .= &mt('All co-authors in domain with [_1] roles',$rolefilter); + $description .= &mt('All co-authors in domain with [_1] roles',$rolefilter); } } - } elsif (($env{'form.roletype'} eq 'course') || - ($env{'form.roletype'} eq 'community')) { - + } elsif ($env{'form.roletype'} eq 'course') { my $coursefilter = $env{'form.coursepick'}; - if ($env{'form.roletype'} eq 'course') { - if ($coursefilter eq 'category') { - my $instcode = &instcode_from_coursefilter(); - if ($instcode eq '.') { - $description .= &mt('All courses in domain').' - '; - } else { - $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - '; - } - } elsif ($coursefilter eq 'selected') { - $description .= &mt('Selected courses in domain').' - '; - } elsif ($coursefilter eq 'all') { + if ($coursefilter eq 'category') { + my $instcode = &instcode_from_coursefilter(); + if ($instcode eq '.') { $description .= &mt('All courses in domain').' - '; + } else { + $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - '; } - } elsif ($env{'form.roletype'} eq 'community') { - if ($coursefilter eq 'selected') { - $description .= &mt('Selected communities in domain').' - '; - } elsif ($coursefilter eq 'all') { - $description .= &mt('All communities in domain').' - '; - } + } elsif ($coursefilter eq 'selected') { + $description .= &mt('Selected courses in domain').' - '; + } elsif ($coursefilter eq 'all') { + $description .= &mt('All courses in domain').' - '; } if ($statusmode eq 'Expired') { $description .= &mt('users with expired [_1] roles',$showfilter); @@ -3535,7 +3324,7 @@ sub viewable_section { ################################################# ################################################# sub show_drop_list { - my ($r,$classlist,$nosort,$permission,$crstype) = @_; + my ($r,$classlist,$nosort,$permission) = @_; my $cid = $env{'request.course.id'}; my ($cnum,$cdom) = &get_course_identity($cid); if (! exists($env{'form.sortby'})) { @@ -3581,11 +3370,7 @@ END } } if (!$studentcount) { - if ($crstype eq 'Community') { - $r->print(&mt('There are no members to drop.')); - } else { - $r->print(&mt('There are no students to drop.')); - } + $r->print(&mt('There are no students to drop.')); return; } my ($classgroups) = &Apache::loncoursedata::get_group_memberships( @@ -3593,16 +3378,11 @@ END my %lt=&Apache::lonlocal::texthash('usrn' => "username", 'dom' => "domain", 'sn' => "student name", - 'mn' => "member name", 'sec' => "section", 'start' => "start date", 'end' => "end date", 'groups' => "active groups", ); - my $nametitle = $lt{'sn'}; - if ($crstype eq 'Community') { - $nametitle = $lt{'mn'}; - } if ($nosort) { $r->print(&Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row()); @@ -3611,7 +3391,7 @@ END $lt{'usrn'} $lt{'dom'} ID - $nametitle + $lt{'sn'} $lt{'sec'} $lt{'start'} $lt{'end'} @@ -3630,7 +3410,7 @@ END ID - $nametitle + $lt{'sn'} $lt{'sec'} @@ -3700,14 +3480,9 @@ END $r->print(&Apache::loncommon::end_data_table().'
'); %lt=&Apache::lonlocal::texthash( 'dp' => "Drop Students", - 'dm' => "Drop Members", 'ca' => "check all", 'ua' => "uncheck all", ); - my $btn = $lt{'dp'}; - if ($crstype eq 'Community') { - $btn = $lt{'dm'}; - } $r->print(<<"END");

@@ -3715,7 +3490,7 @@ END

- +

END return; @@ -3729,20 +3504,24 @@ sub print_first_users_upload_form { my $str; $str = ''; $str .= ''; - $str .= ''; + $str .= ''; $str .= '

'.&mt('Upload a file containing information about users').'

'."\n"; # Excel and CSV Help - $str .= '
' + $str .= '

' .&Apache::loncommon::help_open_topic("Course_Create_Class_List", &mt("How do I create a users list from a spreadsheet")) - .'

'."\n" + ."
\n" .&Apache::loncommon::help_open_topic("Course_Convert_To_CSV", &mt("How do I create a CSV file from a spreadsheet")) - .'

'."\n"; + ."

\n"; + $str .= &Apache::lonhtmlcommon::start_pick_box() .&Apache::lonhtmlcommon::row_title(&mt('File')) + .'

'."\n" + .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n" + .'

'."\n" .&Apache::loncommon::upfile_select_html() .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( @@ -3757,6 +3536,8 @@ sub print_first_users_upload_form { .'' .'

'; + $str .= &Apache::loncommon::end_page(); + $r->print($str); return; } @@ -3803,22 +3584,9 @@ sub upfile_drop_add { 'domain_choice' => 'scalar', 'inststatus_choice' => 'scalar'}); # - my ($cid,$crstype,$setting); - if ($context eq 'domain') { - $setting = $env{'form.roleaction'}; - } - if ($env{'request.course.id'} ne '') { - $cid = $env{'request.course.id'}; - $crstype = &Apache::loncommon::course_type(); - } elsif ($setting eq 'course') { - if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) { - $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'}; - $crstype = &Apache::loncommon::course_type($cid); - } - } my ($startdate,$enddate) = &get_dates_from_form(); if ($env{'form.makedatesdefault'}) { - $r->print(&make_dates_default($startdate,$enddate,$context,$crstype)); + $r->print(&make_dates_default($startdate,$enddate,$context)); } # Determine domain and desired host (home server) my $defdom=$env{'request.role.domain'}; @@ -3870,20 +3638,28 @@ sub upfile_drop_add { $amode = ''; # This causes the loop below to be skipped } } - my ($defaultsec,$defaultrole); + my ($cid,$defaultsec,$defaultrole,$setting); if ($context eq 'domain') { + $setting = $env{'form.roleaction'}; if ($setting eq 'domain') { $defaultrole = $env{'form.defaultrole'}; } elsif ($setting eq 'course') { $defaultrole = $env{'form.courserole'}; $defaultsec = $env{'form.sections'}; - } + } } elsif ($context eq 'author') { $defaultrole = $env{'form.defaultrole'}; } elsif ($context eq 'course') { $defaultrole = $env{'form.defaultrole'}; $defaultsec = $env{'form.sections'}; } + if ($env{'request.course.id'} ne '') { + $cid = $env{'request.course.id'}; + } elsif ($setting eq 'course') { + if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) { + $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'}; + } + } # Check to see if user information can be changed my @userinfo = ('firstname','middlename','lastname','generation', 'permanentemail','id'); @@ -3896,10 +3672,10 @@ sub upfile_drop_add { } my (%userlist,%modifiable_fields,@poss_roles); my $secidx = &Apache::loncoursedata::CL_SECTION(); - my @courseroles = &roles_by_context('course',1,$crstype); + my @courseroles = &roles_by_context('course',1); if (!&Apache::lonnet::allowed('mau',$domain)) { if ($context eq 'course' || $context eq 'author') { - @poss_roles = &curr_role_permissions($context,'','',$crstype); + @poss_roles = &curr_role_permissions($context); my @statuses = ('active','future'); my ($indexhash,$keylist) = &make_keylist_array(); my %info; @@ -3984,21 +3760,14 @@ sub upfile_drop_add { $r->print($groupwarn.'
'); } } - my (%curr_rules,%got_rules,%alerts,%cancreate); - my %customroles = &my_custom_roles($crstype); - my @permitted_roles = - &roles_on_upload($context,$setting,$crstype,%customroles); - my %longtypes = &Apache::lonlocal::texthash( - official => 'Institutional', - unofficial => 'Non-institutional', - ); - map { $cancreate{$_} = &can_create_user($domain,$context,$_); } keys(%longtypes); + my (%curr_rules,%got_rules,%alerts); + my %customroles = &my_custom_roles(); + my @permitted_roles = &roles_on_upload($context,$setting,%customroles); # Get new users list foreach my $line (@userdata) { my @secs; my %entries=&Apache::loncommon::record_sep($line); # Determine user name - $entries{$fields{'username'}} =~ s/^\s+|\s+$//g; unless (($entries{$fields{'username'}} eq '') || (!defined($entries{$fields{'username'}}))) { my ($fname, $mname, $lname,$gen) = ('','','',''); @@ -4021,17 +3790,11 @@ sub upfile_drop_add { } if ($entries{$fields{'username'}} ne &LONCAPA::clean_username($entries{$fields{'username'}})) { - my $nowhitespace; - if ($entries{$fields{'username'}} =~ /\s/) { - $nowhitespace = ' - '.&mt('usernames may not contain spaces.'); - } $r->print('
'. &mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]', - ''.$entries{$fields{'username'}}.'',$fname,$mname,$lname,$gen). - $nowhitespace); + ''.$entries{$fields{'username'}}.'',$fname,$mname,$lname,$gen)); next; } else { - $entries{$fields{'domain'}} =~ s/^\s+|\s+$//g; if ($entries{$fields{'domain'}} ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) { $r->print('
'. ''.$entries{$fields{'domain'}}. @@ -4090,7 +3853,6 @@ sub upfile_drop_add { # determine email address my $email=''; if (defined($fields{'email'})) { - $entries{$fields{'email'}} =~ s/^\s+|\s+$//g; if (defined($entries{$fields{'email'}})) { $email=$entries{$fields{'email'}}; unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } @@ -4137,7 +3899,7 @@ sub upfile_drop_add { $role = $defaultrole; } # Clean up whitespace - foreach (\$id,\$fname,\$mname,\$lname,\$gen,\$inststatus) { + foreach (\$id,\$fname,\$mname,\$lname,\$gen) { $$_ =~ s/(\s+$|^\s+)//g; } # check against rules @@ -4146,16 +3908,9 @@ sub upfile_drop_add { my (%rulematch,%inst_results,%idinst_results); my $uhome=&Apache::lonnet::homeserver($username,$userdomain); if ($uhome eq 'no_host') { - if ($userdomain ne $domain) { - $r->print('
'. - &mt('[_1]: The domain specified ([_2]) is different to that of the course.', - ''.$username.'',$userdomain).'
'. - &mt('The user does not already exist, and you may not create a new user in a different domain.')); - next; - } + next if ($userdomain ne $domain); $checkid = 1; $newuser = 1; - my $user = $username.':'.$domain; my $checkhash; my $checks = { 'username' => 1 }; $checkhash->{$username.':'.$domain} = { 'newuser' => 1, }; @@ -4164,26 +3919,9 @@ sub upfile_drop_add { \%got_rules); if (ref($alerts{'username'}) eq 'HASH') { if (ref($alerts{'username'}{$domain}) eq 'HASH') { - if ($alerts{'username'}{$domain}{$username}) { - $r->print('
'. - &mt('[_1]: matches the username format at your institution, but is not known to your directory service.',''.$username.'').'
'. - &mt('Consequently, the user was not created.')); - next; - } - } - } - my $usertype = 'unofficial'; - if (ref($rulematch{$user}) eq 'HASH') { - if ($rulematch{$user}{'username'}) { - $usertype = 'official'; + next if ($alerts{'username'}{$domain}{$username}); } } - unless ($cancreate{$usertype}) { - my $showtype = $longtypes{$usertype}; - $r->print('
'. - &mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].',''.$username.'',$showtype)); - next; - } } else { if ($context eq 'course' || $context eq 'author') { if ($userdomain eq $domain ) { @@ -4234,12 +3972,7 @@ sub upfile_drop_add { \%got_rules); if (ref($alerts{'id'}) eq 'HASH') { if (ref($alerts{'id'}{$userdomain}) eq 'HASH') { - if ($alerts{'id'}{$userdomain}{$id}) { - $r->print(&mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is found by your directory service.', - ''.$username.'').'
'. - &mt('Consequently, the user was not created.')); - next; - } + next if ($alerts{'id'}{$userdomain}{$id}); } } } @@ -4271,7 +4004,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') { if (@secs > 1) { $multiple = 1; foreach my $sec (@secs) { @@ -4334,7 +4067,7 @@ sub upfile_drop_add { } } # end of foreach (@userdata) # Flush the course logs so reverse user roles immediately updated - $r->register_cleanup(\&Apache::lonnet::flushcourselogs); + &Apache::lonnet::flushcourselogs(); $r->print("

\n

\n".&mt('Processed [quant,_1,user].',$counts{'user'}). "

\n"); if ($counts{'role'} > 0) { @@ -4472,24 +4205,14 @@ sub user_change_result { # ========================================================= Menu Phase Two Drop sub print_drop_menu { - my ($r,$context,$permission,$crstype) = @_; - my $heading; - if ($crstype eq 'Community') { - $heading = &mt("Drop Members"); - } else { - $heading = &mt("Drop Students"); - } - $r->print('

'.$heading.'

'."\n". + my ($r,$context,$permission) = @_; + $r->print('

'.&mt("Drop Students").'

'."\n". ''."\n"); my $classlist = &Apache::loncoursedata::get_classlist(); if (! defined($classlist)) { - if ($crstype eq 'Community') { - $r->print(&mt('There are no members currently enrolled.')."\n"); - } else { - $r->print(&mt('There are no students currently enrolled.')."\n"); - } + $r->print(&mt('There are no students currently enrolled.')."\n"); } else { - &show_drop_list($r,$classlist,'nosort',$permission,$crstype); + &show_drop_list($r,$classlist,'nosort',$permission); } $r->print(''. &Apache::loncommon::end_page()); return; @@ -4498,12 +4221,9 @@ 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; - if ($context eq 'course') { - $crstype = &Apache::loncommon::course_type(); - } my @changelist; if ($choice eq 'drop') { @changelist = &Apache::loncommon::get_env_multiple('form.droplist'); @@ -4515,7 +4235,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', @@ -4532,9 +4252,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'; @@ -4575,7 +4294,7 @@ sub update_user_list { } } } - my $plrole = &Apache::lonnet::plaintext($role,$crstype); + my $plrole = &Apache::lonnet::plaintext($role); my $start = $env{'form.'.$item.'_start'}; my $end = $env{'form.'.$item.'_end'}; if ($choice eq 'drop') { @@ -4632,24 +4351,15 @@ 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); - } - } + if ($role ne 'cc') { + @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, @@ -4676,23 +4386,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); @@ -4701,41 +4401,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); @@ -4743,15 +4417,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; @@ -4762,48 +4427,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"); @@ -4819,17 +4449,17 @@ sub update_user_list { } } } - $r->print('

'.&mt("$result_text{'ok'}{$choice} for [quant,_1,user role,user roles,no user roles].",$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.').'

'); } # Flush the course logs so reverse user roles immediately updated - $r->register_cleanup(\&Apache::lonnet::flushcourselogs); + &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,$crstype)); + $r->print(&make_dates_default($startdate,$enddate,$context)); } } my $linktext = &mt('Display User Lists'); @@ -4839,27 +4469,6 @@ sub update_user_list { $r->print(''.$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 { my ($scope,$uname,$udom,$now) = @_; my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); @@ -4997,7 +4606,7 @@ sub get_groupslist { } sub setsections_javascript { - my ($formname,$groupslist,$mode,$checkauth,$crstype) = @_; + my ($formname,$groupslist,$mode,$checkauth) = @_; my ($checkincluded,$finish,$rolecode,$setsection_js); if ($mode eq 'upload') { $checkincluded = 'formname.name == "'.$formname.'"'; @@ -5036,11 +4645,8 @@ sub setsections_javascript { } my %alerts = &Apache::lonlocal::texthash( secd => 'Section designations do not apply to Course Coordinator roles.', - sedn => 'Section designations do not apply to Coordinator roles.', 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.', - 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.', @@ -5048,123 +4654,78 @@ 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) { +function setSections(formname) { 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'}"); - } else { - alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}"); - } + alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}") return; - } else { - if (validsecs != null) { - for (var j=0; j 1)) { - if (document.$formname.crstype.value == 'Community') { - alert("$alerts{'inco'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.") - } else { - alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.") - } + alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.") return; } for (var j=0; j 0)) { - alert("$alerts{'secd'} $cotext $alerts{'role'}.\\n$alerts{'accr'}."); - section = ""; - } SCRIPTTOP if ($mode ne 'upload') { $dc_setcourse_code .= (<<"ENDSCRIPT"); var coursename = "_$env{'request.role.domain'}"+"_"+course+"_"+userrole var numcourse = getIndex(document.$formname.dccourse); if (numcourse == "-1") { - if (document.$formname.type == 'Community') { - alert("$alerts{'thwc'}"); - } else { - alert("$alerts{'thwa'}"); - } + alert("$alerts{'thwa'}"); return; } else { @@ -5618,22 +5153,19 @@ ENDSCRIPT sub sectioncheck_alerts { my %alerts = &Apache::lonlocal::texthash( - curd => 'You must select a course or community in the current domain', + curd => 'You must select a course 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', youh => 'You had selected', sect => 'sections', plsm => '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', plsc => 'Please choose a different section name', mayt => 'may not be used as the name for a section, as it is the name of a course group', - mayc => 'may not be used as the name for a section, as it is the name of a community group', secn => 'Section names and group names must be distinct', secd => 'Section designations do not apply to ', role => 'roles', accr => 'role will be added with access to all sections', - thwa => 'There was a problem with your course selection', - thwc => 'There was a problem with your community selection', + thwa => 'There was a problem with your course selection' ); return %alerts; }