[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm loncreateuser.pm lonrequestcourse.pm

raeburn raeburn@source.lon-capa.org
Thu, 14 Jan 2010 20:08:14 -0000


This is a MIME encoded message

--raeburn1263499694
Content-Type: text/plain

raeburn		Thu Jan 14 20:08:14 2010 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm lonrequestcourse.pm 
                     	loncoursequeueadmin.pm 
  Log:
  - Domain Coordinator Modify user screen.
    - Rights to request different course types in user's domain
      now shown if defaults apply to user.
    - &get_processtype moved from lonrequestcourse.pm loncoursequeueadmin.pm
      to be more widely available.
    - Additional arguments prepended to &get_processtype() to allow use 
      where request rights are retrieved for a user different to the one 
      requesting the information (i.e., a DC).
  
  
--raeburn1263499694
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100114200814.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.331 loncom/interface/loncreateuser.pm:1.332
--- loncom/interface/loncreateuser.pm:1.331	Tue Dec 29 20:00:26 2009
+++ loncom/interface/loncreateuser.pm	Thu Jan 14 20:08:13 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.331 2009/12/29 20:00:26 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.332 2010/01/14 20:08:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -219,7 +219,7 @@
 sub build_tools_display {
     my ($ccuname,$ccdomain,$context) = @_;
     my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,
-        $colspan);
+        $colspan,$isadv,%domconfig);
     my %lt = &Apache::lonlocal::texthash (
                    'blog'       => "Personal User Blog",
                    'aboutme'    => "Personal Information Page",
@@ -243,6 +243,9 @@
         %reqtitles = &courserequest_titles();
         %reqdisplay = &courserequest_display();
         $colspan = ' colspan="2"';
+        %domconfig =
+            &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
+        $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
     } else {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                           'tools.aboutme','tools.portfolio','tools.blog');
@@ -289,7 +292,14 @@
                    &Apache::loncommon::start_data_table_row()."\n";
         if ($context eq 'requestcourses') {
             my ($curroption,$currlimit);
-            $curroption = $userenv{$context.'.'.$item};
+            if ($userenv{$context.'.'.$item} ne '') {
+                $curroption = $userenv{$context.'.'.$item};
+            } else {
+                my (@inststatuses);
+                $curroption =
+                    &Apache::loncoursequeueadmin::get_processtype($ccuname,$ccdomain,$isadv,$ccdomain,
+                                                               $item,\@inststatuses,\%domconfig);
+            }
             if (!$curroption) {
                 $curroption = 'norequest';
             }
@@ -2680,7 +2690,7 @@
                                 $newenvhash{'environment.requestcourses.'.$key} =
                                     $changeHash{'requestcourses.'.$key};
                                 if ($changeHash{'requestcourses.'.$key} ne '') {
-                                    $newenvhash{'environment.canrequest.'.$key} = 1
+                                    $newenvhash{'environment.canrequest.'.$key} = 1;
                                 } else {
                                     $newenvhash{'environment.canrequest.'.$key} =
           &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.42 loncom/interface/lonrequestcourse.pm:1.43
--- loncom/interface/lonrequestcourse.pm:1.42	Fri Jan  1 23:17:31 2010
+++ loncom/interface/lonrequestcourse.pm	Thu Jan 14 20:08:13 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.42 2010/01/01 23:17:31 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.43 2010/01/14 20:08:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,8 +94,6 @@
 
 =item print_request_outcome()
 
-=item get_processtype()
-
 =item check_autolimit()
 
 =item retrieve_settings()
@@ -2784,7 +2782,9 @@
                     personnel      => \%personnel,
                   };
     my (@inststatuses,$storeresult,$creationresult);
-    my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);
+    my $val = 
+        &Apache::loncoursequeueadmin::get_processtype($env{'user.name'},$env{'user.domain'},
+            $env{'user.adv'},$dom,$crstype,\@inststatuses,\%domconfig);
     if ($val eq '') {
         if ($crstype eq 'official') {
             $output = &mt('You are not permitted to request creation of official courses.');
@@ -3145,94 +3145,6 @@
     return $output;
 }
 
-sub get_processtype {
-    my ($dom,$crstype,$inststatuses,$domconfig) = @_;
-    return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
-    my (%userenv,%settings,$val);
-    my @options = ('autolimit','validate','approval');
-    if ($dom eq $env{'user.domain'}) {
-        %userenv = 
-            &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
-                '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 (($env{'user.adv'}) && ($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($env{'user.domain'},
-                      $env{'user.name'},'reqcrsotherdom.'.$env{'form.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 check_autolimit {
     my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
     my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.12 loncom/interface/loncoursequeueadmin.pm:1.13
--- loncom/interface/loncoursequeueadmin.pm:1.12	Wed Nov 18 19:15:45 2009
+++ loncom/interface/loncoursequeueadmin.pm	Thu Jan 14 20:08:13 2010
@@ -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.13 2010/01/14 20:08:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,7 +33,7 @@
 
 =head1 SYNOPSIS
 
-Adminitsration utilities used by domain coordinators for queued course creation requests, and by course coordinators for queued self-enrollment requests.
+Administration utilities used by domain coordinators for queued course creation requests, and by course coordinators for queued self-enrollment requests.
 
 This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.
@@ -50,6 +50,14 @@
 
 =item get_student_counts()
 
+=item course_creation()
+
+=item build_batchcreatehash()
+ 
+=item can_clone_course()
+
+=item get_processtype()
+
 =back
 
 =cut
@@ -1032,4 +1040,95 @@
     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;
+}
+
 1;

--raeburn1263499694--