--- loncom/interface/domainprefs.pm 2013/07/02 19:04:36 1.197
+++ loncom/interface/domainprefs.pm 2013/07/09 00:17:22 1.198
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.197 2013/07/02 19:04:36 raeburn Exp $
+# $Id: domainprefs.pm,v 1.198 2013/07/09 00:17:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2445,9 +2445,14 @@ sub print_coursedefaults {
my $itemcount = 1;
my %choices = &Apache::lonlocal::texthash (
canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+ uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)',
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
coursecredits => 'Credits can be specified for courses',
);
+ my %staticdefaults = (
+ anonsurvey_threshold => 10,
+ uploadquota => 500,
+ );
if ($position eq 'top') {
%defaultchecked = ('canuse_pdfforms' => 'off');
@toggles = ('canuse_pdfforms');
@@ -2455,10 +2460,16 @@ sub print_coursedefaults {
\%choices,$itemcount);
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my ($currdefresponder,$def_official_credits,$def_unofficial_credits);
+ my ($currdefresponder,$def_official_credits,$def_unofficial_credits,%curruploadquota);
my $currusecredits = 0;
+ my @types = ('official','unofficial','community');
if (ref($settings) eq 'HASH') {
$currdefresponder = $settings->{'anonsurvey_threshold'};
+ if (ref($settings->{'uploadquota'}) eq 'HASH') {
+ foreach my $type (keys(%{$settings->{'uploadquota'}})) {
+ $curruploadquota{$type} = $settings->{'uploadquota'}{$type};
+ }
+ }
if (ref($settings->{'coursecredits'}) eq 'HASH') {
$def_official_credits = $settings->{'coursecredits'}->{'official'};
$def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
@@ -2468,10 +2479,15 @@ sub print_coursedefaults {
}
}
if (!$currdefresponder) {
- $currdefresponder = 10;
+ $currdefresponder = $staticdefaults{'anonsurvey_threshold'};
} elsif ($currdefresponder < 1) {
$currdefresponder = 1;
}
+ foreach my $type (@types) {
+ if ($curruploadquota{$type} eq '') {
+ $curruploadquota{$type} = $staticdefaults{'uploadquota'};
+ }
+ }
$datatable .=
'
'.
$choices{'anonsurvey_threshold'}.
@@ -2479,8 +2495,19 @@ sub print_coursedefaults {
' | '.
''.
- ' |
'."\n";
- $itemcount ++;
+ ''."\n".
+ ''.
+ $choices{'uploadquota'}.
+ ' | '.
+ ''.
+ ' |
'."\n";
+ $itemcount += 2;
my $onclick = 'toggleCredits(this.form);';
my $display = 'none';
if ($currusecredits) {
@@ -7908,6 +7935,13 @@ sub modify_coursedefaults {
my ($resulttext,$errors,%changes,%defaultshash);
my %defaultchecked = ('canuse_pdfforms' => 'off');
my @toggles = ('canuse_pdfforms');
+ my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
+ 'uploadquota_community');
+ my @types = ('official','unofficial','community');
+ my %staticdefaults = (
+ anonsurvey_threshold => 10,
+ uploadquota => 500,
+ );
$defaultshash{'coursedefaults'} = {};
@@ -7936,16 +7970,35 @@ sub modify_coursedefaults {
}
$defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};
}
- my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
- my $newdefresponder = $env{'form.anonsurvey_threshold'};
- $newdefresponder =~ s/\D//g;
- if ($newdefresponder eq '' || $newdefresponder < 1) {
- $newdefresponder = 1;
- }
- $defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder;
- if ($currdefresponder ne $newdefresponder) {
- unless ($currdefresponder eq '' && $newdefresponder == 10) {
- $changes{'anonsurvey_threshold'} = 1;
+ foreach my $item (@numbers) {
+ my ($currdef,$newdef);
+ my $newdef = $env{'form.'.$item};
+ if ($item eq 'anonsurvey_threshold') {
+ $currdef = $domconfig{'coursedefaults'}{$item};
+ $newdef =~ s/\D//g;
+ if ($newdef eq '' || $newdef < 1) {
+ $newdef = 1;
+ }
+ $defaultshash{'coursedefaults'}{$item} = $newdef;
+ } else {
+ my ($type) = ($item =~ /^\Quploadquota_\E(\w+)$/);
+ if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+ $currdef = $domconfig{'coursedefaults'}{'uploadquota'}{$type};
+ }
+ $newdef =~ s/[^\w.\-]//g;
+ $defaultshash{'coursedefaults'}{'uploadquota'}{$type} = $newdef;
+ }
+ if ($currdef ne $newdef) {
+ my $staticdef;
+ if ($item eq 'anonsurvey_threshold') {
+ unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) {
+ $changes{$item} = 1;
+ }
+ } else {
+ unless (($currdef eq '') && ($newdef == $staticdefaults{'uploadquota'})) {
+ $changes{'uploadquota'} = 1;
+ }
+ }
}
}
my $officialcreds = $env{'form.official_credits'};
@@ -7971,7 +8024,7 @@ sub modify_coursedefaults {
if ($putresult eq 'ok') {
my %domdefaults;
if (keys(%changes) > 0) {
- if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'})) {
+ if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) {
%domdefaults = &Apache::lonnet::get_domain_defaults($dom);
if ($changes{'canuse_pdfforms'}) {
$domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
@@ -7984,6 +8037,13 @@ sub modify_coursedefaults {
$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};
}
}
+ if ($changes{'uploadquota'}) {
+ if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'quota'}=$defaultshash{'coursedefaults'}{'uploadquota'}{$type};
+ }
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
}
@@ -7997,6 +8057,17 @@ sub modify_coursedefaults {
}
} elsif ($item eq 'anonsurvey_threshold') {
$resulttext .= ''.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'';
+ } elsif ($item eq 'uploadquota') {
+ if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') {
+ $resulttext .= ''.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').''.
+ '- '.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.'').'
'.
+ '- '.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.'').'
'.
+ '- '.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.'').'
'.
+ '
'.
+ '';
+ } else {
+ $resulttext .= ''.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'';
+ }
} elsif ($item eq 'coursecredits') {
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
if (($domdefaults{'officialcredits'} eq '') &&