--- loncom/interface/lonuserutils.pm 2012/10/02 18:08:12 1.142 +++ loncom/interface/lonuserutils.pm 2013/07/15 14:55:14 1.153 @@ -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.153 2013/07/15 14:55:14 bisitz 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( + '' + ); } ############################################################### @@ -381,6 +399,12 @@ sub javascript_validations { $param{'curr_autharg'} = $curr_authfield; } + my $showcredits; + my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); + if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { + $showcredits = 1; + } + my ($setsection_call,$setsections_js); my $finish = " vf.submit();\n"; if ($mode eq 'upload') { @@ -390,13 +414,14 @@ sub javascript_validations { $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');'; $setsections_js = &setsections_javascript($param{'formname'},$groupslist, - $mode,'',$crstype); + $mode,'',$crstype,$showcredits); } else { $setsection_call = "'ok'"; } } elsif ($context eq 'domain') { $setsection_call = 'setCourse()'; - $setsections_js = &dc_setcourse_js($param{'formname'},$mode,$context); + $setsections_js = &dc_setcourse_js($param{'formname'},$mode, + $context,$showcredits); } $finish = " var checkSec = $setsection_call\n". " if (checkSec == 'ok') {\n". @@ -419,13 +444,16 @@ sub javascript_validations { domain => 'The optional domain field was not specified.', continue => 'Continue adding users?', ); + if ($showcredits) { + $alert{'credits'} = &mt('The optional credits field was not specified'); + } if (($mode eq 'upload') && ($context eq 'domain')) { $alert{'inststatus'} = &mt('The optional affiliation field was not specified'); } my $function_name = <<"END"; $setsections_js -function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus) { +function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus,foundcredits) { END my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($domain); my $auth_checks; @@ -482,6 +510,7 @@ END return; } } +/* regexp here to check for non \d \. in credits */ END } else { $auth_checks .= (<{'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 @@ -638,6 +677,7 @@ function verify(vf,sec_caller) { var foundrole=0; var founddomain=0; var foundinststatus=0; + var foundcredits=0; var tw; for (i=0;i<=vf.nfields.value;i++) { tw=eval('vf.f'+i+'.selectedIndex'); @@ -650,8 +690,9 @@ function verify(vf,sec_caller) { if (tw==11) { foundrole=1; } if (tw==12) { founddomain=1; } if (tw==13) { foundinststatus=1; } + if (tw==14) { foundcredits=1; } } - verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus); + verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus,foundcredits); } // @@ -674,6 +715,7 @@ function verify(vf,sec_caller) { // 11 = role // 12 = domain // 13 = inststatus +// 14 = foundcredits function flip(vf,tf) { var nw=eval('vf.f'+tf+'.selectedIndex'); @@ -771,6 +813,7 @@ function verify(vf,sec_caller) { var foundrole=0; var founddomain=0; var foundinststatus=0; + var foundcredits=0; var tw; for (i=0;i<=vf.nfields.value;i++) { tw=eval('vf.f'+i+'.selectedIndex'); @@ -783,8 +826,9 @@ function verify(vf,sec_caller) { if (i==10 && tw!=0) { foundrole=1; } if (i==11 && tw!=0) { founddomain=1; } if (i==12 && tw!=0) { foundinstatus=1; } + if (i==13 && tw!=0) { foundcredits=1; } } - verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus); + verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus,foundcredits); } function flip(vf,tf) { @@ -816,7 +860,8 @@ 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,$crstype, + $showcredits) = @_; my $form = 'document.studentform'; my $formname = 'studentform'; my ($krbdef,$krbdefdom) = @@ -905,9 +950,15 @@ sub print_upload_manager_footer { &mt('Default role')) .&mt('Choose the role to assign to users without a value specified in the uploaded file.') } elsif ($context eq 'course') { - $Str .= &Apache::lonhtmlcommon::row_title( + if ($showcredits) { + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role, section and credits')) + .&mt('Choose the role and/or section(s) and/or credits to assign to users without values specified in the uploaded file.'); + } else { + $Str .= &Apache::lonhtmlcommon::row_title( &mt('Default role and section')) - .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.'); + .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.'); + } } else { $Str .= &Apache::lonhtmlcommon::row_title( &mt('Default role and/or section(s)')) @@ -915,7 +966,8 @@ sub print_upload_manager_footer { } if (($context eq 'domain') || ($context eq 'author')) { $Str .= '
'; - my ($options,$cb_script,$coursepick) = &default_role_selector($context,1); + my ($options,$cb_script,$coursepick) = + &default_role_selector($context,1,'',$showcredits); if ($context eq 'domain') { $Str .= '

' .''.&mt('Domain Level').'
' @@ -932,8 +984,13 @@ sub print_upload_manager_footer { } else { my ($cnum,$cdom) = &get_course_identity(); my $rowtitle = &mt('section'); - my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle, - $permission,$context,'upload',$crstype); + my $defaultcredits; + if ($showcredits) { + $defaultcredits = &get_defaultcredits(); + } + my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle,$permission, + $context,'upload',$crstype,$showcredits, + $defaultcredits); $Str .= $secbox .&Apache::lonhtmlcommon::row_closure(); my %lt; @@ -979,6 +1036,43 @@ sub print_upload_manager_footer { return; } +sub get_defaultcredits { + my ($cdom,$cnum) = @_; + + if ($cdom eq '' || $cnum eq '') { + return unless ($env{'request.course.id'}); + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } + return unless(($cdom =~ /^$match_domain$/) && ($cnum =~ /^$match_courseid$/)); + my ($defaultcredits,$domdefcredits); + my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); + if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { + my $instcode = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'}; + if ($instcode) { + $domdefcredits = $domdefaults{'officialcredits'}; + } else { + $domdefcredits = $domdefaults{'unofficialcredits'}; + } + } else { + return; + } + + if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { + $defaultcredits = $env{'course.'.$cdom.'_'.$cnum.'.internal.defaultcredits'}; + } elsif (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.defaultcredits'})) { + $defaultcredits = $env{'course.'.$cdom.'_'.$cnum.'.internal.defaultcredits'}; + } else { + my %crsinfo = + &Apache::lonnet::coursedescription("$cdom/$cnum",{'one_time' => 1}); + $defaultcredits = $crsinfo{'internal.defaultcredits'}; + } + if ($defaultcredits eq '') { + $defaultcredits = $domdefcredits; + } + return $defaultcredits; +} + sub forceid_change { my ($context) = @_; my $output = @@ -1000,7 +1094,7 @@ sub forceid_change { ############################################################### ############################################################### sub print_upload_manager_form { - my ($r,$context,$permission,$crstype) = @_; + my ($r,$context,$permission,$crstype,$showcredits) = @_; my $firstLine; my $datatoken; if (!$env{'form.datatoken'}) { @@ -1033,7 +1127,9 @@ sub print_upload_manager_form { 'domain_choice' => 'scalar', 'inststatus_choice' => 'scalar', }; - my $defdom = $env{'request.role.domain'}; + if ($showcredits) { + $col_setting_names->{'credits_choice'} = 'scalar'; + } if ($context eq 'course') { &Apache::loncommon::restore_course_settings('enrollment_upload', $col_setting_names); @@ -1041,6 +1137,7 @@ sub print_upload_manager_form { &Apache::loncommon::restore_settings($context,'user_upload', $col_setting_names); } + my $defdom = $env{'request.role.domain'}; # # Determine kerberos parameters as appropriate my ($krbdef,$krbdefdom) = @@ -1066,6 +1163,10 @@ sub print_upload_manager_form { ['role',&mt('Role'), $env{'form.role_choice'}], ['domain',&mt('Domain'), $env{'form.domain_choice'}], ['inststatus',&mt('Affiliation'), $env{'form.inststatus_choice'}]); + if ($showcredits) { + push(@field, + ['credits',&mt('Student Credits'), $env{'form.credits_choice'}]); + } if ($env{'form.upfile_associate'} eq 'reverse') { &Apache::loncommon::csv_print_samples($r,\@records); $i=&Apache::loncommon::csv_print_select_table($r,\@records, @@ -1082,9 +1183,8 @@ 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); + $context,$permission,$crstype,$showcredits); } sub setup_date_selectors { @@ -1241,7 +1341,7 @@ sub make_dates_default { } sub default_role_selector { - my ($context,$checkpriv,$crstype) = @_; + my ($context,$checkpriv,$crstype,$showcredits) = @_; my %customroles; my ($options,$coursepick,$cb_jscript); if ($context ne 'author') { @@ -1253,6 +1353,7 @@ sub default_role_selector { 'grs' => "Section", 'exs' => "Existing sections", 'new' => "New section", + 'crd' => "Credits", ); $options = ''; + } $cb_jscript = - &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform','courserole','Course/Community'); + &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform','courserole','Course/Community',$credit_elem); $coursepick = &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ''.$courseform.''.$lt{'rol'}.''. ''.$lt{'grs'}.''. + ''.$lt{'crd'}.''. &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row()."\n". ''."\n". @@ -1299,7 +1406,7 @@ sub default_role_selector { ''. ''. ''. - ''. + ''.$creditsinput. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table()."\n"; } @@ -1436,7 +1543,7 @@ sub my_custom_roles { sub print_userlist { my ($r,$mode,$permission,$context,$formname,$totcodes,$codetitles, - $idlist,$idlist_titles) = @_; + $idlist,$idlist_titles,$showcredits) = @_; my $format = $env{'form.output'}; if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'username'; @@ -1471,10 +1578,6 @@ sub print_userlist { @statuses = ('future'); } -# if ($context eq 'course') { -# $r->print(&display_adv_courseroles()); -# } - # # Interface output $r->print('
'."\n". ''. - &column_checkboxes($context,$mode,$formname). - '
'); + &column_checkboxes($context,$mode,$formname,$showcredits). + ''); 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); + my @cols = &infocolumns($context,$mode,$showcredits); if (!@cols) { - $r->print('
'. + $r->print('
'. &mt('No user information selected for display.').''. ''."\n"); return; @@ -1553,12 +1658,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 +1671,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,16 +1810,18 @@ 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; if ($env{'form.action'} eq 'modifystudent') { ($usercount) = &show_users_list($r,$context,'view',$permission, - $env{'form.Status'},\%userlist,$keylist); + $env{'form.Status'},\%userlist,$keylist,'', + $showcredits); } else { ($usercount) = &show_users_list($r,$context,$env{'form.output'}, - $permission,$env{'form.Status'},\%userlist,$keylist); + $permission,$env{'form.Status'},\%userlist, + $keylist,'',$showcredits); } if (!$usercount) { $r->print('
' @@ -1837,12 +1942,12 @@ sub section_group_filter { } sub infocolumns { - my ($context,$mode) = @_; + my ($context,$mode,$showcredits) = @_; my @cols; if (($mode eq 'pickauthor') || ($mode eq 'autoenroll')) { - @cols = &get_cols_array($context,$mode); + @cols = &get_cols_array($context,$mode,$showcredits); } else { - my @posscols = &get_cols_array($context,$mode); + my @posscols = &get_cols_array($context,$mode,$showcredits); if ($env{'form.phase'} ne '') { my @checkedcols = &Apache::loncommon::get_env_multiple('form.showcol'); foreach my $col (@checkedcols) { @@ -1858,7 +1963,7 @@ sub infocolumns { } sub get_cols_array { - my ($context,$mode) = @_; + my ($context,$mode,$showcredits) = @_; my @cols; if ($mode eq 'pickauthor') { @cols = ('username','fullname','status','email'); @@ -1868,9 +1973,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'); } @@ -1879,19 +1981,25 @@ sub get_cols_array { } push(@cols,'email'); if (($context eq 'course') && ($mode ne 'autoenroll')) { + if ($showcredits) { + push(@cols,'credits'); + } push(@cols,'lastlogin','clicker'); } if (($context eq 'course') && ($mode ne 'autoenroll') && ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) { push(@cols,'photos'); } + if ($context eq 'domain') { + push (@cols,'extent'); + } } return @cols; } sub column_checkboxes { - my ($context,$mode,$formname) = @_; - my @cols = &get_cols_array($context,$mode); + my ($context,$mode,$formname,$showcredits) = @_; + my @cols = &get_cols_array($context,$mode,$showcredits); my @showncols = &Apache::loncommon::get_env_multiple('form.showcol'); my (%disabledchk,%unchecked); if ($env{'form.phase'} eq '') { @@ -1899,20 +2007,33 @@ sub column_checkboxes { if ($context eq 'course') { $disabledchk{'role'} = 1; $unchecked{'photo'} = 1; + $unchecked{'clicker'} = 1; + if ($showcredits) { + $unchecked{'credits'} = 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 +2073,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; @@ -1978,6 +2106,7 @@ sub get_column_names { 'end' => "end date", 'status' => "status", 'role' => "role", + 'credits' => "credits", 'type' => "enroll type/action", 'email' => "e-mail address", 'photo' => "photo", @@ -1988,11 +2117,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; } @@ -2246,29 +2376,6 @@ sub instcode_from_coursefilter { return $instcode; } -sub display_adv_courseroles { - my $output; - # - # List course personnel - my %coursepersonnel = - &Apache::lonnet::get_course_adv_roles($env{'request.course.id'}); - # - $output = '
'.&Apache::loncommon::start_data_table(); - foreach my $role (sort(keys(%coursepersonnel))) { - next if ($role =~ /^\s*$/); - $output .= &Apache::loncommon::start_data_table_row(). - ''.$role.''; - foreach my $user (split(',',$coursepersonnel{$role})) { - my ($puname,$pudom)=split(':',$user); - $output .= ' '.&Apache::loncommon::aboutmewrapper( - &Apache::loncommon::plainname($puname,$pudom), - $puname,$pudom); - } - $output .= ''.&Apache::loncommon::end_data_table_row(); - } - $output .= &Apache::loncommon::end_data_table(); -} - sub make_keylist_array { my ($index,$keylist); $index->{'domain'} = &Apache::loncoursedata::CL_SDOM(); @@ -2287,6 +2394,7 @@ sub make_keylist_array { $index->{'extent'} = &Apache::loncoursedata::CL_EXTENT(); $index->{'photo'} = &Apache::loncoursedata::CL_PHOTO(); $index->{'thumbnail'} = &Apache::loncoursedata::CL_THUMBNAIL(); + $index->{'credits'} = &Apache::loncoursedata::CL_CREDITS(); foreach my $key (keys(%{$index})) { $keylist->[$index->{$key}] = $key; } @@ -2335,7 +2443,8 @@ sub process_date_info { } sub show_users_list { - my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname)=@_; + my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname, + $showcredits)=@_; if ($formname eq '') { $formname = 'studentform'; } @@ -2350,6 +2459,9 @@ sub show_users_list { my @sortable = ('username','domain','id','fullname','start','end','email','role'); if ($context eq 'course') { push(@sortable,('section','groups','type')); + if ($showcredits) { + push(@sortable,'credits'); + } } else { push(@sortable,'extent'); } @@ -2360,11 +2472,12 @@ sub show_users_list { $sortby = 'username'; } my $setting = $env{'form.roletype'}; - my ($cid,$cdom,$cnum,$classgroups,$crstype); + my ($cid,$cdom,$cnum,$classgroups,$crstype,$defaultcredits); if ($context eq 'course') { $cid = $env{'request.course.id'}; $crstype = &Apache::loncommon::course_type(); ($cnum,$cdom) = &get_course_identity($cid); + $defaultcredits = $env{'course.'.$cid.'.internal.defaultcredits'}; ($classgroups) = &Apache::loncoursedata::get_group_memberships( $userlist,$keylist,$cdom,$cnum); if ($mode eq 'autoenroll') { @@ -2457,7 +2570,7 @@ END $r->print(< END - my @cols = &infocolumns($context,$mode); + my @cols = &infocolumns($context,$mode,$showcredits); my %coltxt = &get_column_names($context); my %acttxt = &Apache::lonlocal::texthash( 'pr' => "Proceed", @@ -2579,7 +2692,11 @@ END if ($env{'form.userwin'}) { $checkwin = ' checked="checked"'; } - $output .= ''.$lt{'owin'}.''; + $output .= + '' + .''; } $output .= "\n".'
'."\n". &Apache::loncommon::start_data_table(). @@ -2755,6 +2872,11 @@ END 'gif','thumbnail'); } } + if (($role eq 'st') && ($defaultcredits)) { + if ($userlist->{$user}->[$index{'credits'}] eq '') { + $userlist->{$user}->[$index{'credits'}] = $defaultcredits; + } + } } } my %emails = &Apache::loncommon::getemails($uname,$udom); @@ -2872,7 +2994,8 @@ END $checkval .= ':'.$in{'section'}; if ($role eq 'st') { $checkval .= ':'.$in{'type'}.':'. - $in{'lockedtype'}; + $in{'lockedtype'}.':'. + $in{'credits'}; } } } @@ -2919,7 +3042,7 @@ END } else { $r->print(' '."\n"); } - } + } } else { $r->print(''.$in{$item}.''."\n"); } @@ -3120,6 +3243,7 @@ sub select_actions { chgdates => "Change starting/ending dates", chgsec => "Change section associated with user roles", ); + # FIXME Add an option to change credits for student roles. my ($output,$options,%choices); # FIXME Disable actions for now for roletype=course in domain context if ($context eq 'domain' && $setting eq 'course') { @@ -3247,11 +3371,13 @@ ENDTWO } sub date_section_selector { - my ($context,$permission,$crstype) = @_; + my ($context,$permission,$crstype,$showcredits) = @_; my $callingform = $env{'form.callingform'}; my $formname = 'dateselect'; my $groupslist = &get_groupslist(); - my $sec_js = &setsections_javascript($formname,$groupslist); + my $sec_js = + &setsections_javascript($formname,$groupslist,undef,undef,$crstype, + $showcredits); my $output = <<"END";