--- loncom/interface/lonmodifycourse.pm 2013/03/01 05:01:26 1.60 +++ loncom/interface/lonmodifycourse.pm 2013/07/09 00:17:23 1.61 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # handler for DC-only modifiable course settings # -# $Id: lonmodifycourse.pm,v 1.60 2013/03/01 05:01:26 raeburn Exp $ +# $Id: lonmodifycourse.pm,v 1.61 2013/07/09 00:17:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -219,20 +219,22 @@ sub print_course_selection_page { sub print_modification_menu { my ($r,$cdesc,$domdesc,$dom,$type) = @_; &print_header($r,$type); - my ($ccrole,$categorytitle,$setquota_text,$setparams_text,$cat_text); + my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text); 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.'); + $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 { @@ -261,7 +263,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 => '', @@ -317,6 +319,7 @@ sub print_modification_menu { } } $menu_html .= '
  • '.$setquota_text.'
  • '. + '
  • '.$setuploadquota_text.'
  • '. '
  • '.$anon_text.'
  • '."\n"; foreach my $item (@additional_params) { if ($type eq 'Community') { @@ -420,28 +423,55 @@ 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'}; + } 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 @@ -1126,58 +1156,104 @@ sub update_coowners { sub modify_quota { my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; &print_header($r,$type); + my $lctype = lc($type); + my $headline = &mt("Disk space quotas for $lctype: [_1]", + ''.$cdesc.''); $r->print('
    '."\n". - '

    '.&mt('Disk space for storage of group portfolio files for:'). - ' '.$cdesc.'


    '); - my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum); - my $defaultquota = 20; - if ($env{'form.coursequota'} ne '') { - my $newquota = $env{'form.coursequota'}; - if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) { - $newquota = $1; - if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) { - $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] Mb.',$env{'form.coursequota'})); + '

    '.$headline.'

    '); + my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum); + my %staticdefaults = ( + coursequota => 20, + uploadquota => 500, + ); + my %default; + $default{'coursequota'} = $staticdefaults{'coursequota'}; + my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + $default{'uploadquota'} = $domdefs{'uploadquota'}; + if ($default{'uploadquota'} eq '') { + $default{'uploadquota'} = $staticdefaults{'uploadquota'}; + } + my (%cenv,%showresult); + foreach my $item ('coursequota','uploadquota') { + if ($env{'form.'.$item} ne '') { + my $newquota = $env{'form.'.$item}; + if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) { + $newquota = $1; + if ($oldsettings{'internal.'.$item} == $newquota) { + if ($item eq 'coursequota') { + $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'
    '); + } else { + $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'
    '); + } + } else { + $cenv{'internal.'.$item} = $newquota; + $showresult{$item} = 1; + } } else { - my %cenv = ( - 'internal.coursequota' => $env{'form.coursequota'}, - ); - my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom, - $cnum); - if (($oldsettings{'internal.coursequota'} eq '') && - ($env{'form.coursequota'} == $defaultquota)) { + if ($item eq 'coursequota') { + $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'
    '); + } else { + $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'
    '); + + } + } + } + } + if (keys(%cenv)) { + my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom, + $cnum); + foreach my $key (sort(keys(%showresult))) { + if (($oldsettings{'internal.'.$key} eq '') && + ($env{'form.'.$key} == $default{$key})) { + if ($key eq 'uploadquota') { if ($type eq 'Community') { - $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] Mb.',$defaultquota)); + $r->print(&mt('The disk space allocated for files uploaded to this community via the Content Editor is the default quota for this domain: [_1] MB.', + $default{$key}).'
    '); } else { - $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] Mb.',$defaultquota)); + $r->print(&mt('The disk space allocated for files uploaded to this course via the Content Editor is the default quota for this domain: [_1] MB.', + $default{$key}).'
    '); } - } else { - if ($putreply eq 'ok') { - my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum); - $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] Mb.',''.$updatedsettings{'internal.coursequota'}.'')); - my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum); - if ($usage >= $updatedsettings{'internal.coursequota'}) { - my $newoverquota; - if ($usage < $oldsettings{'internal.coursequota'}) { - $newoverquota = 'now'; - } - $r->print('

    '); - if ($type eq 'Community') { - $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '. - &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).' '. - &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('

    '); - } + } else { + if ($type eq 'Community') { + $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.', + $default{$key}).'
    '); } else { - $r->print(&mt('An error occurred storing the quota for group portfolio files: '). - $putreply); + $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.', + $default{$key}).'
    '); } } + delete($showresult{$key}); + } + } + if ($putreply eq 'ok') { + my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum); + if ($showresult{'coursequota'}) { + $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.', + ''.$updatedsettings{'internal.coursequota'}.'').'
    '); + my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum); + if ($usage >= $updatedsettings{'internal.coursequota'}) { + my $newoverquota; + if ($usage < $oldsettings{'internal.coursequota'}) { + $newoverquota = 'now'; + } + $r->print('

    '); + if ($type eq 'Community') { + $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '. + &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).' '. + &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('

    '); + } + } + if ($showresult{'uploadquota'}) { + $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.', + ''.$updatedsettings{'internal.uploadquota'}.'').'
    '); } } else { - $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.')); + $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content.'). + $putreply); } } $r->print('

    '. @@ -1552,7 +1628,7 @@ sub hidden_form_elements { &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode', 'prevphase','numlocalcc','courseowner','login','coursequota','intarg', 'locarg','krbarg','krbver','counter','hidefromcat','usecategory', - 'threshold','defaultcredits'])."\n". + 'threshold','defaultcredits','uploadquota'])."\n". ''; return $hidden_elements; }