--- loncom/interface/courseprefs.pm 2022/04/06 14:35:27 1.111
+++ loncom/interface/courseprefs.pm 2022/07/08 04:24:24 1.113
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.111 2022/04/06 14:35:27 raeburn Exp $
+# $Id: courseprefs.pm,v 1.113 2022/07/08 04:24:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1593,6 +1593,22 @@ sub process_linkprot {
$linkprot{$itemid}{$inner} = $env{$formitem};
}
}
+ my $urlitem = 'form.linkprot_returnurl_'.$idx;
+ my $urlparamname = 'form.linkprot_urlparam_'.$idx;
+ if ($env{$urlitem} == 1) {
+ $env{$urlparamname} =~ s/(`)/'/g;
+ } elsif (exists($env{$urlparamname})) {
+ $env{$urlparamname} = '';
+ }
+ unless ($idx eq 'add') {
+ if ((!$current{'returnurl'} && ($env{$urlparamname} ne '')) ||
+ ($current{'returnurl'} && ($env{$urlparamname} eq ''))) {
+ $haschanges{$itemid} = 1;
+ }
+ }
+ if ($env{$urlparamname} ne '') {
+ $linkprot{$itemid}{'returnurl'} = $env{$urlparamname};
+ }
if ($ltiauth) {
my $reqitem = 'form.linkprot_requser_'.$idx;
$env{$reqitem} =~ s/(`)/'/g;
@@ -2266,7 +2282,7 @@ sub store_linkprot {
my %values = %{$changes->{$id}};
my %desc = &linkprot_names();
my $display;
- foreach my $title ('name','lifetime','version','key','secret') {
+ foreach my $title ('name','lifetime','version','key','secret','returnurl') {
if (($title eq 'key') || ($title eq 'secret')) {
if (ref($ltienc{$id}) eq 'HASH') {
if (exists($ltienc{$id}{$title})) {
@@ -2282,6 +2298,10 @@ sub store_linkprot {
if ($values{$title} eq 'LTI-1p0') {
$display .= $desc{$title}.': 1.1, ';
}
+ } elsif ($title eq 'returnurl') {
+ if ($values{$title}) {
+ $display .= &mt('Return URL parameter').': '.$values{$title}.', ';
+ }
} else {
$display .= $desc{$title}.': '.$values{$title}.', ';
}
@@ -2802,7 +2822,7 @@ function toggleLinkProt(form,num,item) {
return;
}
-function toggleLinkProtReqUser(form,item,extra,valon,styleon,num) {
+function toggleLinkProtExtra(form,item,extra,valon,styleon,num) {
if (document.getElementById('linkprot_'+extra+'_'+num)) {
var extraid = document.getElementById('linkprot_'+extra+'_'+num);
var itemname = form.elements['linkprot_'+item+'_'+num];
@@ -5709,10 +5729,10 @@ sub print_linkprotection {
'
'.
' | ';
- my ($usersty,$onclickrequser,%checkedrequser);
+ my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl);
if ($ltiauth) {
$usersty = 'display:none';
- $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','$i'".');"';
+ $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','$i'".');"';
%checkedrequser = (
no => ' checked="checked"',
yes => '',
@@ -5726,6 +5746,15 @@ sub print_linkprotection {
$usersty = 'display:inline-block';
}
}
+ $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','$i'".');"';
+ %checkedreturnurl = (
+ no => ' checked="checked"',
+ yes => '',
+ );
+ if ($values{'returnurl'} ne '') {
+ $checkedreturnurl{'yes'} = $checkedreturnurl{'no'};
+ $checkedreturnurl{'no'} = '';
+ }
$datatable .=
''.$desc{'name'}.
': '.
@@ -5734,15 +5763,7 @@ sub print_linkprotection {
' '."\n".
(' 'x2).
''.$desc{'lifetime'}.':';
- if ($ltiauth) {
- $datatable .= (' 'x2).''.$desc{'requser'}.'?'.
- ' '.
- '';
- }
- $datatable .= '
';
+ ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' />
';
if ($values{'key'} ne '') {
$datatable .= ''.$desc{'key'};
if ($noedit) {
@@ -5796,8 +5817,22 @@ sub print_linkprotection {
'';
}
}
+ $datatable .= '
'.
+ ''.$desc{'returnurl'}.'?'.
+ ' '.
+ ''.
+ ' '.
+ ''.&mt('Parameter name').':'.
+ ''.
+ ' ';
if ($ltiauth) {
- $datatable .=
+ $datatable .= (' 'x2).''.$desc{'requser'}.'?'.
+ ' '.
+ ''.
''.
' | '."\n".
'';
- my ($usersty,$onclickrequser,%checkedrequser);
+ my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl);
if ($ltiauth) {
$usersty = 'display:none';
- $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','add'".');"';
+ $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','add'".');"';
%checkedrequser = (
no => ' checked="checked"',
yes => '',
);
$datatable .= ''.
+ $datatable .= (' 'x2).''.$desc{'requser'}.'?'.
+ ' '.
+ ''.
+ ''.
'';
@@ -5864,6 +5912,7 @@ sub linkprot_names {
'lifetime' => 'Nonce lifetime (s)',
'name' => 'Launcher Application',
'secret' => 'Secret',
+ 'returnurl' => 'Launcher return URL',
'requser' => 'Use identity',
'email' => 'Email address',
'sourcedid' => 'User ID',
@@ -5919,7 +5968,7 @@ sub linkprot_options {
$checked{'auth'} = ' checked="checked"';
}
}
- my $onclickuser = ' onclick="toggleLinkProtReqUser(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
+ my $onclickuser = ' onclick="toggleLinkProtExtra(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
my $output = ' '.
&mt('Source of LON-CAPA username in LTI request').': ';
foreach my $option ('sourcedid','email','other') {
|