--- loncom/interface/lonuserutils.pm 2012/12/31 15:28:36 1.146 +++ 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.146 2012/12/31 15:28:36 raeburn 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('<p>' - .&mt('Total number of records found in file: [_1]' - ,'<b>'.$distotal.'</b>') - ."</p>\n"); - $r->print('<div class="LC_left_float"><h3>'. - &mt('Identify fields in uploaded list')."</h3>\n"); - $r->print(&mt('Enter as many fields as you can.<br /> The system will inform you and bring you back to this page, <br /> if the data selected are insufficient to add users.')."<br />\n"); + $r->print( + '<h3>'.&mt('Identify fields in uploaded list')."</h3>\n". + '<p class="LC_info">'. + &mt('Total number of records found in file: [_1]' + ,'<b>'.$distotal.'</b>'). + "</p>\n" + ); + if ($distotal == 0) { + $r->print('<p class="LC_warning">'.&mt('None found').'</p>'); + } + $r->print( + '<p>'. + &mt('Enter as many fields as you can.').'<br />'. + &mt('The system will inform you and bring you back to this page,[_1]if the data selected are insufficient to add users.','<br />'). + "</p>\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('<br /><label><input type="checkbox" name="noFirstLine"'.$checked.' />'. - &mt('Ignore First Line').'</label><br />'); - $r->print('<br /><input type="button" value="'.&mt('Reverse Association').'" '. + $r->print( + '<div class="LC_left_float">'. + '<fieldset><legend>'.&mt('Functions').'</legend>'. + '<label><input type="checkbox" name="noFirstLine"'.$checked.' />'. + &mt('Ignore First Line').'</label>'. + ' <input type="button" value="'.&mt('Reverse Association').'" '. 'name="Reverse Association" '. - 'onclick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'); - $r->print("<br /><br />\n". - '<script type="text/javascript" language="Javascript">'."\n". - '// <![CDATA['."\n". - $javascript."\n".$javascript_validations."\n". - '// ]]>'."\n". - '</script>'); + 'onclick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'. + '</fieldset></div><br clear="all" />' + ); + $r->print( + '<script type="text/javascript" language="Javascript">'."\n". + '// <![CDATA['."\n". + $javascript."\n".$javascript_validations."\n". + '// ]]>'."\n". + '</script>' + ); } ############################################################### @@ -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('</div>'); &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear, $context,$permission,$crstype); } @@ -1513,20 +1530,22 @@ sub print_userlist { } $r->print('</div><div class="LC_left_float">'. &column_checkboxes($context,$mode,$formname). - '</div><br clear="all" />'); + '</div>'); if ($env{'form.phase'} eq '') { - $r->print(&list_submit_button(&mt('Display List of Users'))."\n". + $r->print('<br clear="all" />'. + &list_submit_button(&mt('Display List of Users'))."\n". '<input type="hidden" name="phase" value="" /></form>'); 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('<br clear="all" />'. + &list_submit_button(&mt('Update Display'))."\n"); } my @cols = &infocolumns($context,$mode); if (!@cols) { - $r->print('<hr /><span class="LC_warning">'. + $r->print('<hr clear="all" /><span class="LC_warning">'. &mt('No user information selected for display.').'</span>'. '<input type="hidden" name="phase" value="display" /></form>'."\n"); return; @@ -1553,12 +1572,10 @@ sub print_userlist { &Apache::lonhtmlcommon::course_selection($formname,$numcodes, $codetitles,$idlist,$idlist_titles,$crstype, \@standardnames); - $r->print('<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n". - &Apache::lonhtmlcommon::start_pick_box()."\n". - &Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n". + $r->print('<div class="LC_left_float">'. + '<fieldset><legend>'.$title.'</legend>'."\n". $courseform."\n". - &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::end_pick_box().'</p>'. + '</fieldset></div><br clear="all" />'. '<p><input type="hidden" name="origroletype" value="'.$env{'form.roletype'}.'" />'. &list_submit_button(&mt('Update Display')). "\n".'</p><span class="LC_warning">'.$warning.'</span>'."\n"); @@ -1568,10 +1585,10 @@ sub print_userlist { $clearcoursepick = 1; } if (($env{'form.coursepick'}) && (!$clearcoursepick)) { - $r->print('<hr />'.&mt('Searching').' ...<br /> <br />'); + $r->print('<hr />'.&mt('Searching ...').'<br /> <br />'); } } else { - $r->print('<hr /><div id="searching">'.&mt('Searching').' ...</div>'); + $r->print('<hr clear="all" /><div id="searching">'.&mt('Searching ...').'</div>'); } $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('<p class="LC_info"'.$msg.'</p>'."\n") if $msg; + $r->print('<p class="LC_info">'.$msg.'</p>'."\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,8 +1916,10 @@ 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 { @@ -1910,9 +1929,17 @@ sub column_checkboxes { 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 = '<fieldset><legend>'.&mt('Information to show').'</legend>'."\n".'<span class="LC_nobreak">'. '<input type="button" onclick="javascript:checkAll(document.'.$formname.'.showcol);" value="'.&mt('check all').'" />'. @@ -1952,9 +1979,16 @@ sub column_checkboxes { } else { $output .= '<td>'; } - $output .= '<label><input id="showcol'.$cols[$i].'" type="checkbox" name="showcol" value="'.$cols[$i].'"'.$checked.' />'. - $lt{$cols[$i]}.'</label></td>'; - + my $style; + if ($cols[$i] eq 'extent') { + if (($env{'form.roletype'} eq 'domain') || ($env{'form.roletype'} eq '')) { + $style = ' style="display: none;"'; + } + } + $output .= '<span id="show'.$cols[$i].'"'.$style.'><label>'. + '<input id="showcol'.$cols[$i].'" type="checkbox" name="showcol" value="'.$cols[$i].'"'.$checked.' /><span id="showcoltext'.$cols[$i].'">'. + $lt{$cols[$i]}.'</span>'. + '</label></span></td>'; } $output .= '</tr></table></fieldset>'; 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; } @@ -2923,7 +2958,7 @@ END } else { $r->print('<td> </td>'."\n"); } - } + } } else { $r->print('<td>'.$in{$item}.'</td>'."\n"); } @@ -3417,7 +3452,7 @@ sub section_picker { '<input type="hidden" name="sections" value="" />'."\n". '</td></tr></table>'."\n"; } else { - $secbox .= '<input type="hidden" name="sections" value="'. + $secbox .= '<input type="hidden" name="sections" value="'. $env{'request.course.sec'}.'" />'. $env{'request.course.sec'}; } @@ -3822,16 +3857,17 @@ sub print_first_users_upload_form { $str .= '<input type="hidden" name="action" value="upload" />'; $str .= '<input type="hidden" name="state" value="got_file" />'; + $str .= &Apache::grades::checkforfile_js(); + $str .= '<h2>'.&mt('Upload a file containing information about users').'</h2>'."\n"; # Excel and CSV Help - $str .= '<div class="LC_left_float">' + $str .= '<div class="LC_columnSection">' .&Apache::loncommon::help_open_topic("Course_Create_Class_List", &mt("How do I create a users list from a spreadsheet")) - .'</div><div class="LC_left_float">'."\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")) - .'</div><br clear="all" />'."\n"; + ."</div>\n"; $str .= &Apache::lonhtmlcommon::start_pick_box() .&Apache::lonhtmlcommon::row_title(&mt('File')); if (&Apache::lonlocal::current_language() ne 'en') { @@ -3852,7 +3888,8 @@ sub print_first_users_upload_form { .&Apache::lonhtmlcommon::end_pick_box(); $str .= '<p>' - .'<input type="submit" name="fileupload" value="'.&mt('Next').'" />' + .'<input type="submit" name="fileupload" value="'.&mt('Next').'"' + .' onclick="javascript:checkUpload(this.form);" />' .'</p>'; $r->print($str); @@ -3975,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') { @@ -4135,7 +4172,7 @@ sub upfile_drop_add { if ($entries{$fields{'domain'}} ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) { $r->print('<br />'. '<b>'.$entries{$fields{'domain'}}. - '</b>: '.&mt('Unacceptable domain for user [_2] [_3] [_4] [_5]',$fname,$mname,$lname,$gen)); + '</b>: '.&mt('Unacceptable domain for user [_1] [_2] [_3] [_4]',$fname,$mname,$lname,$gen)); next; } my $username = $entries{$fields{'username'}}; @@ -4958,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 {