--- loncom/interface/lonconfigsettings.pm 2022/02/01 23:13:19 1.56 +++ loncom/interface/lonconfigsettings.pm 2022/02/06 21:36:59 1.57 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: lonconfigsettings.pm,v 1.56 2022/02/01 23:13:19 raeburn Exp $ +# $Id: lonconfigsettings.pm,v 1.57 2022/02/06 21:36:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -291,10 +291,27 @@ $jscript if (grep(/^linkprotection$/,@actions)) { if (ref($values) eq 'HASH') { if (ref($values->{'linkprotection'}) eq 'HASH') { + my $ltiauth; + if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { + $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; + } else { + my %domdefs = &Apache::lonnet::get_domain_defaults($dom); + $ltiauth = $domdefs{'crsltiauth'}; + } my $posslti = scalar(keys(%{$values->{'linkprotection'}})); - for (my $i=0; $i<$posslti; $i++) { - if ($values->{'linkprotection'}->{'usable'}) { - $onload .= "toggleLTI(document.display,'$i','secret');"; + for (my $i=0; $i<=$posslti; $i++) { + my $num = $i; + if ($i == $posslti) { + $num = 'add'; + } + if (ref($values->{'linkprotection'}->{$i}) eq 'HASH') { + if ($values->{'linkprotection'}->{$i}->{'usable'}) { + $onload .= "toggleLTI(document.display,'$num','secret');"; + } + } + if ($ltiauth) { + $onload .= "toggleLTIReqUser(document.display,'requser','optional','1','block','$num');". + "toggleLTIReqUser(document.display,'mapuser','userfield','other','inline-block','$num');"; } } }