--- loncom/interface/lonconfigsettings.pm 2012/10/30 10:39:02 1.22
+++ loncom/interface/lonconfigsettings.pm 2015/06/09 21:22:56 1.31
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.22 2012/10/30 10:39:02 foxr Exp $
+# $Id: lonconfigsettings.pm,v 1.31 2015/06/09 21:22:56 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,15 +36,20 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonparmset();
+use Apache::courseclassifier();
+use LONCAPA qw(:DEFAULT :match);
sub print_header {
my ($r,$phase,$context,$jscript,$container) = @_;
- my ($pagetitle,$brcrumtitle,$action,$call_category_check);
+ my ($pagetitle,$brcrumtitle,$action,$call_category_check,$instcode_check,
+ $crstype,@actions,@code_order);
+ if ($phase eq 'display') {
+ @actions = &Apache::loncommon::get_env_multiple('form.actions');
+ }
if ($context eq 'domain') {
($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','View/Modify Domain Settings');
$action = '/adm/domainprefs';
if ($phase eq 'display') {
- my @actions = &Apache::loncommon::get_env_multiple('form.actions');
if (grep(/^coursecategories$/,@actions)) {
$call_category_check = qq|
if (formname == document.display) {
@@ -56,14 +61,65 @@ sub print_header {
}
}
} else {
- if (&Apache::loncommon::course_type() eq 'Community') {
+ $crstype = &Apache::loncommon::course_type();
+ if ($crstype eq 'Community') {
($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
} else {
($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
}
$action = '/adm/courseprefs';
+ if ($phase eq 'display') {
+ if (grep(/^courseinfo$/,@actions)) {
+ my %codedefaults;
+ &Apache::lonnet::auto_instcode_defaults($env{'request.role.domain'},\%codedefaults,
+ \@code_order);
+ if (@code_order) {
+ my $noinstcodestr = &mt('You indicated cloning based on category, but did not select any categories.');
+ &js_escape(\$noinstcodestr);
+ $instcode_check = <<"ENDSCRIPT";
+ if (formname == document.display) {
+ if (formname.cloners_instcode.length) {
+ for (var j=0; j
// "setFormElements(document.pickactions);",
);
$additem = {'add_entries' => \%loaditems,};
+ } elsif ($phase eq 'display') {
+ if ($context eq 'domain') {
+ if (grep(/^coursedefaults$/,@actions)) {
+ my %loaditems = (
+ ' onload' => "toggleDisplay(document.display,'cloneinstcode');".
+ "toggleDisplay(document.display,'credits');".
+ "toggleDisplay(document.display,'studentsubmission');",
+ );
+ $additem = {'add_entries' => \%loaditems,};
+ }
+ } elsif ($context eq 'course') {
+ if (grep(/^courseinfo$/,@actions)) {
+ if (@code_order) {
+ $additem = {
+ add_entries => {'onload' => "courseSet('','load');toggleCloners(document.display.cloners_instcode);"},
+ };
+ }
+ }
+ }
}
$r->print(&Apache::loncommon::start_page($pagetitle,$js,$additem));
$r->print(&Apache::lonhtmlcommon::breadcrumbs($brcrumtitle));
@@ -130,7 +205,7 @@ $jscript
');
if ($container) {
- &Apache::lonparmset::startSettingsScreen($r,$container);
+ &Apache::lonparmset::startSettingsScreen($r,$container,$crstype);
}
$r->print('
');
+ return \%lastact;
}
sub display_settings {
@@ -251,7 +329,11 @@ sub display_settings {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'display')",
text=>"Display/Edit Settings"});
- &print_header($r,$phase,$context,$jscript,$container);
+ my $instcode;
+ if (ref($values) eq 'HASH') {
+ $instcode = $values->{'internal.coursecode'};
+ }
+ &print_header($r,$phase,$context,$jscript,$container,$instcode);
my $divwidth = 900;
if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) {
if (@actions > 0) {
@@ -261,16 +343,44 @@ sub display_settings {
if (grep(/^\Q$item\E$/,@actions)) {
push(@items,$item);
if ($context eq 'domain') {
+ my $settings;
+ if (ref($values) eq 'HASH') {
+ $settings = $values->{$item};
+ }
if ($item eq 'usersessions') {
$r->print(''."\n");
+ } elsif ($item eq 'selfcreation') {
+ if (ref($values) eq 'HASH') {
+ $settings = $values->{'usercreation'};
+ }
+ } elsif ($item eq 'defaults') {
+ if (ref($values->{'inststatus'}) eq 'HASH') {
+ if (ref($values->{'defaults'}) eq 'HASH') {
+ $settings = {%{$values->{'inststatus'}},%{$values->{'defaults'}}};
+ } else {
+ $settings = $values->{'inststatus'};
+ }
+ } else {
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my $inststatus = {
+ inststatustypes => $usertypes,
+ inststatusorder => $types,
+ inststatusguest => [],
+ };
+ if (ref($values->{defaults}) eq 'HASH') {
+ $settings = {%{$inststatus},%{$values->{'defaults'}}};
+ } else {
+ $settings = $inststatus;
+ }
+ }
}
($output{$item},$rowtotal{$item}) =
&Apache::domainprefs::print_config_box($r,$dom,$confname,
- $phase,$item,$prefs->{$item},$values->{$item});
+ $phase,$item,$prefs->{$item},$settings);
} else {
($output{$item},$rowtotal{$item}) =
&Apache::courseprefs::print_config_box($r,$dom,$phase,
@@ -292,6 +402,9 @@ sub display_settings {
}
$r->print('');
}
+ if ($container) {
+ &Apache::lonparmset::endSettingsScreen($r);
+ }
$r->print(&Apache::loncommon::end_page());
return;
}
@@ -348,6 +461,9 @@ sub display_choices {
}
$r->print(&print_footer($r,$phase,'display','Display',undef,$container));
$r->print('');
+ if ($container) {
+ &Apache::lonparmset::endSettingsScreen($r);
+ }
$r->print(&Apache::loncommon::end_page());
return;
}