--- loncom/interface/lonuserutils.pm 2012/10/02 18:08:12 1.142 +++ loncom/interface/lonuserutils.pm 2013/02/19 17:30:35 1.149 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.142 2012/10/02 18:08:12 bisitz Exp $ +# $Id: lonuserutils.pm,v 1.149 2013/02/19 17:30:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -237,6 +237,8 @@ sub domain_roles_select { # Role types my @roletypes = ('domain','author','course','community'); my %lt = &role_type_names(); + my $onchangefirst = "updateCols('showrole')"; + my $onchangesecond = "updateCols('showrole')"; # # build up the menu information to be passed to # &Apache::loncommon::linked_select_forms @@ -283,7 +285,8 @@ sub domain_roles_select { my $result = &Apache::loncommon::linked_select_forms ('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'}, 'roletype','showrole',\%select_menus, - ['domain','author','course','community']); + ['domain','author','course','community'],$onchangefirst, + $onchangesecond); return $result; } @@ -335,13 +338,22 @@ sub print_upload_manager_header { $env{'request.role.domain'},$context, $groupslist,$crstype); my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); - $r->print('

' - .&mt('Total number of records found in file: [_1]' - ,''.$distotal.'') - ."

\n"); - $r->print('

'. - &mt('Identify fields in uploaded list')."

\n"); - $r->print(&mt('Enter as many fields as you can.
The system will inform you and bring you back to this page,
if the data selected are insufficient to add users.')."
\n"); + $r->print( + '

'.&mt('Identify fields in uploaded list')."

\n". + '

'. + &mt('Total number of records found in file: [_1]' + ,''.$distotal.''). + "

\n" + ); + if ($distotal == 0) { + $r->print('

'.&mt('None found').'

'); + } + $r->print( + '

'. + &mt('Enter as many fields as you can.').'
'. + &mt('The system will inform you and bring you back to this page,[_1]if the data selected are insufficient to add users.','
'). + "

\n" + ); $r->print(&hidden_input('action','upload'). &hidden_input('state','got_file'). &hidden_input('associate',''). @@ -349,17 +361,23 @@ sub print_upload_manager_header { &hidden_input('fileupload',$env{'form.fileupload'}). &hidden_input('upfiletype',$env{'form.upfiletype'}). &hidden_input('upfile_associate',$env{'form.upfile_associate'})); - $r->print('

'); - $r->print('
print( + '
'. + '
'.&mt('Functions').''. + ''. + ' '); - $r->print("

\n". - ''); + 'onclick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'. + '

' + ); + $r->print( + '' + ); } ############################################################### @@ -603,7 +621,7 @@ sub upload_manager_javascript_forward_as $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'). + 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 @@ -1082,7 +1100,6 @@ sub print_upload_manager_form { $keyfields=join(',',sort(keys(%sone))); } } - $r->print('
'); &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear, $context,$permission,$crstype); } @@ -1513,20 +1530,22 @@ sub print_userlist { } $r->print('
'. &column_checkboxes($context,$mode,$formname). - '

'); + ''); if ($env{'form.phase'} eq '') { - $r->print(&list_submit_button(&mt('Display List of Users'))."\n". + $r->print('
'. + &list_submit_button(&mt('Display List of Users'))."\n". ''); return; } if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { - $r->print(&list_submit_button(&mt('Update Display'))."\n"); + $r->print('
'. + &list_submit_button(&mt('Update Display'))."\n"); } my @cols = &infocolumns($context,$mode); if (!@cols) { - $r->print('
'. + $r->print('
'. &mt('No user information selected for display.').''. ''."\n"); return; @@ -1553,12 +1572,10 @@ sub print_userlist { &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($title,'LC_oddrow_value')."\n". + $r->print('

'. + '
'.$title.''."\n". $courseform."\n". - &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::end_pick_box().'

'. + '

'. '

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

'.$warning.''."\n"); @@ -1568,10 +1585,10 @@ sub print_userlist { $clearcoursepick = 1; } if (($env{'form.coursepick'}) && (!$clearcoursepick)) { - $r->print('
'.&mt('Searching').' ...
 
'); + $r->print('
'.&mt('Searching ...').'
 
'); } } else { - $r->print('
'.&mt('Searching').' ...
'); + $r->print('
'.&mt('Searching ...').'
'); } $r->rflush(); if ($context eq 'course') { @@ -1707,7 +1724,7 @@ sub print_userlist { } elsif ($context eq 'course') { $r->print(&mt('There are no course users to display.')."\n"); } - $r->print('

'."\n") if $msg; + $r->print('

'.$msg.'

'."\n") if $msg; } else { # Print out the available choices my $usercount; @@ -1868,9 +1885,6 @@ sub get_cols_array { push(@cols,'section'); } push(@cols,('start','end','role')); - if ($context eq 'domain') { - push (@cols,'extent'); - } unless (($mode eq 'autoenroll') && ($env{'form.Status'} ne 'Any')) { push(@cols,'status'); } @@ -1885,6 +1899,9 @@ sub get_cols_array { ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) { push(@cols,'photos'); } + if ($context eq 'domain') { + push (@cols,'extent'); + } } return @cols; } @@ -1899,20 +1916,30 @@ sub column_checkboxes { if ($context eq 'course') { $disabledchk{'role'} = 1; $unchecked{'photo'} = 1; + $unchecked{'clicker'} = 1; + } elsif ($context eq 'domain') { + $unchecked{'extent'} = 1; } - $unchecked{'clicker'} = 1; $unchecked{'start'} = 1; $unchecked{'end'} = 1; } else { if ($env{'form.Status'} ne 'Any') { $disabledchk{'status'} = 1; } - if ($env{'form.showrole'} ne 'Any') { - $disabledchk{'role'} = 1; + if (($env{'form.showrole'} ne 'Any') && ($env{'form.showrole'} ne 'cr')) { + $disabledchk{'role'} = 1; + } + if ($context eq 'domain') { + if (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { + $disabledchk{'status'} = 1; + } elsif ($env{'form.roletype'} eq 'domain') { + $disabledchk{'extent'} = 1; + } } } my $numposs = scalar(@cols); - my $numinrow = 8; + my $numinrow = 7; my %lt = &get_column_names($context); my $output = '
'.&mt('Information to show').''."\n".''. ''. @@ -1952,9 +1979,16 @@ sub column_checkboxes { } else { $output .= ''; } - $output .= ''; - + my $style; + if ($cols[$i] eq 'extent') { + if (($env{'form.roletype'} eq 'domain') || ($env{'form.roletype'} eq '')) { + $style = ' style="display: none;"'; + } + } + $output .= ''; } $output .= '
'; return $output; @@ -1988,11 +2022,12 @@ sub get_column_names { 'clicker' => "clicker-ID", ); if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { - $lt{'extent'} = &mt('Course(s): description, section(s), status'); + $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'); + $lt{'extent'} = &mt('communities: description, section(s), status'); + } elsif (($context eq 'author') || + ($context eq 'domain' && $env{'form.roletype'} eq 'author')) { + $lt{'extent'} = &mt('author'); } return %lt; } @@ -2579,7 +2614,11 @@ END if ($env{'form.userwin'}) { $checkwin = ' checked="checked"'; } - $output .= ''.$lt{'owin'}.''; + $output .= + '' + .''; } $output .= "\n".'
'."\n". &Apache::loncommon::start_data_table(). @@ -2919,7 +2958,7 @@ END } else { $r->print(' '."\n"); } - } + } } else { $r->print(''.$in{$item}.''."\n"); } @@ -3413,7 +3452,7 @@ sub section_picker { ''."\n". ''."\n"; } else { - $secbox .= ''. $env{'request.course.sec'}; } @@ -3666,11 +3705,13 @@ END } } if (!$studentcount) { + my $msg = ''; if ($crstype eq 'Community') { - $r->print(&mt('There are no members to drop.')); + $msg = &mt('There are no members to drop.'); } else { - $r->print(&mt('There are no students to drop.')); + $msg = &mt('There are no students to drop.'); } + $r->print('

'.$msg.'

'); return; } my ($classgroups) = &Apache::loncoursedata::get_group_memberships( @@ -3816,16 +3857,17 @@ sub print_first_users_upload_form { $str .= ''; $str .= ''; + $str .= &Apache::grades::checkforfile_js(); + $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" - .&Apache::loncommon::help_open_topic("Course_Convert_To_CSV", + .' '.&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')); if (&Apache::lonlocal::current_language() ne 'en') { @@ -3846,7 +3888,8 @@ sub print_first_users_upload_form { .&Apache::lonhtmlcommon::end_pick_box(); $str .= '

' - .'' + .'' .'

'; $r->print($str); @@ -3969,7 +4012,7 @@ sub upfile_drop_add { } elsif ($setting eq 'course') { $defaultrole = $env{'form.courserole'}; $defaultsec = $env{'form.sections'}; - } + } } elsif ($context eq 'author') { $defaultrole = $env{'form.defaultrole'}; } elsif ($context eq 'course') { @@ -4129,7 +4172,7 @@ sub upfile_drop_add { if ($entries{$fields{'domain'}} ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) { $r->print('
'. ''.$entries{$fields{'domain'}}. - ': '.&mt('Unacceptable domain for user [_2] [_3] [_4] [_5]',$fname,$mname,$lname,$gen)); + ': '.&mt('Unacceptable domain for user [_1] [_2] [_3] [_4]',$fname,$mname,$lname,$gen)); next; } my $username = $entries{$fields{'username'}}; @@ -4461,7 +4504,7 @@ sub upfile_drop_add { if (! defined($classlist)) { $r->print('
'. ''. - &mt('There are no students with current/future access to the course.'). + '

'.&mt('There are no students with current/future access to the course.').'

'. '
'."\n"); } elsif (ref($classlist) eq 'HASH') { # Remove the students we just added from the list of students. @@ -4585,11 +4628,13 @@ sub print_drop_menu { '
'."\n"); my $classlist = &Apache::loncoursedata::get_classlist(); if (! defined($classlist)) { + my $msg = ''; if ($crstype eq 'Community') { - $r->print(&mt('There are no members currently enrolled.')."\n"); + $msg = &mt('There are no members currently enrolled.'); } else { - $r->print(&mt('There are no students currently enrolled.')."\n"); + $msg = &mt('There are no students currently enrolled.'); } + $r->print('

'.$msg."

\n"); } else { &show_drop_list($r,$classlist,'nosort',$permission,$crstype); } @@ -4922,7 +4967,7 @@ 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} [quant,_1,user role,user roles,no user roles].",$count).'

'); if ($count > 0) { if ($choice eq 'revoke' || $choice eq 'drop') { $r->print('

'.&mt('Re-enabling will re-activate data for the role.').'

'); @@ -4939,7 +4984,10 @@ sub update_user_list { if ($choice eq 'drop') { $linktext = &mt('Display current class roster'); } - $r->print(''.$linktext.'
'."\n"); + $r->print( + &Apache::lonhtmlcommon::actionbox( + [''.$linktext.'']) + .''."\n"); } sub dates_feedback { @@ -4947,7 +4995,7 @@ sub dates_feedback { my $dates; if ($start < $now) { if ($end == 0) { - $dates .= &mt('role(s) active now; no end date'); + $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 { @@ -5144,7 +5192,7 @@ sub setsections_javascript { 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 ', + youh => 'You had selected', secs => 'sections.', plmo => 'Please modify your selections so they include no more than one section.', mayn => 'may not be used as the name for a section, as it is a reserved word.',