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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Wed, 05 Dec 2007 02:55:40 -0000


raeburn		Tue Dec  4 21:55:40 2007 EDT

  Modified files:              
    /loncom/interface	lonmodifycourse.pm 
  Log:
  - Use lonnet::coursedescription() to extract cnum from cid instead of splitting on underscore. 
  - Formname for page to change DC-modifiable enrollment settings set to setparms, so
   breadcrumbs links work
  - Fix scope in &check_course() so $cdesc is retrieved. 
  
  
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.34 loncom/interface/lonmodifycourse.pm:1.35
--- loncom/interface/lonmodifycourse.pm:1.34	Sat Oct  6 00:32:49 2007
+++ loncom/interface/lonmodifycourse.pm	Tue Dec  4 21:55:40 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.34 2007/10/06 04:32:49 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.35 2007/12/05 02:55:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -370,7 +370,7 @@
         $curr_authfield = $curr_authtype.'arg';
     }
     my $javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield);
-    my %param = ( formname => 'document.cmod',
+    my %param = ( formname => 'document.'.$env{'form.phase'},
 	   kerb_def_dom => $krbdefdom,
 	   kerb_def_auth => $krbdef,
            mode => 'modifycourse',
@@ -437,7 +437,7 @@
     my $mainheader = &mt('Course settings modifiable by [_1] only.',$dctitle);
     my $hidden_elements = &hidden_form_elements();
     $r->print(<<ENDDOCUMENT);
-<form action="/adm/modifycourse" method="post" name="cmod">
+<form action="/adm/modifycourse" method="post" name="$env{'form.phase'}">
 <h3>$mainheader</h3>
 </p><p>
 <table width="100%" cellspacing="6" cellpadding="6">
@@ -807,31 +807,36 @@
 sub check_course {
     my ($r,$dom,$domdesc) = @_;
     my ($ok_course,$description,$instcode,$owner);
-    if (defined($env{'form.pickedcourse'})) {
-        my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
-        if ($cdom eq $dom) {
-            my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
-                                               $cnum,undef,undef,'.');
-            if (keys(%courseIDs) > 0) {
-                $ok_course = 'ok';
-                my ($description,$instcode,$owner);
-                if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
-                    $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
-                    $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
-                    $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};          
-                } else {
-                    ($description,$instcode,$owner) = 
-                                       split(/:/,$courseIDs{$cdom.'_'.$cnum});
-                }
-                $description = &unescape($description);
-                $instcode = &unescape($instcode);
-                if ($instcode) {
-                    $description .= " ($instcode)";
-                } 
+    my %args = (
+                 one_time => 1,
+               );
+    my %coursehash = 
+        &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
+    my $cnum = $coursehash{'num'};
+    my $cdom = $coursehash{'domain'};
+    if ($cdom eq $dom) {
+        my $description;
+        my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
+                                           $cnum,undef,undef,'.');
+        if (keys(%courseIDs) > 0) {
+            $ok_course = 'ok';
+            my ($instcode,$owner);
+            if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
+                $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
+                $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
+                $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};          
+            } else {
+                ($description,$instcode,$owner) = 
+                                   split(/:/,$courseIDs{$cdom.'_'.$cnum});
+            }
+            $description = &unescape($description);
+            $instcode = &unescape($instcode);
+            if ($instcode) {
+                $description .= " ($instcode)";
             }
+            return ($ok_course,$description);
         }
     }
-    return ($ok_course,$description);
 }
 
 sub course_settings_descrip {