--- loncom/interface/domainprefs.pm 2014/10/04 02:44:18 1.160.6.54
+++ loncom/interface/domainprefs.pm 2016/09/18 19:22:48 1.160.6.71
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.54 2014/10/04 02:44:18 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.71 2016/09/18 19:22:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -250,6 +250,8 @@ sub handler {
header => [{col1 => 'Log-in Page Items',
col2 => '',},
{col1 => 'Log-in Help',
+ col2 => 'Value'},
+ {col1 => 'Custom HTML in document head',
col2 => 'Value'}],
print => \&print_login,
modify => \&modify_login,
@@ -412,7 +414,9 @@ sub handler {
'coursedefaults' =>
{text => 'Course/Community defaults',
help => 'Domain_Configuration_Course_Defaults',
- header => [{col1 => 'Defaults which can be overridden for each course by a DC',
+ header => [{col1 => 'Defaults which can be overridden in each course by a CC',
+ col2 => 'Value',},
+ {col1 => 'Defaults which can be overridden for each course by a DC',
col2 => 'Value',},],
print => \&print_coursedefaults,
modify => \&modify_coursedefaults,
@@ -461,6 +465,8 @@ sub handler {
{col1 => 'Log-in Page Items',
col2 => ''},
{col1 => 'Log-in Help',
+ col2 => 'Value'},
+ {col1 => 'Custom HTML in document head',
col2 => 'Value'}],
print => \&print_login,
modify => \&modify_login,
@@ -650,7 +656,7 @@ sub print_config_box {
my $colspan = '';
my $rightcolspan = '';
if (($action eq 'rolecolors') || ($action eq 'defaults') ||
- (($action eq 'login') && ($numheaders < 3))) {
+ (($action eq 'login') && ($numheaders < 4))) {
$colspan = ' colspan="2"';
}
if ($action eq 'usersessions') {
@@ -666,13 +672,13 @@ sub print_config_box {
';
$rowtotal ++;
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
- ($action eq 'usermodification') || ($action eq 'defaults') ||
+ ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
($action eq 'selfenrollment') || ($action eq 'usersessions')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
$output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
} elsif ($action eq 'login') {
- if ($numheaders == 3) {
+ if ($numheaders == 4) {
$colspan = ' colspan="2"';
$output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal);
} else {
@@ -721,10 +727,11 @@ sub print_config_box {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
}
$rowtotal ++;
- } elsif (($action eq 'usermodification') || ($action eq 'defaults')) {
+ } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
+ ($action eq 'defaults')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'login') {
- if ($numheaders == 3) {
+ if ($numheaders == 4) {
$output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
@@ -740,6 +747,27 @@ sub print_config_box {
} else {
$output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
}
+ $output .= '
+
+
+
+
+
+
+ ';
+ if ($numheaders == 4) {
+ $output .= '
+ '.&mt($item->{'header'}->[3]->{'col1'}).'
+ '.&mt($item->{'header'}->[3]->{'col2'}).'
+ ';
+ } else {
+ $output .= '
+ '.&mt($item->{'header'}->[2]->{'col1'}).'
+ '.&mt($item->{'header'}->[2]->{'col2'}).'
+ ';
+ }
+ $rowtotal ++;
+ $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
$output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
$rowtotal ++;
@@ -864,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 .= '
@@ -1162,6 +1188,57 @@ sub print_login {
$itemcount ++;
}
$datatable .= &captcha_choice('login',$settings,$itemcount);
+ } elsif ($caller eq 'headtag') {
+ my %domservers = &Apache::lonnet::get_servers($dom);
+ my $choice = $choices{'headtag'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= ''.$choice.' '.
+ ' ';
}
return $datatable;
}
@@ -1195,6 +1272,9 @@ sub login_choices {
link => "Link",
alink => "Active link",
vlink => "Visited link",
+ headtag => "Custom markup",
+ action => "Action",
+ current => "Current",
);
return %choices;
}
@@ -2318,7 +2398,7 @@ ENDSCRIPT
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff,$coownerson,$coownersoff);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -2352,6 +2432,9 @@ sub print_autoenroll {
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
+ if (exists($settings->{'autofailsafe'})) {
+ $failsafe = $settings->{'autofailsafe'};
+ }
} else {
if ($autorun) {
$runon = ' checked="checked" ';
@@ -2387,8 +2470,12 @@ sub print_autoenroll {
$coownerson.' value="1" />'.&mt('Yes').' '.
' '.&mt('No').' '.
- '';
- $$rowtotal += 3;
+ ''.
+ ''.&mt('Failsafe for no drops when institutional data missing').' '.
+ ''.
+ ' ';
+ $$rowtotal += 4;
return $datatable;
}
@@ -2746,7 +2833,7 @@ sub print_helpsettings {
sub radiobutton_prefs {
my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
- $additional) = @_;
+ $additional,$align) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
(ref($choices) eq 'HASH'));
@@ -2780,8 +2867,14 @@ sub radiobutton_prefs {
$datatable .=
''.
''.$choices->{$item}.
- ' '.
- ''.
+ ' ';
+ if ($align eq 'left') {
+ $datatable .= '';
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .=
+ ''.
' '.&mt('Yes').
' 'Course/Community users can create/upload PDF forms',
uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)',
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
coursecredits => 'Credits can be specified for courses',
+ 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)",
+ mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver',
);
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
+ postsubmit => 60,
+ mysqltables => 172800,
);
if ($position eq 'top') {
- %defaultchecked = ('canuse_pdfforms' => 'off');
- @toggles = ('canuse_pdfforms');
+ %defaultchecked = (
+ 'uselcmath' => 'on',
+ 'usejsme' => 'on',
+ 'canclone' => 'none',
+ );
+ @toggles = ('uselcmath','usejsme');
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
- \%choices,$itemcount);
+ \%choices,$itemcount);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.
+ ''.$choices{'canclone'}.
+ ' ';
+ my $currcanclone = 'none';
+ my $onclick;
+ my @cloneoptions = ('none','domain');
+ my %clonetitles = (
+ none => 'No additional course requesters',
+ domain => "Any course requester in course's domain",
+ instcode => 'Course requests for official courses ...',
+ );
+ my (%codedefaults,@code_order,@posscodes);
+ if (&Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults,
+ \@code_order) eq 'ok') {
+ if (@code_order > 0) {
+ push(@cloneoptions,'instcode');
+ $onclick = ' onclick="toggleDisplay(this.form,'."'cloneinstcode'".');"';
+ }
+ }
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'canclone'}) {
+ if (ref($settings->{'canclone'}) eq 'HASH') {
+ if (ref($settings->{'canclone'}{'instcode'}) eq 'ARRAY') {
+ if (@code_order > 0) {
+ $currcanclone = 'instcode';
+ @posscodes = @{$settings->{'canclone'}{'instcode'}};
+ }
+ }
+ } elsif ($settings->{'canclone'} eq 'domain') {
+ $currcanclone = $settings->{'canclone'};
+ }
+ }
+ }
+ foreach my $option (@cloneoptions) {
+ my ($checked,$additional);
+ if ($currcanclone eq $option) {
+ $checked = ' checked="checked"';
+ }
+ if ($option eq 'instcode') {
+ if (@code_order) {
+ my $show = 'none';
+ if ($checked) {
+ $show = 'block';
+ }
+ $additional = '
'.
+ &mt('Institutional codes for new and cloned course have identical:').
+ ' ';
+ foreach my $item (@code_order) {
+ my $codechk;
+ if ($checked) {
+ if (grep(/^\Q$item\E$/,@posscodes)) {
+ $codechk = ' checked="checked"';
+ }
+ }
+ $additional .= ''.
+ ' '.
+ $item.' ';
+ }
+ $additional .= (' 'x2).'('.&mt('check as many as needed').')';
+ }
+ }
+ $datatable .=
+ ' '.$clonetitles{$option}.
+ ' '.$additional.' ';
+ }
+ $datatable .= ' '.
+ ' ';
+ $itemcount ++;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits,
- %curruploadquota);
+ my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql);
my $currusecredits = 0;
+ my $postsubmitclient = 1;
my @types = ('official','unofficial','community','textbook');
if (ref($settings) eq 'HASH') {
$currdefresponder = $settings->{'anonsurvey_threshold'};
@@ -2827,14 +3001,51 @@ sub print_coursedefaults {
}
}
if (ref($settings->{'coursecredits'}) eq 'HASH') {
- $def_official_credits = $settings->{'coursecredits'}->{'official'};
- $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
- $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'};
- if (($def_official_credits ne '') || ($def_unofficial_credits ne '') ||
- ($def_textbook_credits ne '')) {
- $currusecredits = 1;
+ foreach my $type (@types) {
+ next if ($type eq 'community');
+ $defcredits{$type} = $settings->{'coursecredits'}->{$type};
+ if ($defcredits{$type} ne '') {
+ $currusecredits = 1;
+ }
+ }
+ }
+ if (ref($settings->{'postsubmit'}) eq 'HASH') {
+ if ($settings->{'postsubmit'}->{'client'} eq 'off') {
+ $postsubmitclient = 0;
+ foreach my $type (@types) {
+ $deftimeout{$type} = $staticdefaults{'postsubmit'};
+ }
+ } else {
+ foreach my $type (@types) {
+ if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') {
+ if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) {
+ $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type};
+ } else {
+ $deftimeout{$type} = $staticdefaults{'postsubmit'};
+ }
+ } else {
+ $deftimeout{$type} = $staticdefaults{'postsubmit'};
+ }
+ }
+ }
+ } else {
+ foreach my $type (@types) {
+ $deftimeout{$type} = $staticdefaults{'postsubmit'};
}
}
+ if (ref($settings->{'mysqltables'}) eq 'HASH') {
+ foreach my $type (keys(%{$settings->{'mysqltables'}})) {
+ $currmysql{$type} = $settings->{'mysqltables'}{$type};
+ }
+ } else {
+ foreach my $type (@types) {
+ $currmysql{$type} = $staticdefaults{'mysqltables'};
+ }
+ }
+ } else {
+ foreach my $type (@types) {
+ $deftimeout{$type} = $staticdefaults{'postsubmit'};
+ }
}
if (!$currdefresponder) {
$currdefresponder = $staticdefaults{'anonsurvey_threshold'};
@@ -2874,21 +3085,14 @@ sub print_coursedefaults {
$display = 'block';
}
my $additional = ''.
- ''.
- &mt('Default credits for official courses [_1]',
- ' ').
- ' '.
- ''.
- &mt('Default credits for unofficial courses [_1]',
- ' ').
- ' '.
- ''.
- &mt('Default credits for textbook courses [_1]',
- ' ').
- '
'."\n";
+ ''.&mt('Default credits').' '."\n";
%defaultchecked = ('coursecredits' => 'off');
@toggles = ('coursecredits');
my $current = {
@@ -2896,9 +3100,46 @@ sub print_coursedefaults {
};
(my $table,$itemcount) =
&radiobutton_prefs($current,\@toggles,\%defaultchecked,
- \%choices,$itemcount,$onclick,$additional);
+ \%choices,$itemcount,$onclick,$additional,'left');
$datatable .= $table;
+ $onclick = "toggleDisplay(this.form,'studentsubmission');";
+ my $display = 'none';
+ if ($postsubmitclient) {
+ $display = 'block';
+ }
+ $additional = ''.
+ &mt('Number of seconds submit is disabled').'
'.
+ '
'.&mt('Enter 0 to remain disabled until page reload.').' '.
+ '
'."\n";
+ %defaultchecked = ('postsubmit' => 'on');
+ @toggles = ('postsubmit');
+ $current = {
+ 'postsubmit' => $postsubmitclient,
+ };
+ ($table,$itemcount) =
+ &radiobutton_prefs($current,\@toggles,\%defaultchecked,
+ \%choices,$itemcount,$onclick,$additional,'left');
+ $datatable .= $table;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'mysqltables'}.
+ ' '.
+ ''.
+ ' '."\n";
$itemcount ++;
+
}
$$rowtotal += $itemcount;
return $datatable;
@@ -3143,7 +3384,13 @@ sub print_usersessions {
if ($position eq 'top') {
if (keys(%serverhomes) > 1) {
my %spareid = ¤t_offloads_to($dom,$settings,\%servers);
- $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$rowtotal);
+ my $curroffloadnow;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'offloadnow'}) eq 'HASH') {
+ $curroffloadnow = $settings->{'offloadnow'};
+ }
+ }
+ $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$curroffloadnow,$rowtotal);
} else {
$datatable .= ''.
&mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.');
@@ -3393,7 +3640,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;
@@ -3413,12 +3660,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".
+ ' '.
+ ' '.&mt('Switch active users on next access').' '.
"\n";
my (%current,%canselect);
my @choices =
@@ -3642,9 +3898,10 @@ sub print_loadbalancing {
$disabled = ' disabled="disabled"';
}
$targettable .=
- ' '.
+ ' '.$chkboxval.
- ' ';
+ '';
my $rem = $i%($numinrow);
if ($rem == 0) {
if (($i > 0) && ($i < $numspares-1)) {
@@ -3734,7 +3991,7 @@ sub loadbalancing_rules {
if (ref($currrules) eq 'HASH') {
$current = $currrules->{$type};
}
- if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) {
+ if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
if ($dom ne &Apache::lonnet::host_domain($lonhost)) {
$current = '';
}
@@ -3786,7 +4043,7 @@ sub loadbalance_rule_row {
my @rulenames;
my %ruletitles = &offloadtype_text();
if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) {
- @rulenames = ('balancer','offloadedto');
+ @rulenames = ('balancer','offloadedto','specific');
} else {
@rulenames = ('default','homeserver');
if ($type eq '_LC_external') {
@@ -3797,7 +4054,7 @@ sub loadbalance_rule_row {
push(@rulenames,'none');
}
my $style = $targets_div_style;
- if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) {
+ if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
$style = $homedom_div_style;
}
my $space;
@@ -3848,8 +4105,13 @@ sub loadbalance_rule_row {
' '.$ruletitles{$rulenames[$i]}.
- ''.$extra.' '."\n";
+ ')"'.$checked.' /> ';
+ if (($rulenames[$i] eq 'specific') && ($type =~ /^_LC_ipchange/)) {
+ $output .= $ruletitles{'particular'};
+ } else {
+ $output .= $ruletitles{$rulenames[$i]};
+ }
+ $output .= ''.$extra.' '."\n";
}
$output .= ' '."\n";
return $output;
@@ -3864,6 +4126,7 @@ sub offloadtype_text {
'none' => 'No offload',
'balancer' => 'Session hosted on Load Balancer, after re-authentication',
'offloadedto' => 'Session hosted on offload server, after re-authentication',
+ 'particular' => 'Session hosted (after re-auth) on server:',
);
return %ruletitles;
}
@@ -4304,7 +4567,8 @@ sub email_as_username {
sub captcha_choice {
my ($context,$settings,$itemcount) = @_;
- my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext);
+ my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
+ $vertext,$currver);
my %lt = &captcha_phrases();
$keyentry = 'hidden';
if ($context eq 'cancreate') {
@@ -4322,6 +4586,11 @@ sub captcha_choice {
$pubtext = $lt{'pub'};
$privtext = $lt{'priv'};
$keyentry = 'text';
+ $vertext = $lt{'ver'};
+ $currver = $settings->{'recaptchaversion'};
+ if ($currver ne '2') {
+ $currver = 1;
+ }
}
if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
$currpub = $settings->{'recaptchakeys'}{'public'};
@@ -4355,7 +4624,11 @@ sub captcha_choice {
$currpub.'" size="40" /> '."\n".
''.$privtext.' '."\n".
'
'."\n".
+ $currpriv.'" size="40" /> '.
+ ''.$vertext.' '."\n".
+ ' '.
+ ' '."\n".
'';
return $output;
}
@@ -4538,11 +4811,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') {
@@ -4611,7 +4881,7 @@ sub print_defaults {
$datatable .= '