[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Mon Dec 27 22:35:34 EST 2021
raeburn Tue Dec 28 03:35:34 2021 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface domainprefs.pm
Log:
- For 2.11
Backport 1.399, 1.400
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.115 loncom/interface/domainprefs.pm:1.160.6.116
--- loncom/interface/domainprefs.pm:1.160.6.115 Fri Dec 24 21:00:55 2021
+++ loncom/interface/domainprefs.pm Tue Dec 28 03:35:34 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.115 2021/12/24 21:00:55 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.116 2021/12/28 03:35:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -741,6 +741,8 @@
$output .= &wafproxy_javascript($dom);
} elsif ($action eq 'autoupdate') {
$output .= &autoupdate_javascript();
+ } elsif ($action eq 'autoenroll') {
+ $output .= &autoenroll_javascript();
} elsif ($action eq 'login') {
$output .= &saml_javascript();
} elsif ($action eq 'ipaccess') {
@@ -2985,6 +2987,41 @@
ENDSCRIPT
}
+sub autoenroll_javascript {
+ return <<"ENDSCRIPT";
+<script type="text/javascript">
+// <![CDATA[
+function toggleFailsafe(form) {
+ var radioname = 'autoenroll_failsafe';
+ var divid = 'autoenroll_failsafe_div';
+ var num = form.elements[radioname].length;
+ if (num) {
+ var setvis = '';
+ for (var i=0; i<num; i++) {
+ if (form.elements[radioname][i].checked) {
+ if ((form.elements[radioname][i].value == 'zero') || (form.elements[radioname][i].value == 'any')) {
+ if (document.getElementById(divid)) {
+ document.getElementById(divid).style.display = 'inline-block';
+ }
+ setvis = 1;
+ }
+ break;
+ }
+ }
+ if (!setvis) {
+ if (document.getElementById(divid)) {
+ document.getElementById(divid).style.display = 'none';
+ }
+ }
+ }
+ return;
+}
+// ]]>
+</script>
+
+ENDSCRIPT
+}
+
sub saml_javascript {
return <<"ENDSCRIPT";
<script type="text/javascript">
@@ -3098,7 +3135,12 @@
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff,
+ $failsafe,$autofailsafe,$failsafesty,%failsafechecked);
+ $failsafesty = 'none';
+ %failsafechecked = (
+ off => ' checked="checked"',
+ );
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -3132,8 +3174,24 @@
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
- if (exists($settings->{'autofailsafe'})) {
- $failsafe = $settings->{'autofailsafe'};
+ if (exists($settings->{'failsafe'})) {
+ $failsafe = $settings->{'failsafe'};
+ if ($failsafe eq 'zero') {
+ $failsafechecked{'zero'} = ' checked="checked"';
+ $failsafechecked{'off'} = '';
+ $failsafesty = 'inline-block';
+ } elsif ($failsafe eq 'any') {
+ $failsafechecked{'any'} = ' checked="checked"';
+ $failsafechecked{'off'} = '';
+ }
+ $autofailsafe = $settings->{'autofailsafe'};
+ } elsif (exists($settings->{'autofailsafe'})) {
+ $autofailsafe = $settings->{'autofailsafe'};
+ if ($autofailsafe ne '') {
+ $failsafechecked{'zero'} = ' checked="checked"';
+ $failsafe = 'zero';
+ $failsafechecked{'off'} = '';
+ }
}
} else {
if ($autorun) {
@@ -3172,9 +3230,15 @@
$coownersoff.' value="0" />'.&mt('No').'</label></span></td>'.
'</tr><tr>'.
'<td>'.&mt('Failsafe for no drops when institutional data missing').'</td>'.
- '<td class="LC_right_item"><span class="LC_nobreak">'.
- '<input type="text" name="autoenroll_failsafe"'.
- ' value="'.$failsafe.'" size="4" /></span></td></tr>';
+ '<td class="LC_left_item"><span class="LC_nobreak">'.
+ '<span class="LC_nobreak"><label><input type="radio" name="autoenroll_failsafe" value="off" onclick="toggleFailsafe(this.form)"'.$failsafechecked{'off'}.' />'.&mt('Not in use').'</label></span> '.
+ '<span class="LC_nobreak"><label><input type="radio" name="autoenroll_failsafe" value="zero" onclick="toggleFailsafe(this.form)"'.$failsafechecked{'zero'}.' />'.&mt('Retrieved section enrollment is zero').'</label></span><br />'.
+ '<span class="LC_nobreak"><label><input type="radio" name="autoenroll_failsafe" value="any" onclick="toggleFailsafe(this.form)"'.$failsafechecked{'any'}.' />'.&mt('Retrieved section enrollment is zero or greater').'</label></span>'.
+ '<div class="LC_floatleft" style="display:'.$failsafesty.';" id="autoenroll_failsafe_div">'.
+ '<span class="LC_nobreak">'.
+ &mt('Threshold for number of students in section to drop: [_1]',
+ '<input type="text" name="autoenroll_autofailsafe" value="'.$autofailsafe.'" size="4" />').
+ '</span></div></td></tr>';
$$rowtotal += 4;
return $datatable;
}
@@ -11387,7 +11451,7 @@
my %title = ( run => 'Auto-enrollment active',
sender => 'Sender for notification messages',
coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)',
- failsafe => 'Failsafe for no drops if institutional data missing for a section');
+ autofailsafe => 'Failsafe for no drops if institutional data missing for a section');
my @offon = ('off','on');
my $sender_uname = $env{'form.sender_uname'};
my $sender_domain = $env{'form.sender_domain'};
@@ -11397,17 +11461,23 @@
$sender_domain = '';
}
my $coowners = $env{'form.autoassign_coowners'};
+ my $autofailsafe = $env{'form.autoenroll_autofailsafe'};
+ $autofailsafe =~ s{^\s+|\s+$}{}g;
+ if ($autofailsafe =~ /\D/) {
+ undef($autofailsafe);
+ }
my $failsafe = $env{'form.autoenroll_failsafe'};
- $failsafe =~ s{^\s+|\s+$}{}g;
- if ($failsafe =~ /\D/) {
- undef($failsafe);
+ unless (($failsafe eq 'zero') || ($failsafe eq 'any')) {
+ $failsafe = 'off';
+ undef($autofailsafe);
}
my %autoenrollhash = (
autoenroll => { 'run' => $env{'form.autoenroll_run'},
'sender_uname' => $sender_uname,
'sender_domain' => $sender_domain,
'co-owners' => $coowners,
- 'autofailsafe' => $failsafe,
+ 'autofailsafe' => $autofailsafe,
+ 'failsafe' => $failsafe,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -11435,9 +11505,12 @@
} elsif ($coowners) {
$changes{'coowners'} = 1;
}
- if ($currautoenroll{'autofailsafe'} ne $failsafe) {
+ if ($currautoenroll{'autofailsafe'} ne $autofailsafe) {
$changes{'autofailsafe'} = 1;
}
+ if ($currautoenroll{'failsafe'} ne $failsafe) {
+ $changes{'failsafe'} = 1;
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'<ul>';
if ($changes{'run'}) {
@@ -11458,11 +11531,24 @@
}
}
if ($changes{'autofailsafe'}) {
- if ($failsafe ne '') {
- $resulttext .= '<li>'.&mt('Failsafe for no drops if institutional data missing for a section set to: [_1]',$failsafe).'</li>';
+ if ($autofailsafe ne '') {
+ $resulttext .= '<li>'.&mt('Failsafe for no drops if institutional data missing for a section set to: [_1]',$autofailsafe).'</li>';
} else {
- $resulttext .= '<li>'.&mt('Failsafe for no drops if institutional data missing for a section: deleted');
+ $resulttext .= '<li>'.&mt('Failsafe for no drops if institutional data missing for a section not in use').'</li>';
}
+ }
+ if ($changes{'failsafe'}) {
+ if ($failsafe eq 'off') {
+ unless ($changes{'autofailsafe'}) {
+ $resulttext .= '<li>'.&mt('Failsafe for no drops if institutional data missing for a section not in use').'</li>';
+ }
+ } elsif ($failsafe eq 'zero') {
+ $resulttext .= '<li>'.&mt('Failsafe applies if retrieved section enrollment is zero').'</li>';
+ } else {
+ $resulttext .= '<li>'.&mt('Failsafe applies if retrieved section enrollment is zero or greater').'</li>';
+ }
+ }
+ if (($changes{'autofailsafe'}) || ($changes{'failsafe'})) {
&Apache::lonnet::get_domain_defaults($dom,1);
if (ref($lastactref) eq 'HASH') {
$lastactref->{'domdefaults'} = 1;
More information about the LON-CAPA-cvs
mailing list