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

raeburn raeburn at source.lon-capa.org
Sun Mar 30 21:37:29 EDT 2014


raeburn		Mon Mar 31 01:37:29 2014 EDT

  Modified files:              
    /loncom/interface	lonmodifycourse.pm 
  Log:
  - Modify &check_course() to return additional item (ref to %coursehash),
    and eliminate passing of unused request object.  
  
  
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.70 loncom/interface/lonmodifycourse.pm:1.71
--- loncom/interface/lonmodifycourse.pm:1.70	Mon Mar 17 02:45:25 2014
+++ loncom/interface/lonmodifycourse.pm	Mon Mar 31 01:37:28 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.70 2014/03/17 02:45:25 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.71 2014/03/31 01:37:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -226,9 +226,16 @@
 }
 
 sub print_modification_menu {
-    my ($r,$cdesc,$domdesc,$dom,$type) = @_;
+    my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash) = @_;
     &print_header($r,$type);
-    my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text);
+    my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text,
+        $cdom,$cnum);
+    if (ref($coursehash) eq 'HASH') {
+        $cdom = $coursehash->{'domain'};
+        $cnum = $coursehash->{'num'};
+    } else {
+         ($cdom,$cnum) = split(/_/,$cid);
+    }
     if ($type eq 'Community') {
         $ccrole = 'co';
     } else {
@@ -1571,38 +1578,35 @@
 }
 
 sub check_course {
-    my ($r,$dom,$domdesc) = @_;
-    my ($ok_course,$description,$instcode,$owner);
-    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)";
+    my ($dom,$domdesc) = @_;
+    my ($ok_course,$description,$instcode);
+    my %coursehash;
+    if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
+        my %args;
+        unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
+            %args = (
+                      'one_time'      => 1,
+                      'freshen_cache' => 1,
+                    );
+        }
+        %coursehash =
+           &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
+        my $cnum = $coursehash{'num'};
+        my $cdom = $coursehash{'domain'};
+        $description = $coursehash{'description'};
+        $instcode = $coursehash{'internal.coursecode'};
+        if ($instcode) {
+            $description .= " ($instcode)";
+        }
+        if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
+            my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
+                                                          $cnum,undef,undef,'.');
+            if ($courseIDs{$cdom.'_'.$cnum}) {
+                $ok_course = 'ok';
             }
-            return ($ok_course,$description);
         }
     }
+    return ($ok_course,$description,\%coursehash);
 }
 
 sub course_settings_descrip {
@@ -1700,7 +1704,7 @@
             if ($phase eq 'courselist') {
                 &print_course_selection_page($r,$dom,$domdesc);
             } else {
-                my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
+                my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
                 if ($checked eq 'ok') {
                     my $enter_text;
                     if ($type eq 'Community') {
@@ -1712,7 +1716,8 @@
                         &Apache::lonhtmlcommon::add_breadcrumb
                         ({href=>"javascript:changePage(document.$phase,'menu')",
                           text=>"Pick action"});
-                        &print_modification_menu($r,$cdesc,$domdesc,$dom,$type);
+                        &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
+                                                 $env{'form.pickedcourse'},$coursehash);
                     } elsif ($phase eq 'ccrole') {
                         &Apache::lonhtmlcommon::add_breadcrumb
                          ({href=>"javascript:changePage(document.$phase,'ccrole')",




More information about the LON-CAPA-cvs mailing list