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

raeburn raeburn@source.lon-capa.org
Fri, 21 Aug 2009 13:18:46 -0000


raeburn		Fri Aug 21 13:18:46 2009 EDT

  Modified files:              
    /loncom/interface	lonrequestcourse.pm 
  Log:
  - Eliminate repeated line for HTTP header generation.
  - coding style: unshift(), push()
  - for an official course but with no institutional codes to pick from adjust pages reached by prev and next from courseinfo and access dates pages.
  
  
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.19 loncom/interface/lonrequestcourse.pm:1.20
--- loncom/interface/lonrequestcourse.pm:1.19	Thu Aug 20 21:15:37 2009
+++ loncom/interface/lonrequestcourse.pm	Fri Aug 21 13:18:46 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.19 2009/08/20 21:15:37 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.20 2009/08/21 13:18:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -116,13 +116,11 @@
 
 sub handler {
     my ($r) = @_;
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->send_http_header;
     if ($r->header_only) {
-        &Apache::loncommon::content_type($r,'text/html');
-        $r->send_http_header;
         return OK;
     }
-    &Apache::loncommon::content_type($r,'text/html');
-    $r->send_http_header;
 
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     my $dom = &get_course_dom();
@@ -159,9 +157,10 @@
     $states{'view'} = ['pick_request','details','cancel','removal'];
     $states{'log'} = ['filter','display'];
     $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
+
     if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
         unless ($env{'form.state'} eq 'crstype') {
-            unshift (@{$states{'new'}},'codepick');
+            unshift(@{$states{'new'}},'codepick');
         }
     }
 
@@ -811,12 +810,19 @@
                 $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
                           &Apache::lonhtmlcommon::end_pick_box().'</div>');
             } else {
+                $next = $states->{$action}[$page+2];
                 $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
             }
         } else {
+            if ($crstype eq 'official') {
+                $next = $states->{$action}[$page+2];
+            }
             $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
         }
     } elsif ($prev eq 'codepick') {
+        if ($env{'form.instcode'} eq '') {
+            $prev = $states->{$action}[$page-2];
+        }
         $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
     } elsif ($state eq 'enrollment') {
         if ($crstype eq 'official') {
@@ -2391,7 +2397,7 @@
                                                 if (grep(/^\Q$sec\E/,@currsec)) {
                                                     $env{'form.person_'.$i.'_sec'} = $sec;
                                                 } else {
-                                                    push (@newsecs,$sec);
+                                                    push(@newsecs,$sec);
                                                 }
                                             }
                                         }