--- loncom/interface/domainprefs.pm 2015/03/13 13:53:07 1.160.6.58 +++ loncom/interface/domainprefs.pm 2015/06/15 20:18:35 1.160.6.65 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.58 2015/03/13 13:53:07 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.65 2015/06/15 20:18:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -892,8 +892,6 @@ sub print_config_box { $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'helpsettings') { $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); - } elsif ($action eq 'coursedefaults') { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } } $output .= ' @@ -2893,6 +2891,7 @@ sub print_coursedefaults { uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)', usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', postsubmit => 'Disable submit button/keypress following student submission', + canclone => "People who may clone a course (besides course's owner and coordinators)", ); my %staticdefaults = ( anonsurvey_threshold => 10, @@ -2903,10 +2902,82 @@ sub print_coursedefaults { %defaultchecked = ( 'uselcmath' => 'on', 'usejsme' => 'on', + 'canclone' => 'none', ); @toggles = ('uselcmath','usejsme'); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, \%choices,$itemcount); + $css_class = $itemcount%2?' class="LC_odd_row"':''; + $datatable .= + '
'.&mt($type).' '. ''. &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'); @@ -3529,7 +3608,7 @@ sub current_offloads_to { } sub spares_row { - my ($dom,$servers,$spareid,$serverhomes,$altids,$rowtotal) = @_; + my ($dom,$servers,$spareid,$serverhomes,$altids,$curroffloadnow,$rowtotal) = @_; my $css_class; my $numinrow = 4; my $itemcount = 1; @@ -3549,12 +3628,21 @@ sub spares_row { } } next unless (ref($spareid->{$server}) eq 'HASH'); + my $checkednow; + if (ref($curroffloadnow) eq 'HASH') { + if ($curroffloadnow->{$server}) { + $checkednow = ' checked="checked"'; + } + } $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' | |
'.
&mt('[_1] when busy, offloads to:'
- ,''.$server.'').
+ ,''.$server.'').' '. + ''."\n". + ''. "\n"; my (%current,%canselect); my @choices = @@ -4681,11 +4769,8 @@ sub print_defaults { my $includeempty = 1; $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty); } elsif ($item eq 'lang_def') { - my %langchoices = &get_languages_hash(); - $langchoices{''} = 'No language preference'; - %langchoices = &Apache::lonlocal::texthash(%langchoices); - $datatable .= &Apache::loncommon::select_form($defaults{$item},$item, - \%langchoices); + my $includeempty = 1; + $datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty); } else { my $size; if ($item eq 'portal_def') { @@ -4754,7 +4839,7 @@ sub print_defaults { $datatable .= ''; } $datatable .= ' '.&mt('Internal ID:'). - ''. + ''. ' '.&mt('(new)'). ' | '.
&mt('Name displayed:').
@@ -5291,7 +5376,7 @@ sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
'checksums','clusterstatus','metadata_keywords','metadata_harvest',
'takeoffline','takeonline','showenv','toggledebug','ping','domconf',
- 'uniquecodes','diskusage');
+ 'uniquecodes','diskusage','coursecatalog');
}
sub defaults_javascript {
@@ -7310,10 +7395,14 @@ sub modify_quotas {
if (@{$confhash{'validation'}{$item}} > 0) {
@{$confhash{'validation'}{$item}} = sort(@{$confhash{'validation'}{$item}});
}
- if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
- if (ref($domconfig{'requestcourses'}{'validation'}{$item}) eq 'ARRAY') {
- @changed = &Apache::loncommon::compare_arrays($confhash{'validation'}{$item},
- $domconfig{'requestcourses'}{'validation'}{$item});
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}{$item}) eq 'ARRAY') {
+ @changed = &Apache::loncommon::compare_arrays($confhash{'validation'}{$item},
+ $domconfig{'requestcourses'}{'validation'}{$item});
+ } else {
+ @changed = @{$confhash{'validation'}{$item}};
+ }
} else {
@changed = @{$confhash{'validation'}{$item}};
}
@@ -7334,9 +7423,15 @@ sub modify_quotas {
$env{'form.requestcourses_validation_'.$item} =~ s/[\n\r\f]+/\s/gs;
}
}
- if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
- if ($domconfig{'requestcourses'}{'validation'}{$item} ne $confhash{'validation'}{$item}) {
- $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'validation'}{$item} ne $confhash{'validation'}{$item}) {
+ $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+ }
+ } else {
+ if ($confhash{'validation'}{$item} ne '') {
+ $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+ }
}
} else {
if ($confhash{'validation'}{$item} ne '') {
@@ -7354,14 +7449,18 @@ sub modify_quotas {
}
}
if (ref($confhash{'validation'}) eq 'HASH') {
- if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
- if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
- unless ($confhash{'validation'}{'dc'} eq $domconfig{'requestcourses'}{'validation'}{'dc'}) {
- if ($confhash{'validation'}{'dc'} eq '') {
- $changes{'validation'}{'dc'} = &mt('None');
- } else {
- $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
+ unless ($confhash{'validation'}{'dc'} eq $domconfig{'requestcourses'}{'validation'}{'dc'}) {
+ if ($confhash{'validation'}{'dc'} eq '') {
+ $changes{'validation'}{'dc'} = &mt('None');
+ } else {
+ $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+ }
}
+ } elsif ($confhash{'validation'}{'dc'} ne '') {
+ $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
}
} elsif ($confhash{'validation'}{'dc'} ne '') {
$changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
@@ -7369,9 +7468,13 @@ sub modify_quotas {
} elsif ($confhash{'validation'}{'dc'} ne '') {
$changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
}
- } elsif (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
- if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
- $changes{'validation'}{'dc'} = &mt('None');
+ } else {
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
+ $changes{'validation'}{'dc'} = &mt('None');
+ }
+ }
}
}
}
@@ -10285,7 +10388,42 @@ sub modify_coursedefaults {
}
}
}
-
+ my $currclone = $domconfig{'coursedefaults'}{'canclone'};
+ my @currclonecode;
+ if (ref($currclone) eq 'HASH') {
+ if (ref($currclone->{'instcode'}) eq 'ARRAY') {
+ @currclonecode = @{$currclone->{'instcode'}};
+ }
+ }
+ my $newclone;
+ if ($env{'form.canclone'} =~ /^(none|domain|instcode)$/) {
+ $newclone = $env{'form.canclone'};
+ }
+ if ($newclone eq 'instcode') {
+ my @newcodes = &Apache::loncommon::get_env_multiple('form.clonecode');
+ my (%codedefaults,@code_order,@clonecode);
+ &Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults,
+ \@code_order);
+ foreach my $item (@code_order) {
+ if (grep(/^\Q$item\E$/,@newcodes)) {
+ push(@clonecode,$item);
+ }
+ }
+ if (@clonecode) {
+ $defaultshash{'coursedefaults'}{'canclone'} = { $newclone => \@clonecode };
+ my @diffs = &Apache::loncommon::compare_arrays(\@currclonecode,\@clonecode);
+ if (@diffs) {
+ $changes{'canclone'} = 1;
+ }
+ } else {
+ $newclone eq '';
+ }
+ } elsif ($newclone ne '') {
+ $defaultshash{'coursedefaults'}{'canclone'} = $newclone;
+ }
+ if ($newclone ne $currclone) {
+ $changes{'canclone'} = 1;
+ }
my %credits;
foreach my $type (@types) {
unless ($type eq 'community') {
@@ -10369,7 +10507,8 @@ sub modify_coursedefaults {
if (keys(%changes) > 0) {
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
- ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'})) {
+ ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
+ ($changes{'canclone'})) {
foreach my $item ('uselcmath','usejsme') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
@@ -10401,6 +10540,18 @@ sub modify_coursedefaults {
}
}
}
+ if ($changes{'canclone'}) {
+ if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') {
+ if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') {
+ my @clonecodes = @{$defaultshash{'coursedefaults'}{'canclone'}{'instcode'}};
+ if (@clonecodes) {
+ $domdefaults{'canclone'} = join('+',@clonecodes);
+ }
+ }
+ } else {
+ $domdefaults{'canclone'}=$defaultshash{'coursedefaults'}{'canclone'};
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -10489,6 +10640,17 @@ sub modify_coursedefaults {
} else {
$resulttext .= '
|