--- loncom/interface/loncoursequeueadmin.pm 2009/11/18 19:15:45 1.12 +++ loncom/interface/loncoursequeueadmin.pm 2010/01/15 03:29:54 1.14 @@ -1,7 +1,7 @@ # The LearningOnline Network # Utilities to administer domain course requests and course self-enroll requests # -# $Id: loncoursequeueadmin.pm,v 1.12 2009/11/18 19:15:45 raeburn Exp $ +# $Id: loncoursequeueadmin.pm,v 1.14 2010/01/15 03:29:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,7 +33,9 @@ Apache::loncoursequeueadmin.pm =head1 SYNOPSIS -Adminitsration utilities used by domain coordinators for queued course creation requests, and by course coordinators for queued self-enrollment requests. +Utilities used by domain coordinators to administer queued course creation requests, +and by course coordinators for queued self-enrollment requests, and by general +users to display their queued self-enrollment requests. This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org. @@ -50,6 +52,16 @@ described at http://www.lon-capa.org. =item get_student_counts() +=item course_creation() + +=item build_batchcreatehash() + +=item can_clone_course() + +=item get_processtype() + +=item queued_selfenrollment() + =back =cut @@ -1032,4 +1044,141 @@ sub can_clone_course { return $canclone; } +sub get_processtype { + my ($uname,$udom,$isadv,$dom,$crstype,$inststatuses,$domconfig) = @_; + return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); + if ($uname eq '' || $udom eq '') { + $uname = $env{'user.name'}; + $udom = $env{'user.domain'}; + $isadv = $env{'user.adv'}; + } + my (%userenv,%settings,$val); + my @options = ('autolimit','validate','approval'); + if ($dom eq $udom) { + %userenv = + &Apache::lonnet::userenvironment($udom,$uname,'requestcourses.'.$crstype,'inststatus'); + if ($userenv{'requestcourses.'.$crstype}) { + $val = $userenv{'requestcourses.'.$crstype}; + @{$inststatuses} = ('_custom_'); + } else { + my ($task,%alltasks); + if (ref($domconfig->{'requestcourses'}) eq 'HASH') { + %settings = %{$domconfig->{'requestcourses'}}; + if (ref($settings{$crstype}) eq 'HASH') { + if (($isadv) && ($settings{$crstype}{'_LC_adv'} ne '')) { + $val = $settings{$crstype}{'_LC_adv'}; + @{$inststatuses} = ('_LC_adv_'); + } else { + if ($userenv{'inststatus'} ne '') { + @{$inststatuses} = split(',',$userenv{'inststatus'}); + } else { + @{$inststatuses} = ('default'); + } + foreach my $status (@{$inststatuses}) { + if (exists($settings{$crstype}{$status})) { + my $value = $settings{$crstype}{$status}; + next unless ($value); + unless (exists($alltasks{$value})) { + if (ref($alltasks{$value}) eq 'ARRAY') { + unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) { + push(@{$alltasks{$value}},$status); + } + } else { + @{$alltasks{$value}} = ($status); + } + } + } + } + my $maxlimit = 0; + + foreach my $key (sort(keys(%alltasks))) { + if ($key =~ /^autolimit=(\d*)$/) { + if ($1 eq '') { + $val ='autolimit='; + last; + } elsif ($1 > $maxlimit) { + $maxlimit = $1; + } + } + } + if ($maxlimit) { + $val = 'autolimit='.$maxlimit; + } else { + foreach my $option (@options) { + if ($alltasks{$option}) { + $val = $option; + last; + } + } + } + } + } + } + } + } else { + %userenv = &Apache::lonnet::userenvironment($udom,$uname,'reqcrsotherdom.'.$crstype); + if ($userenv{'reqcrsotherdom.'.$crstype}) { + my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype}); + my $optregex = join('|',@options); + foreach my $item (@doms) { + my ($extdom,$extopt) = split(':',$item); + if ($extdom eq $dom) { + if ($extopt =~ /^($optregex)(=?\d*)$/) { + $val = $1.$2; + } + last; + } + } + @{$inststatuses} = ('_external_'); + } + } + return $val; +} + +sub queued_selfenrollment { + my ($notitle) = @_; + my $output; + my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests'); + my %reqs_by_date; + foreach my $item (keys(%selfenrollrequests)) { + if (ref($selfenrollrequests{$item}) eq 'HASH') { + if ($selfenrollrequests{$item}{'status'} eq 'request') { + if ($selfenrollrequests{$item}{'timestamp'}) { + push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item); + } + } + } + } + if (keys(%reqs_by_date)) { + my $rolename = &Apache::lonnet::plaintext('st'); + unless ($notitle) { + $output .= ''.&mt('Enrollment requests pending Course Coordinator approval').'
'; + } + $output .= &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Date requested').''.&mt('Course title').''. + ''.&mt('User role').''.&mt('Section').''. + &Apache::loncommon::end_data_table_header_row(); + my @sorted = sort { $a <=> $b } (keys(%reqs_by_date)); + foreach my $item (@sorted) { + if (ref($reqs_by_date{$item}) eq 'ARRAY') { + foreach my $crs (@{$reqs_by_date{$item}}) { + my %courseinfo = &Apache::lonnet::coursedescription($crs); + my $usec = $selfenrollrequests{$crs}{'section'}; + if ($usec eq '') { + $usec = &mt('No section'); + } + $output .= &Apache::loncommon::start_data_table_row(). + ''.&Apache::lonlocal::locallocaltime($item).''. + ''.$courseinfo{'description'}.''. + ''.$rolename.''.$usec.''. + &Apache::loncommon::end_data_table_row(); + } + } + } + $output .= &Apache::loncommon::end_data_table(); + } + return $output; +} + 1;