version 1.197, 2013/07/02 19:04:36
|
version 1.198, 2013/07/09 00:17:22
|
Line 2445 sub print_coursedefaults {
|
Line 2445 sub print_coursedefaults {
|
my $itemcount = 1; |
my $itemcount = 1; |
my %choices = &Apache::lonlocal::texthash ( |
my %choices = &Apache::lonlocal::texthash ( |
canuse_pdfforms => 'Course/Community users can create/upload PDF forms', |
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', |
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', |
coursecredits => 'Credits can be specified for courses', |
coursecredits => 'Credits can be specified for courses', |
); |
); |
|
my %staticdefaults = ( |
|
anonsurvey_threshold => 10, |
|
uploadquota => 500, |
|
); |
if ($position eq 'top') { |
if ($position eq 'top') { |
%defaultchecked = ('canuse_pdfforms' => 'off'); |
%defaultchecked = ('canuse_pdfforms' => 'off'); |
@toggles = ('canuse_pdfforms'); |
@toggles = ('canuse_pdfforms'); |
Line 2455 sub print_coursedefaults {
|
Line 2460 sub print_coursedefaults {
|
\%choices,$itemcount); |
\%choices,$itemcount); |
} else { |
} else { |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$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 $currusecredits = 0; |
|
my @types = ('official','unofficial','community'); |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
$currdefresponder = $settings->{'anonsurvey_threshold'}; |
$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') { |
if (ref($settings->{'coursecredits'}) eq 'HASH') { |
$def_official_credits = $settings->{'coursecredits'}->{'official'}; |
$def_official_credits = $settings->{'coursecredits'}->{'official'}; |
$def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; |
$def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; |
Line 2468 sub print_coursedefaults {
|
Line 2479 sub print_coursedefaults {
|
} |
} |
} |
} |
if (!$currdefresponder) { |
if (!$currdefresponder) { |
$currdefresponder = 10; |
$currdefresponder = $staticdefaults{'anonsurvey_threshold'}; |
} elsif ($currdefresponder < 1) { |
} elsif ($currdefresponder < 1) { |
$currdefresponder = 1; |
$currdefresponder = 1; |
} |
} |
|
foreach my $type (@types) { |
|
if ($curruploadquota{$type} eq '') { |
|
$curruploadquota{$type} = $staticdefaults{'uploadquota'}; |
|
} |
|
} |
$datatable .= |
$datatable .= |
'<tr'.$css_class.'><td><span class="LC_nobreak">'. |
'<tr'.$css_class.'><td><span class="LC_nobreak">'. |
$choices{'anonsurvey_threshold'}. |
$choices{'anonsurvey_threshold'}. |
Line 2479 sub print_coursedefaults {
|
Line 2495 sub print_coursedefaults {
|
'<td class="LC_right_item"><span class="LC_nobreak">'. |
'<td class="LC_right_item"><span class="LC_nobreak">'. |
'<input type="text" name="anonsurvey_threshold"'. |
'<input type="text" name="anonsurvey_threshold"'. |
' value="'.$currdefresponder.'" size="5" /></span>'. |
' value="'.$currdefresponder.'" size="5" /></span>'. |
'</td></tr>'."\n"; |
'</td></tr>'."\n". |
$itemcount ++; |
'<tr><td><span class="LC_nobreak">'. |
|
$choices{'uploadquota'}. |
|
'</span></td>'. |
|
'<td align="right" class="LC_right_item">'. |
|
'<table><tr>'; |
|
foreach my $type (@types) { |
|
$datatable .= '<td align="center">'.&mt($type).'<br />'. |
|
'<input type="text" name="uploadquota_'.$type.'"'. |
|
' value="'.$curruploadquota{$type}.'" size="5" /></td>'; |
|
} |
|
$datatable .= '</tr></table></td></tr>'."\n"; |
|
$itemcount += 2; |
my $onclick = 'toggleCredits(this.form);'; |
my $onclick = 'toggleCredits(this.form);'; |
my $display = 'none'; |
my $display = 'none'; |
if ($currusecredits) { |
if ($currusecredits) { |
Line 7908 sub modify_coursedefaults {
|
Line 7935 sub modify_coursedefaults {
|
my ($resulttext,$errors,%changes,%defaultshash); |
my ($resulttext,$errors,%changes,%defaultshash); |
my %defaultchecked = ('canuse_pdfforms' => 'off'); |
my %defaultchecked = ('canuse_pdfforms' => 'off'); |
my @toggles = ('canuse_pdfforms'); |
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'} = {}; |
$defaultshash{'coursedefaults'} = {}; |
|
|
Line 7936 sub modify_coursedefaults {
|
Line 7970 sub modify_coursedefaults {
|
} |
} |
$defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item}; |
$defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item}; |
} |
} |
my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'}; |
foreach my $item (@numbers) { |
my $newdefresponder = $env{'form.anonsurvey_threshold'}; |
my ($currdef,$newdef); |
$newdefresponder =~ s/\D//g; |
my $newdef = $env{'form.'.$item}; |
if ($newdefresponder eq '' || $newdefresponder < 1) { |
if ($item eq 'anonsurvey_threshold') { |
$newdefresponder = 1; |
$currdef = $domconfig{'coursedefaults'}{$item}; |
} |
$newdef =~ s/\D//g; |
$defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder; |
if ($newdef eq '' || $newdef < 1) { |
if ($currdefresponder ne $newdefresponder) { |
$newdef = 1; |
unless ($currdefresponder eq '' && $newdefresponder == 10) { |
} |
$changes{'anonsurvey_threshold'} = 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'}; |
my $officialcreds = $env{'form.official_credits'}; |
Line 7971 sub modify_coursedefaults {
|
Line 8024 sub modify_coursedefaults {
|
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
my %domdefaults; |
my %domdefaults; |
if (keys(%changes) > 0) { |
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); |
%domdefaults = &Apache::lonnet::get_domain_defaults($dom); |
if ($changes{'canuse_pdfforms'}) { |
if ($changes{'canuse_pdfforms'}) { |
$domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; |
$domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; |
Line 7984 sub modify_coursedefaults {
|
Line 8037 sub modify_coursedefaults {
|
$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; |
$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; |
my $cachetime = 24*60*60; |
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); |
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); |
} |
} |
Line 7997 sub modify_coursedefaults {
|
Line 8057 sub modify_coursedefaults {
|
} |
} |
} elsif ($item eq 'anonsurvey_threshold') { |
} elsif ($item eq 'anonsurvey_threshold') { |
$resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>'; |
$resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>'; |
|
} elsif ($item eq 'uploadquota') { |
|
if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') { |
|
$resulttext .= '<li>'.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').'<ul>'. |
|
'<li>'.&mt('Official courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.'</b>').'</li>'. |
|
'<li>'.&mt('Unofficial courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.'</b>').'</li>'. |
|
'<li>'.&mt('Communities: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.'</b>').'</li>'. |
|
'</ul>'. |
|
'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'</li>'; |
|
} |
} elsif ($item eq 'coursecredits') { |
} elsif ($item eq 'coursecredits') { |
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
if (($domdefaults{'officialcredits'} eq '') && |
if (($domdefaults{'officialcredits'} eq '') && |