--- loncom/interface/lonmodifycourse.pm 2014/03/17 02:45:25 1.70 +++ loncom/interface/lonmodifycourse.pm 2014/03/31 01:37:28 1.71 @@ -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 get_filters { } 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 print_footer { } 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 @@ sub handler { 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 @@ sub handler { &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')",