--- loncom/interface/lonuserutils.pm 2023/12/10 04:31:41 1.184.4.10.2.6 +++ loncom/interface/lonuserutils.pm 2024/01/05 04:09:47 1.184.4.10.2.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.184.4.10.2.6 2023/12/10 04:31:41 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.184.4.10.2.7 2024/01/05 04:09:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1607,6 +1607,24 @@ sub print_userlist { if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'username'; } + my ($showstart,$showend); + if (($env{'form.Status'} eq '') && ($env{'form.phase'} eq '') && + ($env{'form.showrole'} eq '') && ($context eq 'course') && + ($env{'request.course.id'} ne '') && + ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'} ne '')) { + my $now = time; + my $startaccess = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_start_date'}; + my $endaccess = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_end_date'}; + if (($startaccess) && ($startaccess > $now)) { + $env{'form.Status'} = 'Future'; + $showstart = 1; + } + if (($endaccess ne '') && ($endaccess != 0) && ($endaccess < $now)) { + $env{'form.Status'} = 'Expired'; + undef($showstart); + $showend = 1; + } + } if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { $env{'form.Status'} = 'Active'; } @@ -1674,7 +1692,7 @@ sub print_userlist { $r->print(§ion_group_filter($cnum,$cdom)); } $r->print('
'. - &column_checkboxes($context,$mode,$formname,$showcredits). + &column_checkboxes($context,$mode,$formname,$showcredits,$showstart,$showend). '
'); if ($env{'form.phase'} eq '') { $r->print('
'. @@ -2063,7 +2081,7 @@ sub get_cols_array { } sub column_checkboxes { - my ($context,$mode,$formname,$showcredits) = @_; + my ($context,$mode,$formname,$showcredits,$showstart,$showend) = @_; my @cols = &get_cols_array($context,$mode,$showcredits); my @showncols = &Apache::loncommon::get_env_multiple('form.showcol'); my (%disabledchk,%unchecked); @@ -2076,11 +2094,21 @@ sub column_checkboxes { if ($showcredits) { $unchecked{'credits'} = 1; } - } elsif ($context eq 'domain') { + my %curr_groups = &Apache::longroup::coursegroups(); + unless (keys(%curr_groups)) { + $unchecked{'groups'} = 1; + } + } elsif ($context eq 'domain') { $unchecked{'extent'} = 1; } - $unchecked{'start'} = 1; - $unchecked{'end'} = 1; + if ($showstart) { + $unchecked{'lastlogin'} = 1; + } else { + $unchecked{'start'} = 1; + } + unless ($showend) { + $unchecked{'end'} = 1; + } } else { if ($env{'form.Status'} ne 'Any') { $disabledchk{'status'} = 1;