version 1.191, 2013/02/25 17:43:41
|
version 1.192, 2013/03/01 04:17:15
|
Line 417 sub handler {
|
Line 417 sub handler {
|
if ($phase eq 'process') { |
if ($phase eq 'process') { |
&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles); |
&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles); |
} elsif ($phase eq 'display') { |
} elsif ($phase eq 'display') { |
my $js = &recaptcha_js(); |
my $js = &recaptcha_js(). |
|
&credits_js(); |
if ((keys(%servers) > 1) || (keys(%existing) > 0)) { |
if ((keys(%servers) > 1) || (keys(%existing) > 0)) { |
my ($othertitle,$usertypes,$types) = |
my ($othertitle,$usertypes,$types) = |
&Apache::loncommon::sorted_inst_types($dom); |
&Apache::loncommon::sorted_inst_types($dom); |
Line 2372 sub print_helpsettings {
|
Line 2373 sub print_helpsettings {
|
} |
} |
|
|
sub radiobutton_prefs { |
sub radiobutton_prefs { |
my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_; |
my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, |
|
$additional) = @_; |
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && |
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && |
(ref($choices) eq 'HASH')); |
(ref($choices) eq 'HASH')); |
|
|
Line 2398 sub radiobutton_prefs {
|
Line 2400 sub radiobutton_prefs {
|
} |
} |
} |
} |
} |
} |
|
if ($onclick) { |
|
$onclick = ' onclick="'.$onclick.'"'; |
|
} |
foreach my $item (@{$toggles}) { |
foreach my $item (@{$toggles}) { |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$datatable .= |
$datatable .= |
'<tr'.$css_class.'><td><span class="LC_nobreak">'.$choices->{$item}. |
'<tr'.$css_class.'><td valign="top">'. |
|
'<span class="LC_nobreak">'.$choices->{$item}. |
'</span></td>'. |
'</span></td>'. |
'<td class="LC_right_item"><span class="LC_nobreak">'. |
'<td class="LC_right_item"><span class="LC_nobreak">'. |
'<label><input type="radio" name="'. |
'<label><input type="radio" name="'. |
$item.'" '.$checkedon{$item}.' value="1" />'.&mt('Yes'). |
$item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes'). |
'</label> <label><input type="radio" name="'.$item.'" '. |
'</label> <label><input type="radio" name="'.$item.'" '. |
$checkedoff{$item}.' value="0" />'.&mt('No').'</label>'. |
$checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').'</label>'. |
'</span></td>'. |
'</span>'.$additional. |
|
'</td>'. |
'</tr>'; |
'</tr>'; |
$itemcount ++; |
$itemcount ++; |
} |
} |
Line 2417 sub radiobutton_prefs {
|
Line 2424 sub radiobutton_prefs {
|
|
|
sub print_coursedefaults { |
sub print_coursedefaults { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($css_class,$datatable); |
my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); |
my $itemcount = 1; |
my $itemcount = 1; |
|
my %choices = &Apache::lonlocal::texthash ( |
|
canuse_pdfforms => 'Course/Community users can create/upload PDF forms', |
|
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', |
|
coursecredits => 'Credits can be specified for courses', |
|
); |
if ($position eq 'top') { |
if ($position eq 'top') { |
my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles); |
|
%choices = |
|
&Apache::lonlocal::texthash ( |
|
canuse_pdfforms => 'Course/Community users can create/upload PDF forms', |
|
); |
|
%defaultchecked = ('canuse_pdfforms' => 'off'); |
%defaultchecked = ('canuse_pdfforms' => 'off'); |
@toggles = ('canuse_pdfforms',); |
@toggles = ('canuse_pdfforms'); |
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, |
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, |
\%choices,$itemcount); |
\%choices,$itemcount); |
$$rowtotal += $itemcount; |
|
} else { |
} else { |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
my %choices = |
my ($currdefresponder,$def_official_credits,$def_unofficial_credits); |
&Apache::lonlocal::texthash ( |
my $currusecredits = 0; |
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', |
|
); |
|
my $currdefresponder; |
|
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
$currdefresponder = $settings->{'anonsurvey_threshold'}; |
$currdefresponder = $settings->{'anonsurvey_threshold'}; |
|
if (ref($settings->{'coursecredits'}) eq 'HASH') { |
|
$def_official_credits = $settings->{'coursecredits'}->{'official'}; |
|
$def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; |
|
if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) { |
|
$currusecredits = 1; |
|
} |
|
} |
} |
} |
if (!$currdefresponder) { |
if (!$currdefresponder) { |
$currdefresponder = 10; |
$currdefresponder = 10; |
Line 2446 sub print_coursedefaults {
|
Line 2456 sub print_coursedefaults {
|
$currdefresponder = 1; |
$currdefresponder = 1; |
} |
} |
$datatable .= |
$datatable .= |
'<tr'.$css_class.'><td><span class="LC_nobreak">'.$choices{'anonsurvey_threshold'}. |
'<tr'.$css_class.'><td><span class="LC_nobreak">'. |
|
$choices{'anonsurvey_threshold'}. |
'</span></td>'. |
'</span></td>'. |
'<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>'; |
'</td></tr>'."\n"; |
|
$itemcount ++; |
|
my $onclick = 'toggleCredits(this.form);'; |
|
my $display = 'none'; |
|
if ($currusecredits) { |
|
$display = 'block'; |
|
} |
|
my $additional = '<div id="credits" style="display: '.$display.'">'. |
|
'<span class="LC_nobreak">'. |
|
&mt('Default credits for official courses [_1]', |
|
'<input type="text" name="official_credits" value="'. |
|
$def_official_credits.'" size="3" />'). |
|
'</span><br />'. |
|
'<span class="LC_nobreak">'. |
|
&mt('Default credits for unofficial courses [_1]', |
|
'<input type="text" name="unofficial_credits" value="'. |
|
$def_unofficial_credits.'" size="3" />'). |
|
'</span></div>'."\n"; |
|
%defaultchecked = ('coursecredits' => 'off'); |
|
@toggles = ('coursecredits'); |
|
my $current = { |
|
'coursecredits' => $currusecredits, |
|
}; |
|
(my $table,$itemcount) = |
|
&radiobutton_prefs($current,\@toggles,\%defaultchecked, |
|
\%choices,$itemcount,$onclick,$additional); |
|
$datatable .= $table; |
} |
} |
|
$$rowtotal += $itemcount; |
return $datatable; |
return $datatable; |
} |
} |
|
|
Line 7811 sub modify_coursedefaults {
|
Line 7849 sub modify_coursedefaults {
|
my ($dom,%domconfig) = @_; |
my ($dom,%domconfig) = @_; |
my ($resulttext,$errors,%changes,%defaultshash); |
my ($resulttext,$errors,%changes,%defaultshash); |
my %defaultchecked = ('canuse_pdfforms' => 'off'); |
my %defaultchecked = ('canuse_pdfforms' => 'off'); |
my @offon = ('off','on'); |
|
my @toggles = ('canuse_pdfforms'); |
my @toggles = ('canuse_pdfforms'); |
|
|
$defaultshash{'coursedefaults'} = {}; |
$defaultshash{'coursedefaults'} = {}; |
Line 7828 sub modify_coursedefaults {
|
Line 7865 sub modify_coursedefaults {
|
if (($domconfig{'coursedefaults'}{$item} eq '') && |
if (($domconfig{'coursedefaults'}{$item} eq '') && |
($env{'form.'.$item} eq '0')) { |
($env{'form.'.$item} eq '0')) { |
$changes{$item} = 1; |
$changes{$item} = 1; |
} elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) { |
} elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) { |
$changes{$item} = 1; |
$changes{$item} = 1; |
} |
} |
} elsif ($defaultchecked{$item} eq 'off') { |
} elsif ($defaultchecked{$item} eq 'off') { |
Line 7853 sub modify_coursedefaults {
|
Line 7890 sub modify_coursedefaults {
|
$changes{'anonsurvey_threshold'} = 1; |
$changes{'anonsurvey_threshold'} = 1; |
} |
} |
} |
} |
|
my $officialcreds = $env{'form.official_credits'}; |
|
$officialcreds =~ s/^[^\d\.]//g; |
|
my $unofficialcreds = $env{'form.unofficial_credits'}; |
|
$unofficialcreds =~ s/^[^\d\.]//g; |
|
if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') && |
|
($env{'form.coursecredits'} eq '1')) { |
|
$changes{'coursecredits'} = 1; |
|
} else { |
|
if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) || |
|
($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds)) { |
|
$changes{'coursecredits'} = 1; |
|
} |
|
} |
|
$defaultshash{'coursedefaults'}{'coursecredits'} = { |
|
official => $officialcreds, |
|
unofficial => $unofficialcreds, |
|
} |
} |
} |
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, |
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, |
$dom); |
$dom); |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
|
my %domdefaults; |
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
if ($changes{'canuse_pdfforms'}) { |
if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'})) { |
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); |
%domdefaults = &Apache::lonnet::get_domain_defaults($dom); |
$domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; |
if ($changes{'canuse_pdfforms'}) { |
|
$domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; |
|
} |
|
if ($changes{'coursecredits'}) { |
|
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
|
$domdefaults{'officialcredits'} = |
|
$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}; |
|
$domdefaults{'unofficialcredits'} = |
|
$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; |
|
} |
|
} |
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 7873 sub modify_coursedefaults {
|
Line 7938 sub modify_coursedefaults {
|
$resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>'; |
$resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>'; |
} |
} |
} 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 'coursecredits') { |
|
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
|
if (($domdefaults{'officialcredits'} eq '') && |
|
($domdefaults{'unofficialcredits'} eq '')) { |
|
$resulttext .= '<li>'.&mt('Student credits not in use for courses in this domain').'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').'<ul>'. |
|
'<li>'.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).'</li>'. |
|
'<li>'.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).'</li>'. |
|
'</ul>'. |
|
'</li>'; |
|
} |
|
} else { |
|
$resulttext .= '<li>'.&mt('Student credits not in use for courses in this domain').'</li>'; |
|
} |
} |
} |
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
Line 9006 function updateCaptcha(caller,context) {
|
Line 9086 function updateCaptcha(caller,context) {
|
} |
} |
} |
} |
return; |
return; |
|
} |
|
|
|
// ]]> |
|
</script> |
|
|
|
END |
|
|
|
} |
|
|
|
sub credits_js { |
|
return <<"END"; |
|
|
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
|
function toggleCredits(domForm) { |
|
if (document.getElementById('credits')) { |
|
creditsitem = document.getElementById('credits'); |
|
var creditsLength = domForm.coursecredits.length; |
|
if (creditsLength) { |
|
var currval; |
|
for (var i=0; i<creditsLength; i++) { |
|
if (domForm.coursecredits[i].checked) { |
|
currval = domForm.coursecredits[i].value; |
|
} |
|
} |
|
if (currval == 1) { |
|
creditsitem.style.display = 'block'; |
|
} else { |
|
creditsitem.style.display = 'none'; |
|
} |
|
} |
|
} |
|
return; |
} |
} |
|
|
// ]]> |
// ]]> |