--- loncom/interface/domainprefs.pm 2014/03/29 20:25:28 1.230 +++ loncom/interface/domainprefs.pm 2014/03/29 20:35:21 1.231 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.230 2014/03/29 20:25:28 raeburn Exp $ +# $Id: domainprefs.pm,v 1.231 2014/03/29 20:35:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -213,13 +213,13 @@ sub handler { 'contacts','defaults','scantron','coursecategories', 'serverstatuses','requestcourses','helpsettings', 'coursedefaults','usersessions','loadbalancing', - 'requestauthor'],$dom); + 'requestauthor','selfenrollment'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','selfcreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', 'serverstatuses','helpsettings', - 'coursedefaults','usersessions'); + 'coursedefaults','selfenrollment','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -417,6 +417,18 @@ sub handler { print => \&print_coursedefaults, modify => \&modify_coursedefaults, }, + 'selfenrollment' => + {text => 'Self-enrollment in Course/Community', + help => 'Domain_Configuration_Selfenrollment', + header => [{col1 => 'Configuration Rights', + col2 => 'Configured by Course Personnel or Domain Coordinator?'}, + {col1 => 'Defaults', + col2 => 'Value'}, + {col1 => 'Self-enrollment validation (optional)', + col2 => 'Value'},], + print => \&print_selfenrollment, + modify => \&modify_selfenrollment, + }, 'privacy' => {text => 'User Privacy', help => 'Domain_Configuration_User_Privacy', @@ -613,6 +625,8 @@ sub process_changes { $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { $output = &modify_coursedefaults($dom,$lastactref,%domconfig); + } elsif ($action eq 'selfenrollment') { + $output = &modify_selfenrollment($dom,$lastactref,%domconfig) } elsif ($action eq 'usersessions') { $output = &modify_usersessions($dom,$lastactref,%domconfig); } elsif ($action eq 'loadbalancing') { @@ -2819,6 +2833,243 @@ sub print_coursedefaults { return $datatable; } +sub print_selfenrollment { + my ($position,$dom,$settings,$rowtotal) = @_; + my ($css_class,$datatable); + my $itemcount = 1; + my @types = ('official','unofficial','community','textbook'); + if (($position eq 'top') || ($position eq 'middle')) { + my ($rowsref,$titlesref) = &get_selfenroll_titles(); + my %descs = &selfenroll_default_descs(); + my @rows; + my $key; + if ($position eq 'top') { + $key = 'admin'; + if (ref($rowsref) eq 'ARRAY') { + @rows = @{$rowsref}; + } + } elsif ($position eq 'middle') { + $key = 'default'; + @rows = ('types','registered','approval','limit'); + } + foreach my $row (@rows) { + if (defined($titlesref->{$row})) { + $itemcount ++; + $css_class = $itemcount%2?' class="LC_odd_row"':''; + $datatable .= '
'.&mt($type).' | '; + } + } + unless (($row eq 'registered') && ($key eq 'default')) { + $datatable .= '
---|
';
+ if ($position eq 'top') {
+ my %checked;
+ if ($current{$type} eq '0') {
+ $checked{'0'} = ' checked="checked"';
+ } else {
+ $checked{'1'} = ' checked="checked"';
+ }
+ foreach my $role ('1','0') {
+ $datatable .= ' ';
+ }
+ } else {
+ if ($row eq 'types') {
+ my %checked;
+ if ($current{$type} =~ /^(all|dom)$/) {
+ $checked{$1} = ' checked="checked"';
+ } else {
+ $checked{''} = ' checked="checked"';
+ }
+ foreach my $val ('','dom','all') {
+ $datatable .= ' ';
+ }
+ } elsif ($row eq 'registered') {
+ my %checked;
+ if ($current{$type} eq '1') {
+ $checked{'1'} = ' checked="checked"';
+ } else {
+ $checked{'0'} = ' checked="checked"';
+ }
+ foreach my $val ('0','1') {
+ $datatable .= ' ';
+ }
+ } elsif ($row eq 'approval') {
+ my %checked;
+ if ($current{$type} =~ /^([12])$/) {
+ $checked{$1} = ' checked="checked"';
+ } else {
+ $checked{'0'} = ' checked="checked"';
+ }
+ for my $val (0..2) {
+ $datatable .= ' ';
+ }
+ } elsif ($row eq 'limit') {
+ my %checked;
+ if ($current{$type} =~ /^(allstudents|selfenrolled)$/) {
+ $checked{$1} = ' checked="checked"';
+ } else {
+ $checked{'none'} = ' checked="checked"';
+ }
+ my $cap;
+ if ($currentcap{$type} =~ /^\d+$/) {
+ $cap = $currentcap{$type};
+ }
+ foreach my $val ('none','allstudents','selfenrolled') {
+ $datatable .= ' ';
+ }
+ $datatable .= ' '. + ''.&mt('Maximum allowed: '). + ''. + ''; + } + } + $datatable .= ' | ';
+ }
+ $datatable .= '
'.$changes{$key}{$item}.'').'