--- loncom/interface/lonuserutils.pm 2009/08/03 16:26:09 1.96 +++ loncom/interface/lonuserutils.pm 2010/08/04 16:50:29 1.121 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.96 2009/08/03 16:26:09 bisitz Exp $ +# $Id: lonuserutils.pm,v 1.121 2010/08/04 16:50:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -91,7 +91,7 @@ sub modifyuserrole { if ($setting eq 'course' || $context eq 'course') { $scope = '/'.$cid; $scope =~ s/\_/\//g; - if ($role ne 'cc' && $sec ne '') { + if (($role ne 'cc') && ($role ne 'co') && ($sec ne '')) { $scope .='/'.$sec; } } elsif ($context eq 'domain') { @@ -235,7 +235,7 @@ sub domain_roles_select { # domain context # # Role types - my @roletypes = ('domain','author','course'); + my @roletypes = ('domain','author','course','community'); my %lt = &role_type_names(); # # build up the menu information to be passed to @@ -247,6 +247,10 @@ 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'}; @@ -261,7 +265,7 @@ sub domain_roles_select { @roles = &construction_space_roles(); } else { my $custom = 1; - @roles = &course_roles('domain',undef,$custom); + @roles = &course_roles('domain',undef,$custom,$roletype); } my $order = ['Any',@roles]; $select_menus{$roletype}->{'order'} = $order; @@ -271,14 +275,15 @@ sub domain_roles_select { &mt('Custom role'); } else { $select_menus{$roletype}->{'select2'}->{$role} = - &Apache::lonnet::plaintext($role); + &Apache::lonnet::plaintext($role,$crstype); } } $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']); + 'roletype','showrole',\%select_menus, + ['domain','author','course','community']); return $result; } @@ -290,7 +295,7 @@ sub hidden_input { } sub print_upload_manager_header { - my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_; + my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype)=@_; my $javascript; # if (! exists($env{'form.upfile_associate'})) { @@ -327,7 +332,7 @@ sub print_upload_manager_header { my $javascript_validations = &javascript_validations('upload',$krbdefdom,$password_choice,undef, $env{'request.role.domain'},$context, - $groupslist); + $groupslist,$crstype); my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); $r->print('

' .&mt('Total number of records found in file: [_1]' @@ -360,7 +365,7 @@ sub print_upload_manager_header { ############################################################### sub javascript_validations { my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain, - $context,$groupslist)=@_; + $context,$groupslist,$crstype)=@_; my %param = ( kerb_def_dom => $krbdefdom, curr_authtype => $curr_authtype, @@ -381,10 +386,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'}.');'; + $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');'; $setsections_js = &setsections_javascript($param{'formname'},$groupslist, - $mode); + $mode,'',$crstype); } else { $setsection_call = "'ok'"; } @@ -743,7 +748,7 @@ ENDPICK ############################################################### ############################################################### sub print_upload_manager_footer { - my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission) = @_; + my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission,$crstype) = @_; my $form = 'document.studentform'; my $formname = 'studentform'; my ($krbdef,$krbdefdom) = @@ -761,7 +766,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); + $formname,$permission,$crstype); my $Str = "\n".'

'; $Str .= &hidden_input('nfields',$i); @@ -788,23 +793,21 @@ sub print_upload_manager_footer { &Apache::loncommon::help_open_topic('Auth_Options'). "

\n"; } - $Str .= &set_login($defdom,$krbform,$intform,$locform) - .&Apache::lonhtmlcommon::row_closure(); + $Str .= &set_login($defdom,$krbform,$intform,$locform); my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($defdom,'lcserver', 'default','hide'); -#FIXME: Broken?!? $home_server_pick returns empty value on prod (2.8.1) and on dev server. SB 2009-08-03 if ($numlib > 1) { - $Str .= &Apache::lonhtmlcommon::row_title( + $Str .= &Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title( &mt('LON-CAPA Home Server for New Users')) .&mt('LON-CAPA domain: [_1] with home server:','"'.$defdom.'"') .$home_server_pick .&Apache::lonhtmlcommon::row_closure(); } else { - $Str .= &Apache::lonhtmlcommon::row_title(&mt('Home Server')) - .$home_server_pick - .&Apache::lonhtmlcommon::row_closure(); + $Str .= $home_server_pick. + &Apache::lonhtmlcommon::row_closure(); } $Str .= &Apache::lonhtmlcommon::row_title(&mt('Default domain')) @@ -827,7 +830,7 @@ sub print_upload_manager_footer { .' '.&mt('Add a domain role').'' .'   ' + .' '.&mt('Add a course/community role').'' .''; } elsif ($context eq 'author') { $Str .= &Apache::lonhtmlcommon::row_title( @@ -862,15 +865,26 @@ 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'); + $permission,$context,'upload',$crstype); $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); + $context,$permission,$crstype); } sub setup_date_selectors { @@ -1075,7 +1089,7 @@ sub get_dates_from_form { } sub date_setting_table { - my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission) = @_; + my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission,$crstype) = @_; my $nolink; if ($bulkaction) { $nolink = 1; @@ -1092,9 +1106,13 @@ sub date_setting_table { ($env{'form.action'} eq 'upload')) { if ($env{'request.course.sec'} eq '') { $dateDefault = ''. - ''; + ''; } } } @@ -1123,7 +1141,7 @@ sub date_setting_table { } sub make_dates_default { - my ($startdate,$enddate,$context) = @_; + my ($startdate,$enddate,$context,$crstype) = @_; my $result = ''; if ($context eq 'course') { my ($cnum,$cdom) = &get_course_identity(); @@ -1131,26 +1149,34 @@ sub make_dates_default { {'default_enrollment_start_date'=>$startdate, 'default_enrollment_end_date' =>$enddate},$cdom,$cnum); if ($put_result eq 'ok') { - $result .= &mt('Set default start and end access dates for course.'). - '
'."\n"; + 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"; # # Refresh the course environment &Apache::lonnet::coursedescription($env{'request.course.id'}, {'freshen_cache' => 1}); } else { - $result .= &mt('Unable to set default access dates for course.').":".$put_result. - '
'; + 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.'
'; } } return $result; } sub default_role_selector { - my ($context,$checkpriv) = @_; + my ($context,$checkpriv,$crstype) = @_; my %customroles; my ($options,$coursepick,$cb_jscript); if ($context ne 'author') { - %customroles = &my_custom_roles(); + %customroles = &my_custom_roles($crstype); } my %lt=&Apache::lonlocal::texthash( @@ -1162,7 +1188,7 @@ sub default_role_selector { $options = ''."\n". + ''."\n". ''. ''. '
'. @@ -1203,6 +1229,7 @@ sub default_role_selector { $env{'request.role.domain'}.'" />'. ''. ''. + ''. '
'. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table()."\n"; @@ -1212,13 +1239,13 @@ sub default_role_selector { } sub default_course_roles { - my ($context,$checkpriv,%customroles) = @_; + my ($context,$checkpriv,$crstype,%customroles) = @_; my $output; my $custom = 1; - my @roles = &course_roles($context,$checkpriv,$custom); + my @roles = &course_roles($context,$checkpriv,$custom,lc($crstype)); foreach my $role (@roles) { if ($role ne 'cr') { - my $plrole=&Apache::lonnet::plaintext($role); + my $plrole=&Apache::lonnet::plaintext($role,$crstype); $output .= ' '; } } @@ -1267,8 +1294,14 @@ sub domain_roles { } sub course_roles { - my ($context,$checkpriv,$custom) = @_; - my @allroles = &roles_by_context('course',$custom); + 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 @roles; if ($context eq 'domain') { @roles = @allroles; @@ -1279,7 +1312,7 @@ sub course_roles { if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) { push(@roles,$role); } else { - if ($role ne 'cc' && $env{'request.course.sec'} ne '') { + if ((($role ne 'cc') && ($role ne 'co')) && ($env{'request.course.sec'} ne '')) { if (&Apache::lonnet::allowed('c'.$role, $env{'request.course.id'}.'/'. $env{'request.course.sec'})) { @@ -1297,19 +1330,19 @@ sub course_roles { } sub curr_role_permissions { - my ($context,$setting,$checkpriv) = @_; + my ($context,$setting,$checkpriv,$type) = @_; 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); + @roles = &course_roles($context,$checkpriv,$custom,$type); } else { @roles = &domain_roles($checkpriv); } } elsif ($context eq 'course') { - @roles = &course_roles($context,$checkpriv,$custom); + @roles = &course_roles($context,$checkpriv,$custom,$type); } return @roles; } @@ -1317,10 +1350,14 @@ 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; } } @@ -1409,26 +1446,52 @@ sub print_userlist { ''); return; } - if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { - $r->print(' '.&list_submit_button(&mt('Update Display')). - "\n

\n"); + 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" + ); } my ($indexhash,$keylist) = &make_keylist_array(); - my (%userlist,%userinfo); - if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { + 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 @standardnames = &Apache::loncommon::get_standard_codeitems(); my $courseform = - &Apache::lonhtmlcommon::course_selection($formname,$totcodes, - $codetitles,$idlist,$idlist_titles); + &Apache::lonhtmlcommon::course_selection($formname,$numcodes, + $codetitles,$idlist,$idlist_titles,$crstype, + \@standardnames); $r->print('

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

'. - '

'.&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'}) { + '

'. + &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)) { $r->print('
'.&mt('Searching').' ...
 
'); } } else { @@ -1501,8 +1564,9 @@ sub print_userlist { } } } - } elsif ($env{'form.roletype'} eq 'course') { - if ($env{'form.coursepick'}) { + } elsif (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { + if (($env{'form.coursepick'}) && (!$clearcoursepick)) { my %courses = &process_coursepick(); my %allusers; my $hidepriv = 1; @@ -1513,7 +1577,8 @@ sub print_userlist { my (@roles,@sections,%access,%users,%userdata, %statushash); if ($env{'form.showrole'} eq 'Any') { - @roles = &course_roles($context,undef,$custom); + @roles = &course_roles($context,undef,$custom, + $env{'form.roletype'}); } else { @roles = ($env{'form.showrole'}); } @@ -1559,6 +1624,8 @@ 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"); @@ -1601,7 +1668,16 @@ sub role_filter { $role_select = ''; $output = ''; + .' '; } return $output; } @@ -1647,7 +1723,7 @@ sub section_group_filter { $env{'form.'.$name{$item}} = 'all'; } if ($item eq 'sec') { - if ($env{'form.showrole'} eq 'cc') { + if (($env{'form.showrole'} eq 'cc') || ($env{'form.showrole'} eq 'co')) { $env{'form.'.$name{$item}} = 'none'; } my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); @@ -1658,7 +1734,7 @@ sub section_group_filter { } if (@options > 0) { my $currsel; - $markup = ''."\n"; foreach my $option ('all','none',@options) { $currsel = ''; if ($env{'form.'.$name{$item}} eq $option) { @@ -1673,7 +1749,9 @@ sub section_group_filter { $markup .= ''."\n"; } $markup .= ''."\n"; - $output .= (' 'x3).''; + $output .= (' 'x3).'' + .'' + .' '; } } return $output; @@ -1726,7 +1804,8 @@ sub gather_userinfo { $indexhash,$uniqid,$userlist); } } - } elsif ($env{'form.roletype'} eq 'course') { + } elsif (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { ($userdata{'username'},$userdata{'domain'},$userdata{'role'}) = split(/:/,$item); if (ref($rolehash->{$item}) eq 'HASH') { @@ -1776,7 +1855,8 @@ 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'))) { + if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course') + && ($env{'form.roletype'} eq 'community')))) { &process_date_info($userdata); } my $username = $userdata->{'username'}; @@ -1845,7 +1925,7 @@ function setCourseCat(formname) { if (formname.Year.options[formname.Year.selectedIndex].value == -1) { return; } - courseSet('Year'); + courseSet('$codetitles[0]'); for (var j=0; j 1) { my @course_ids = split(/&&/,$env{'form.courselist'}); @@ -2041,9 +2125,10 @@ sub show_users_list { $sortby = 'username'; } my $setting = $env{'form.roletype'}; - my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers); + my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype); 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); @@ -2078,6 +2163,12 @@ 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(); @@ -2124,6 +2215,17 @@ function username_display_launch(usernam document.location.href = '/adm/'+domain+'/'+username+'/aboutme'; } } + if (target == 'track') { + if (document.$formname.userwin.checked == true) { + var url = '/adm/trackstudent?selected_student='+username+':'+domain+'&only_body=1'; + var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'; + var trackwin = window.open(url,'',options,1); + trackwin.focus(); + return; + } else { + document.location.href = '/adm/trackstudent?selected_student='+username+':'+domain; + } + } } // ]]> @@ -2158,10 +2260,13 @@ END 'aboutme' => "Display a user's personal information page", 'owin' => "Open in a new window", 'modify' => "Modify a user's information", + 'track' => "View a user's recent activity", 'clicker' => "Clicker-ID", ); 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'); } @@ -2173,18 +2278,21 @@ END if ($context eq 'course') { push(@cols,'section'); } - if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) { + if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course') + && ($env{'form.roletype'} eq 'community'))) { 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 'course' || + $env{'form.roletype'} eq 'community')) { push (@cols,'extent'); } if (($statusmode eq 'Any') && - (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) { + (!($context eq 'domain' && (($env{'form.roletype'} eq 'course') + || ($env{'form.roletype'} eq 'community'))))) { push(@cols,'status'); } if ($context eq 'course') { @@ -2197,19 +2305,23 @@ END if ($env{'form.showrole'} eq 'cr') { $rolefilter = &mt('custom'); } elsif ($env{'form.showrole'} ne 'Any') { - $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'}); + $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'},$crstype); } my $results_description; if ($mode ne 'autoenroll') { $results_description = &results_header_row($rolefilter,$statusmode, - $context,$permission,$mode); + $context,$permission,$mode,$crstype); $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'}) { - $actionselect = &select_actions($context,$setting,$statusmode,$formname); + unless (($context eq 'domain') && + (($setting eq 'course') || ($setting eq 'community'))) { + $actionselect = + &select_actions($context,$setting,$statusmode,$formname); + } } $r->print(< @@ -2229,9 +2341,9 @@ END if ($env{'form.showrole'} eq 'Any') { my $custom = 1; if ($context eq 'domain') { - @allroles = &roles_by_context($setting,$custom); + @allroles = &roles_by_context($setting,$custom,$crstype); } else { - @allroles = &roles_by_context($context,$custom); + @allroles = &roles_by_context($context,$custom,$crstype); } } else { @allroles = ($env{'form.showrole'}); @@ -2271,6 +2383,12 @@ END if ($permission->{'cusr'}) { unshift (@linkdests,'modify'); } + if (&Apache::lonnet::allowed('vsa', $env{'request.course.id'}) || + &Apache::lonnet::allowed('vsa', $env{'request.course.id'}.'/'. + $env{'request.course.sec'})) { + push(@linkdests,'track'); + } + $output .= ''; my $usernamelink = $env{'form.usernamelink'}; if ($usernamelink eq '') { @@ -2287,7 +2405,7 @@ END if ($env{'form.userwin'}) { $checkwin = ' checked="checked"'; } - $output .= ''.$lt{'owin'}.''; + $output .= ''.$lt{'owin'}.''; } $output .= "\n".''."\n". &Apache::loncommon::start_data_table(). @@ -2297,11 +2415,7 @@ END $lt{'type'} "; } else { - if ($mode eq 'pickauthor') { - $output .= "\n".' '."\n"; - } else { - $output .= "\n".''.&mt('Count').''."\n"; - } + $output .= "\n".' '."\n"; if ($actionselect) { $output .= ''.&mt('Select').''."\n"; } @@ -2356,9 +2470,13 @@ 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. ' - .'This error has been logged. ' - .'Please alert your LON-CAPA administrator.')); + $r->print( + '

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

' + ); $CSVfile = undef; } # @@ -2432,7 +2550,8 @@ END } } elsif ($env{'form.roletype'} eq 'author') { ($uname,$udom,$role) = split(/:/,$user,-1); - } elsif ($env{'form.roletype'} eq 'course') { + } elsif (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { ($uname,$udom,$role) = split(/:/,$user); } } else { @@ -2539,7 +2658,7 @@ END if ($clickers!~/\w/) { $clickers='-'; } $in{'clicker'} = $clickers; my $role = $in{'role'}; - $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]); + $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); if (! defined($in{'start'}) || $in{'start'} == 0) { $in{'start'} = &mt('none'); } else { @@ -2826,7 +2945,7 @@ sub print_username_link { $output = $in->{'username'}; } else { $output = '{'username'}','$in->{'domain'}'".')" />'. + "'$in->{'username'}','$in->{'domain'}'".')">'. $in->{'username'}.''; } return $output; @@ -2837,6 +2956,7 @@ sub role_type_names { 'domain' => 'Domain Roles', 'author' => 'Co-Author Roles', 'course' => 'Course Roles', + 'community' => 'Community Roles', ); return %lt; } @@ -2973,7 +3093,7 @@ ENDTWO } sub date_section_selector { - my ($context,$permission) = @_; + my ($context,$permission,$crstype) = @_; my $callingform = $env{'form.callingform'}; my $formname = 'dateselect'; my $groupslist = &get_groupslist(); @@ -2998,7 +3118,7 @@ END } else { opener.document.$callingform.retainsec.value = formname.retainsec.value; } - setSections(formname); + setSections(formname,'$crstype'); if (seccheck == 'ok') { opener.document.$callingform.newsecs.value = formname.sections.value; } @@ -3055,10 +3175,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 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).', + fors => 'For student roles, changing the section will result in a section switch as students may only be in one section of a course at a time.', + forn => 'For a course role that is not "student", users may have roles in more than one section at a time.', + reta => "Retain each user's current section affiliations?", + dnap => '(Does not apply to student roles).', ); my ($date_items,$headertext); if ($env{'form.bulkaction'} eq 'chgsec') { @@ -3072,13 +3192,18 @@ ENDJS } $date_items = &date_setting_table($starttime,undef,$context, $env{'form.bulkaction'},$formname, - $permission); + $permission,$crstype); } $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'}.'

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

'. @@ -3114,13 +3239,13 @@ ENDJS } sub section_picker { - my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode) = @_; + my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode,$crstype) = @_; 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); + &default_role_selector($context,1,$crstype); $secbox .= &Apache::lonhtmlcommon::row_title(&mt('role'),'LC_oddrow_value'). $options. &Apache::lonhtmlcommon::row_closure(1)."\n"; } @@ -3130,7 +3255,7 @@ sub section_picker { ''.&mt('Existing sections')."\n". '
'.$sections_select.''. &mt('New section').'
'."\n". - ''."\n". + ''."\n". ''."\n". ''."\n"; } else { @@ -3139,31 +3264,55 @@ 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) = @_; + my ($rolefilter,$statusmode,$context,$permission,$mode,$crstype) = @_; my ($description,$showfilter); if ($rolefilter ne 'Any') { $showfilter = $rolefilter; } if ($context eq 'course') { if ($mode eq 'csv' || $mode eq 'excel') { - $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' '; + 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'}).' '; + } } if ($statusmode eq 'Expired') { - $description .= &mt('Users in course with expired [_1] roles',$showfilter); + 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); + } } elsif ($statusmode eq 'Future') { - $description .= &mt('Users in course with future [_1] roles',$showfilter); + 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); + } } elsif ($statusmode eq 'Active') { - $description .= &mt('Users in course with active [_1] roles',$showfilter); + 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); + } } else { if ($rolefilter eq 'Any') { - $description .= &mt('All users in course'); + if ($crstype eq 'Community') { + $description .= &mt('All users in community'); + } else { + $description .= &mt('All users in course'); + } } else { - $description .= &mt('All users in course with [_1] roles',$rolefilter); + 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); + } } } my $constraint; @@ -3171,7 +3320,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') { + } elsif (($env{'form.showrole'} ne 'cc') && ($env{'form.showrole'} ne 'co')) { $constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec); } if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) { @@ -3256,22 +3405,31 @@ 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') { + } elsif (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { my $coursefilter = $env{'form.coursepick'}; - if ($coursefilter eq 'category') { - my $instcode = &instcode_from_coursefilter(); - if ($instcode eq '.') { + 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') { $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') { - $description .= &mt('All courses in domain').' - '; + } 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').' - '; + } } if ($statusmode eq 'Expired') { $description .= &mt('users with expired [_1] roles',$showfilter); @@ -3308,7 +3466,7 @@ sub viewable_section { ################################################# ################################################# sub show_drop_list { - my ($r,$classlist,$nosort,$permission) = @_; + my ($r,$classlist,$nosort,$permission,$crstype) = @_; my $cid = $env{'request.course.id'}; my ($cnum,$cdom) = &get_course_identity($cid); if (! exists($env{'form.sortby'})) { @@ -3354,7 +3512,11 @@ END } } if (!$studentcount) { - $r->print(&mt('There are no students to drop.')); + if ($crstype eq 'Community') { + $r->print(&mt('There are no members to drop.')); + } else { + $r->print(&mt('There are no students to drop.')); + } return; } my ($classgroups) = &Apache::loncoursedata::get_group_memberships( @@ -3362,11 +3524,16 @@ 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()); @@ -3375,7 +3542,7 @@ END $lt{'usrn'} $lt{'dom'} ID - $lt{'sn'} + $nametitle $lt{'sec'} $lt{'start'} $lt{'end'} @@ -3394,7 +3561,7 @@ END ID - $lt{'sn'} + $nametitle $lt{'sec'} @@ -3464,9 +3631,14 @@ 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");

@@ -3474,7 +3646,7 @@ END

- +

END return; @@ -3488,25 +3660,28 @@ 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_title(&mt('File')); + if (&Apache::lonlocal::current_language() ne 'en') { + if ($context eq 'course') { + $str .= '

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

'."\n"; + } + } + $str .= &Apache::loncommon::upfile_select_html() .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( '