--- loncom/interface/lonmodifycourse.pm 2010/09/11 21:36:00 1.57.2.1 +++ loncom/interface/lonmodifycourse.pm 2013/12/24 19:15:11 1.65 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # handler for DC-only modifiable course settings # -# $Id: lonmodifycourse.pm,v 1.57.2.1 2010/09/11 21:36:00 raeburn Exp $ +# $Id: lonmodifycourse.pm,v 1.65 2013/12/24 19:15:11 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}; @@ -149,7 +157,7 @@ sub print_course_search_page { 'instcodefilter','ownerfilter', 'coursefilter']; my $filter = {}; - my ($numtitles,$cctitle,$dctitle); + my ($numtitles,$cctitle,$dctitle,@codetitles); my $ccrole = 'cc'; if ($type eq 'Community') { $ccrole = 'co'; @@ -163,7 +171,8 @@ sub print_course_search_page { $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,$filter,$action,\$numtitles,'modifycourse', + undef,undef,undef,\@codetitles)); if ($type eq 'Community') { $r->print(&mt('Actions available after searching for a community:').'

'. '

'.$lt{'cour'}.'

'.$disp_table.'

'. ''.$lt{'back'}.''."\n". &hidden_form_elements(). @@ -398,28 +423,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.instcode'], + $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.instcode'}) { + $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 @@ -636,14 +690,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). @@ -654,7 +715,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; } @@ -715,12 +776,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}; } @@ -739,7 +803,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 { @@ -778,6 +842,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'}) ) { @@ -813,10 +883,10 @@ sub modify_course { } } if (@changes > 0) { - $chgresponse = &mt("The following settings have been changed: