[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonconfigsettings.pm
raeburn
raeburn at source.lon-capa.org
Fri May 22 12:52:16 EDT 2015
raeburn Fri May 22 16:52:16 2015 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonconfigsettings.pm
Log:
- For 2.11
- Backport 1.30.
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.21.4.6 loncom/interface/lonconfigsettings.pm:1.21.4.7
--- loncom/interface/lonconfigsettings.pm:1.21.4.6 Wed Apr 23 10:26:37 2014
+++ loncom/interface/lonconfigsettings.pm Fri May 22 16:52:16 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.21.4.6 2014/04/23 10:26:37 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.21.4.7 2015/05/22 16:52:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,15 +35,20 @@
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
+use Apache::courseclassifier();
+use LONCAPA qw(:DEFAULT :match);
sub print_header {
my ($r,$phase,$context,$jscript,$container) = @_;
- my ($pagetitle,$brcrumtitle,$action,$call_category_check,$crstype);
+ my ($pagetitle,$brcrumtitle,$action,$call_category_check,$instcode_check,
+ $crstype, at actions, at 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$/, at actions)) {
$call_category_check = qq|
if (formname == document.display) {
@@ -62,6 +67,54 @@
($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
}
$action = '/adm/courseprefs';
+ if ($phase eq 'display') {
+ if (grep(/^courseinfo$/, at 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.');
+ $instcode_check = <<"ENDSCRIPT";
+ if (formname == document.display) {
+ if (formname.cloners_instcode.length) {
+ for (var j=0; j<formname.cloners_instcode.length; j++) {
+ if (formname.cloners_instcode[j].checked) {
+ if (formname.cloners_instcode[j].value == 1) {
+ var codes;
+ if (document.getElementsByClassName) {
+ codes = document.getElementsByClassName('LC_cloners_instcodes');
+ } else {
+ codes = getElementsByClassName(document.body,'LC_cloners_instcodes');
+ }
+ if (codes.length) {
+ var gotcode = 0;
+ for (var i=0; i<codes.length; i++) {
+ if (codes[i].selectedIndex != 0) {
+ gotcode = 1;
+ break;
+ }
+ }
+ if (!gotcode) {
+ for (var k=0; k<formname.cloners_instcode.length; k++) {
+ if (formname.cloners_instcode[k].value == 0) {
+ formname.cloners_instcode[k].checked = true;
+ }
+ }
+ toggleCloners(document.display.cloners_instcode);
+ alert('$noinstcodestr');
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ENDSCRIPT
+ }
+ }
+ }
}
my $alert = &mt('You must select at least one functionality type to display.');
my $js = '
@@ -90,7 +143,7 @@
return;
}
}
- '.$call_category_check.'
+ '.$instcode_check.$call_category_check.'
formname.submit();
}'."\n";
if ($phase eq 'pickactions') {
@@ -119,6 +172,25 @@
'onload' => "setFormElements(document.pickactions);",
);
$additem = {'add_entries' => \%loaditems,};
+ } elsif ($phase eq 'display') {
+ if ($context eq 'domain') {
+ if (grep(/^coursedefaults$/, at 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$/, at 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));
@@ -248,7 +320,11 @@
&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) {
More information about the LON-CAPA-cvs
mailing list