--- loncom/interface/lonmodifycourse.pm 2014/01/15 18:47:56 1.66 +++ 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.66 2014/01/15 18:47:56 bisitz Exp $ +# $Id: lonmodifycourse.pm,v 1.71 2014/03/31 01:37:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -153,10 +153,7 @@ sub print_course_search_page { $type = 'Course'; } &print_header($r,$type); - my $filterlist = ['descriptfilter', - 'instcodefilter','ownerfilter', - 'coursefilter']; - my $filter = {}; + my ($filterlist,$filter) = &get_filters($dom); my ($numtitles,$cctitle,$dctitle,@codetitles); my $ccrole = 'cc'; if ($type eq 'Community') { @@ -164,15 +161,15 @@ sub print_course_search_page { } $cctitle = &Apache::lonnet::plaintext($ccrole,$type); $dctitle = &Apache::lonnet::plaintext('dc'); - $r->print(&Apache::lonpickcourse::js_changer()); + $r->print(&Apache::loncommon::js_changer()); if ($type eq 'Community') { $r->print('

'.&mt('Search for a community in the [_1] domain',$domdesc).'

'); } else { $r->print('

'.&mt('Search for a course in the [_1] domain',$domdesc).'

'); - } - $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type, - undef,undef,$filter,$action,\$numtitles,'modifycourse', - undef,undef,undef,\@codetitles)); + } + $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action, + \$numtitles,'modifycourse',undef,undef,undef, + \@codetitles,$dom)); if ($type eq 'Community') { $r->print(&mt('Actions available after searching for a community:').''); } + return; } sub print_course_selection_page { @@ -195,31 +193,49 @@ sub print_course_selection_page { &print_header($r,$type); # Criteria for course search - my $filterlist = ['descriptfilter', - 'instcodefilter','ownerfilter', - 'ownerdomfilter','coursefilter']; - my %filter; + my ($filterlist,$filter) = &get_filters(); my $action = '/adm/modifycourse'; my $dctitle = &Apache::lonnet::plaintext('dc'); my ($numtitles,@codetitles); - $r->print(&Apache::lonpickcourse::js_changer()); + $r->print(&Apache::loncommon::js_changer()); $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').
'); - $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type, - undef,undef,\%filter,$action,\$numtitles, - undef,undef,undef,undef,\@codetitles)); - $filter{'domainfilter'} = $dom; - my %courses = &Apache::lonpickcourse::search_courses($r,$type,0, - \%filter,$numtitles,undef, - undef,undef,\@codetitles); + $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action, + \$numtitles,'modifycourse',undef,undef,undef, + \@codetitles,$dom,$env{'form.form'})); + my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles, + undef,undef,undef,\@codetitles); &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef, %courses); return; } +sub get_filters { + my ($dom) = @_; + my @filterlist = ('descriptfilter','instcodefilter','ownerfilter', + 'ownerdomfilter','coursefilter','sincefilter'); + # created filter + my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom); + if ($loncaparev ne 'unknown_cmd') { + push(@filterlist,'createdfilter'); + } + my %filter; + foreach my $item (@filterlist) { + $filter{$item} = $env{'form.'.$item}; + } + return (\@filterlist,\%filter); +} + 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 { @@ -436,7 +452,7 @@ sub print_setquota { coursequota => 20, uploadquota => 500, ); - my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.instcode'], + my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'], $cdom,$cnum); my $coursequota = $settings{'internal.coursequota'}; my $uploadquota = $settings{'internal.uploadquota'}; @@ -447,7 +463,7 @@ sub print_setquota { my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); if ($type eq 'Community') { $uploadquota = $domdefs{$lctype.'quota'}; - } elsif ($settings{'internal.instcode'}) { + } elsif ($settings{'internal.coursecode'}) { $uploadquota = $domdefs{'officialquota'}; } elsif ($settings{'internal.textbook'}) { $uploadquota = $domdefs{'textbookquota'}; @@ -1241,10 +1257,10 @@ sub modify_quota { } $r->print('

'); if ($type eq 'Community') { - $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '. + $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '. &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.')); } else { - $r->print(&mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '. + $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '. &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.')); } $r->print('

'); @@ -1562,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 { @@ -1691,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') { @@ -1703,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')",