--- loncom/interface/lonmodifycourse.pm 2011/01/11 22:09:49 1.58 +++ 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.58 2011/01/11 22:09:49 raeburn Exp $ +# $Id: lonmodifycourse.pm,v 1.71 2014/03/31 01:37:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,18 +39,22 @@ use lib '/home/httpd/lib/perl'; use LONCAPA; sub get_dc_settable { - my ($type) = @_; + my ($type,$cdom) = @_; if ($type eq 'Community') { return ('courseowner'); } else { - return ('courseowner','coursecode','authtype','autharg'); + my @items = ('courseowner','coursecode','authtype','autharg'); + if (&showcredits($cdom)) { + push(@items,'defaultcredits'); + } + return @items; } } sub autoenroll_keys { - my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops', - 'autostart','autoend','sectionnums','crosslistings', - 'co-owners']; + my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits', + 'autoadds','autodrops','autostart','autoend','sectionnums', + 'crosslistings','co-owners']; my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date']; return ($internals,$accessdates); } @@ -114,6 +118,10 @@ sub get_enrollment_settings { || $type eq "autharg" || $type eq "coursecode" || $type eq "crosslistings") { $enrollvar{$type} = $settings{$item}; + } elsif ($type eq 'defaultcredits') { + if (&showcredits($cdom)) { + $enrollvar{$type} = $settings{$item}; + } } elsif ($type eq 'courseowner') { if ($settings{$item} =~ /^[^:]+:[^:]+$/) { $enrollvar{$type} = $settings{$item}; @@ -145,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') { @@ -156,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 { @@ -187,45 +193,69 @@ 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,$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 { $ccrole = 'cc'; - } + } if ($type eq 'Community') { $categorytitle = 'View/Modify Community Settings'; $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.'); + $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.'); $setparams_text = 'View/Modify community owner'; $cat_text = 'View/Modify catalog settings for community'; } else { $categorytitle = 'View/Modify Course Settings'; $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.'); - $setparams_text = 'View/Modify course owner, institutional code, and default authentication'; + $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.'); + if (&showcredits($dom)) { + $setparams_text = 'View/Modify course owner, institutional code, and default authentication and credits'; + } else { + $setparams_text = 'View/Modify course owner, institutional code, and default authentication'; + } $cat_text = 'View/Modify catalog settings for course'; } my $anon_text = 'Responder threshold required to display anonymous survey submissions'; @@ -249,7 +279,7 @@ sub print_modification_menu { linktitle => '' }, { - linktext => 'View/Modify quota for group portfolio files', + linktext => 'View/Modify quotas for group portfolio files, and for uploaded content.', url => &phaseurl('setquota'), permission => 1, #help => '', @@ -300,8 +330,12 @@ sub print_modification_menu { } else { $menu_html .= '
  • '.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'
  • '. '
  • '.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'
  • '; + if (&showcredits($dom)) { + $menu_html .= '
  • '.&mt('Default credits earned by student on course completion.').'
  • '; + } } $menu_html .= '
  • '.$setquota_text.'
  • '. + '
  • '.$setuploadquota_text.'
  • '. '
  • '.$anon_text.'
  • '."\n"; foreach my $item (@additional_params) { if ($type eq 'Community') { @@ -357,7 +391,7 @@ sub print_settings_display { } my $cctitle = &Apache::lonnet::plaintext($ccrole,$type); my $dctitle = &Apache::lonnet::plaintext('dc'); - my @modifiable_params = &get_dc_settable($type); + my @modifiable_params = &get_dc_settable($type,$cdom); my ($internals,$accessdates) = &autoenroll_keys(); my @items; if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) { @@ -389,9 +423,13 @@ sub print_settings_display { ' '.$cdesc.''. '
    '."\n". '

    '.$lt{'cose'}.'

    '. + '
  • '.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',$cctitle,'','').'
  • '); + if (&showcredits($cdom)) { + $r->print('
  • '.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, and default authentication and credits[_3].',$dctitle,'','')."\n"); + } else { + $r->print('
  • '.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, and default authentication[_3].',$dctitle,'','')."\n"); + } + $r->print('
  • '. '

    '.$lt{'cour'}.'

    '.$disp_table.'

    '. ''.$lt{'back'}.''."\n". &hidden_form_elements(). @@ -401,28 +439,57 @@ sub print_settings_display { sub print_setquota { my ($r,$cdom,$cnum,$cdesc,$type) = @_; + my $lctype = lc($type); + my $headline = &mt("Set disk space quotas for $lctype: [_1]", + ''.$cdesc.''); my %lt = &Apache::lonlocal::texthash( - 'cquo' => 'Disk space for storage of group portfolio files for:', - 'gpqu' => 'Course portfolio files disk space', + 'gpqu' => 'Disk space for storage of group portfolio files', + 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor', 'modi' => 'Save', 'back' => 'Pick another action', ); - if ($type eq 'Community') { - $lt{'gpqu'} = &mt('Community portfolio files disk space'); - } - my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum); + my %staticdefaults = ( + coursequota => 20, + uploadquota => 500, + ); + my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'], + $cdom,$cnum); my $coursequota = $settings{'internal.coursequota'}; + my $uploadquota = $settings{'internal.uploadquota'}; if ($coursequota eq '') { - $coursequota = 20; + $coursequota = $staticdefaults{'coursequota'}; + } + if ($uploadquota eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + if ($type eq 'Community') { + $uploadquota = $domdefs{$lctype.'quota'}; + } elsif ($settings{'internal.coursecode'}) { + $uploadquota = $domdefs{'officialquota'}; + } elsif ($settings{'internal.textbook'}) { + $uploadquota = $domdefs{'textbookquota'}; + } else { + $uploadquota = $domdefs{'unofficialquota'}; + } + if ($uploadquota eq '') { + $uploadquota = $staticdefaults{'uploadquota'}; + } } &print_header($r,$type); my $hidden_elements = &hidden_form_elements(); - my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota'); + my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota'); + my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota'); $r->print(< -

    $lt{'cquo'} $cdesc

    +

    $headline

    +

    +$porthelpitem $lt{'gpqu'}: MB + +
    + +$uploadhelpitem $lt{'upqu'}: MB + +

    -$helpitem $lt{'gpqu'}: Mb     

    $hidden_elements @@ -639,14 +706,21 @@ sub print_course_modification_page { &Apache::loncommon::help_open_topic('Modify_Course_Instcode'). ' '.&mt('Course Code'))."\n". ''. - &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title( - &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth'). - ' '.&mt('Default Authentication method'))."\n". - $authenitems."\n". - &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title( - &Apache::loncommon::help_open_topic('Modify_Course_Owner'). + &Apache::lonhtmlcommon::row_closure()); + if (&showcredits($cdom)) { + $r->print(&Apache::lonhtmlcommon::row_title( + &Apache::loncommon::help_open_topic('Modify_Course_Credithours'). + ' '.&mt('Credits (students)'))."\n". + ''. + &Apache::lonhtmlcommon::row_closure()); + } + $r->print(&Apache::lonhtmlcommon::row_title( + &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth'). + ' '.&mt('Default Authentication method'))."\n". + $authenitems."\n". + &Apache::lonhtmlcommon::row_closure(). + &Apache::lonhtmlcommon::row_title( + &Apache::loncommon::help_open_topic('Modify_Course_Owner'). ' '.&mt('Course Owner'))."\n"); } $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure(1). @@ -657,7 +731,7 @@ sub print_course_modification_page { } else { $r->print('javascript:verify_message(this.form);"'); } - $r->print('value="'.$lt{'gobt'}.'" />

    '); + $r->print(' value="'.$lt{'gobt'}.'" />

    '); return; } @@ -718,12 +792,15 @@ sub modify_course { unless ($type eq 'Community') { push(@items,('internal.coursecode','internal.authtype','internal.autharg', 'internal.sectionnums','internal.crosslistings')); + if (&showcredits($cdom)) { + push(@items,'internal.defaultcredits'); + } } my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum); my $description = $settings{'description'}; - my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,%cenv,%changed, - @changes,@nochanges,@sections,@xlists,@warnings); - my @modifiable_params = &get_dc_settable($type); + my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr, + %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings); + my @modifiable_params = &get_dc_settable($type,$cdom); foreach my $param (@modifiable_params) { $currattr{$param} = $settings{'internal.'.$param}; } @@ -742,7 +819,7 @@ sub modify_course { $sections[0] = $settings{'internal.sectionnums'}; } } - unless ($settings{'internal.crosslistings'} eq'') { + unless ($settings{'internal.crosslistings'} eq '') { if ($settings{'internal.crosslistings'} =~ m/,/) { @xlists = split/,/,$settings{'internal.crosslistings'}; } else { @@ -781,6 +858,12 @@ sub modify_course { $changed{'code'} = 1; } } + + if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) { + $newattr{'defaultcredits'} =~ s/[^\d\.]//g; + $newattr{'defaultcredits'}=$env{'form.defaultcredits'}; + } + } if ( exists($env{'form.courseowner'}) ) { @@ -816,10 +899,10 @@ sub modify_course { } } if (@changes > 0) { - $chgresponse = &mt("The following settings have been changed: