[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm londocs.pm lonextresedit.pm lonexttool.pm
raeburn
raeburn at source.lon-capa.org
Wed Nov 29 20:52:15 EST 2017
raeburn Thu Nov 30 01:52:15 2017 EDT
Modified files:
/loncom/interface domainprefs.pm londocs.pm lonextresedit.pm
lonexttool.pm
Log:
- LON-CAPA as LTI Consumer.
- Value in custom field passed to Tool Provider on launch can be the value
of an item in %env. (Include LONCAPA::env{<var name>} when adding the
custom field in the domain configuration, where <var name> is the
env var for which the value is to be sent).
- Course Coordinator can set a path to append to the standard URL to
which the signed POSTed data are sent. (Path can be different for
each tool instance).
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.317 loncom/interface/domainprefs.pm:1.318
--- loncom/interface/domainprefs.pm:1.317 Thu Nov 30 01:49:19 2017
+++ loncom/interface/domainprefs.pm Thu Nov 30 01:52:14 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.317 2017/11/30 01:49:19 raeburn Exp $
+# $Id: domainprefs.pm,v 1.318 2017/11/30 01:52:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4050,7 +4050,7 @@
}
}
$datatable .= '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
- foreach my $item ('label','title','target','linktext','explanation') {
+ foreach my $item ('label','title','target','linktext','explanation','append') {
my $checked;
if ($courseconfig{$item}) {
$checked = ' checked="checked"';
@@ -4171,7 +4171,7 @@
}
$datatable .= '</tr></table></fieldset>'.
'<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
- foreach my $item ('label','title','target','linktext','explanation') {
+ foreach my $item ('label','title','target','linktext','explanation','append') {
$datatable .= '<label>'.
'<input type="checkbox" name="ltitools_courseconfig" value="'.$item.'" checked="checked" />'.
$lt{'crs'.$item}.'</label>'.(' ' x2)."\n";
@@ -4219,6 +4219,7 @@
'crstitle' => 'Course title',
'crslinktext' => 'Link Text',
'crsexplanation' => 'Explanation',
+ 'crsappend' => 'Provider URL',
);
return %lt;
}
@@ -10260,7 +10261,7 @@
}
}
my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
- foreach my $item ('label','title','target','linktext','explanation') {
+ foreach my $item ('label','title','target','linktext','explanation','append') {
if (grep(/^\Q$item\E$/, at courseconfig)) {
$confhash{$itemid}{'crsconf'}{$item} = 1;
if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') {
@@ -10451,7 +10452,7 @@
$resulttext .= ('*'x$num).'</li>';
}
$resulttext .= '<li>'.&mt('Configurable in course:');
- my @possconfig = ('label','title','target','linktext','explanation');
+ my @possconfig = ('label','title','target','linktext','explanation','append');
my $numconfig = 0;
if (ref($confhash{$itemid}{'crsconf'}) eq 'HASH') {
foreach my $item (@possconfig) {
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.641 loncom/interface/londocs.pm:1.642
--- loncom/interface/londocs.pm:1.641 Fri Nov 10 15:47:49 2017
+++ loncom/interface/londocs.pm Thu Nov 30 01:52:14 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.641 2017/11/10 15:47:49 raeburn Exp $
+# $Id: londocs.pm,v 1.642 2017/11/30 01:52:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -659,7 +659,7 @@
my $marker = $2;
my $info = $3;
my ($toolid,%toolhash,%toolsettings);
- my @extras = ('linktext','explanation','crslabel','crstitle');
+ my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
my @toolinfo = split(/:/,$info);
if ($residx) {
%toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
@@ -670,7 +670,7 @@
$toolid =~ s/\D//g;
($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
$toolhash{'linktext'},$toolhash{'explanation'},
- $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
+ $toolhash{'crslabel'},$toolhash{'crstitle'},$toolhash{'crsappend'}) = @toolinfo;
foreach my $item (@extras) {
$toolhash{$item} = &unescape($toolhash{$item});
}
Index: loncom/interface/lonextresedit.pm
diff -u loncom/interface/lonextresedit.pm:1.19 loncom/interface/lonextresedit.pm:1.20
--- loncom/interface/lonextresedit.pm:1.19 Wed May 10 13:49:14 2017
+++ loncom/interface/lonextresedit.pm Thu Nov 30 01:52:14 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: lonextresedit.pm,v 1.19 2017/05/10 13:49:14 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.20 2017/11/30 01:52:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -261,12 +261,12 @@
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
my (%newhash,$changed, at deleted,$errormsg);
($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'linktext'},$newhash{'explanation'},
- $newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args);
- foreach my $item ('linktext','explanation','crslabel','crstitle') {
+ $newhash{'crslabel'},$newhash{'crstitle'},$newhash{'crsappend'}) = split(/:/,$args);
+ foreach my $item ('linktext','explanation','crslabel','crstitle','crsappend') {
$newhash{$item} = &unescape($newhash{$item});
}
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle') {
+ foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle','crsappend') {
$newhash{$item} =~ s/^\s+//;
$newhash{$item} =~ s/\s+$//;
if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
@@ -335,15 +335,16 @@
}
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
$windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
- $legend,$urlelem,$toolelem,%toolattr);
+ $appendstyle,$legend,$urlelem,$toolelem,%toolattr);
$formname = 'new'.$type;
$toggle = $type;
$fieldsetid = 'upload'.$type.'form';
$urlid = $type.'url';
map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight',
- 'crstitlediv','crslabeldiv','crstitle','crslabel',
- 'windiv','linktextdiv','explanationdiv','linktext',
- 'explanation');
+ 'crstitlediv','crslabeldiv','crsappenddiv',
+ 'crstitle','crslabel','crsappend','windiv',
+ 'linktextdiv','explanationdiv','linktext',
+ 'explanation','providerurl');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
$windivstyle = 'display:none';
@@ -351,6 +352,7 @@
$explanationstyle = 'display:none';
$labelstyle = 'display:none';
$titlestyle = 'display:none';
+ $appendstyle = 'display:none';
if ($supplementalflag) {
$formname = 'newsupp'.$type;
$toggle = 'supp'.$type;
@@ -359,8 +361,8 @@
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
- $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
- $linktext,$explanation,%chkstate);
+ $crsappend,$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
+ $linktext,$explanation,$providerurl,%chkstate);
$fieldsetstyle = 'display: none;';
$action = '/adm/coursedocs';
my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
@@ -449,6 +451,11 @@
if ($icon) {
$image = '<img src="'.$icon.'" alt="'.$tooltitle.'" />';
}
+ if ($ltitools->{$toolhash{'id'}}->{'url'} =~ m{://}) {
+ (my $prot,my $host,$providerurl) = ($ltitools->{$toolhash{'id'}}->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
+ } else {
+ $providerurl = $ltitools->{$toolhash{'id'}}->{'url'};
+ }
$tooltarget = $toolhash{'target'};
if ($tooltarget eq 'window') {
$dimendivstyle = 'display:block';
@@ -473,6 +480,10 @@
$crslabel = $toolhash{'crslabel'};
$labelstyle = 'display:inline';
}
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'append'}) {
+ $crsappend = $toolhash{'crsappend'};
+ $appendstyle = 'display:inline';
+ }
if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'target'}) {
$dispdivstyle = 'display:block';
}
@@ -515,6 +526,7 @@
$toolelem .= '</select></span><br />';
$crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
$crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
+ $crsappend = '';
}
$toolelem .= '<div id="'.$toolattr{'dispdiv'}.'" style="'.$dispdivstyle.'">'.
'<span class="'.$class.'">'.&mt('Display target:').' '.
@@ -547,6 +559,11 @@
'<div id="'.$toolattr{'crstitlediv'}.'" style="'.$titlestyle.'">'.
'<span class="'.$class.'">'.&mt('Course title:').' '.
'<input type="text" id="'.$toolattr{'crstitle'}.'" name="exttooltitle" value="'.$crstitle.'"'.$disabled.' /></span><br />'.
+ '</div>'.
+ '<div id="'.$toolattr{'crsappenddiv'}.'" style="'.$appendstyle.'">'.
+ '<span class="'.$class.'">'.&mt('Append to URL[_1]',
+ '<span id="'.$toolattr{'providerurl'}.'"> ('.$providerurl.')<br /></span>').
+ '<input type="text" id="'.$toolattr{'crsappend'}.'" size="20" name="exttoolappend" value="'.$crsappend.'"'.$disabled.' /></span><br />'.
'</div>';
}
my $chooser = $toolelem;
@@ -629,6 +646,7 @@
if (ref($toolsref) eq 'HASH') {
my $num = scalar(keys(%{$toolsref}));
$toolsjs = " var ltitools = new Array($num);\n".
+ " var ltitoolsUrl = new Array($num);\n".
" var ltitoolsTarget = new Array($num);\n".
" var ltitoolsWidth = new Array($num);\n".
" var ltitoolsHeight = new Array($num);\n".
@@ -639,6 +657,7 @@
" var ltitoolsExplain = new Array($num);\n".
" var ltitoolsLabel = new Array($num);\n".
" var ltitoolsTitle = new Array($num);\n";
+ " var ltitoolsAppend = new Array($num);\n";
my $i = 0;
foreach my $key (sort { $a <=> $b } keys(%{$toolsref})) {
if (ref($toolsref->{$key}) eq 'HASH') {
@@ -648,12 +667,19 @@
my $height = $toolsref->{$key}->{'display'}->{'height'};
my $linkdef = $toolsref->{$key}->{'display'}->{'linktext'};
my $explaindef = $toolsref->{$key}->{'display'}->{'explanation'};
+ my $providerurl;
+ if ($toolsref->{$key}->{'url'} =~ m{://}) {
+ (my $prot,my $host,$providerurl) = ($toolsref->{$key}->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
+ } else {
+ $providerurl = $toolsref->{$key}->{'url'};
+ }
$toolsjs .= ' ltitools['.$i.'] = '."'$key';\n".
' ltitoolsTarget['.$i.'] = '."'$target';\n".
' ltitoolsWidth['.$i.'] = '."'$width';\n".
' ltitoolsHeight['.$i.'] = '."'$height';\n".
' ltitoolsLinkDef['.$i.'] = '."'$linkdef';\n".
- ' ltitoolsExplainDef['.$i.'] = '."'$explaindef';\n";
+ ' ltitoolsExplainDef['.$i.'] = '."'$explaindef';\n".
+ ' ltitoolsUrl['.$i.'] = '."'$providerurl';\n";
}
if (ref($toolsref->{$key}->{'crsconf'}) eq 'HASH') {
my $display = $toolsref->{$key}->{'crsconf'}->{'target'};
@@ -666,7 +692,10 @@
$toolsjs .= ' ltitoolsLabel['.$i.'] = '."'$label';\n";
my $title = $toolsref->{$key}->{'crsconf'}->{'title'};
$toolsjs .= ' ltitoolsTitle['.$i.'] = '."'$title';\n";
+ my $append = $toolsref->{$key}->{'crsconf'}->{'append'};
+ $toolsjs .= ' ltitoolsAppend['.$i.'] = '."'$append';\n";
}
+
$i++;
}
}
@@ -786,9 +815,11 @@
}
var labelinput = prefix+'toolcrslabel';
var titleinput = prefix+'toolcrstitle';
+ var appendinput = prefix+'toolcrsappend';
if (residx > 0) {
labelinput += '_'+residx;
titleinput += '_'+residx;
+ appendinput += '_'+residx;
}
if (document.getElementById(labelinput)) {
var crslabel = document.getElementById(labelinput).value;
@@ -804,6 +835,13 @@
} else {
info += ':';
}
+ if (document.getElementById(appendinput)) {
+ var crsappend = document.getElementById(appendinput).value;
+ crsappend.trim();
+ info += ':'+escape(crsappend);
+ } else {
+ info += ':';
+ }
info=escape(info);
if (residx > 0) {
eval("extform.importdetail.value=title+'='+info+'='+residx;extform.submit();");
@@ -854,8 +892,11 @@
heightinput = prefix+'tooldimenheight';
labeldiv = prefix+'toolcrslabeldiv';
titlediv = prefix+'toolcrstitlediv';
+ appenddiv = prefix+'toolcrsappenddiv';
+ providerurl = prefix+'toolproviderurl';
labelinput = prefix+'toolcrslabel';
titleinput = prefix+'toolcrstitle';
+ appendinput = prefix+'toolcrsappend';
windiv = prefix+'toolwindiv';
linktextdiv = prefix+'toollinktextdiv';
linktextinput = prefix+'toollinktext';
@@ -886,6 +927,9 @@
if (document.getElementById(titlediv)) {
document.getElementById(titlediv).style.display = 'none';
}
+ if (document.getElementById(appenddiv)) {
+ document.getElementById(appenddiv).style.display = 'none';
+ }
} else {
if (ltitools.length > 0) {
for (var j=0; j<ltitools.length; j++) {
@@ -969,6 +1013,21 @@
document.getElementById(titlediv).style.display = 'none';
}
}
+ if (document.getElementById(appenddiv)) {
+ if (ltitoolsAppend[j]) {
+ document.getElementById(appenddiv).style.display = 'inline';
+ if (document.getElementById(providerurl)) {
+ if ((ltitoolsUrl[j] != '') && (ltitoolsUrl[j] != null)) {
+ document.getElementById(providerurl).innerHTML.value = ' ('+ltitoolsUrl[j]+')<br />';
+ }
+ }
+ } else {
+ document.getElementById(appenddiv).style.display = 'none';
+ if (document.getElementById(providerurl)) {
+ document.getElementById(providerurl).innerHTML.value = '';
+ }
+ }
+ }
break;
}
}
Index: loncom/interface/lonexttool.pm
diff -u loncom/interface/lonexttool.pm:1.4 loncom/interface/lonexttool.pm:1.5
--- loncom/interface/lonexttool.pm:1.4 Mon Jun 6 17:40:48 2016
+++ loncom/interface/lonexttool.pm Thu Nov 30 01:52:14 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Launch External Tool Provider (LTI)
#
-# $Id: lonexttool.pm,v 1.4 2016/06/06 17:40:48 raeburn Exp $
+# $Id: lonexttool.pm,v 1.5 2017/11/30 01:52:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -104,6 +104,7 @@
};
$toolhash{'crslabel'} = $toolsettings{'crslabel'};
$toolhash{'crstitle'} = $toolsettings{'crstitle'};
+ $toolhash{'crsappend'} = $toolsettings{'crsappend'};
$is_tool = 1;
if ($target eq 'tex') {
$r->print(&mt('External Tool'));
@@ -111,8 +112,12 @@
my $submittext = &mt('Launch [_1]',$toolhash{'title'});
if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && ($toolhash{'url'} ne '')) {
my %lti = <i_params($r,$cnum,$cdom,$submittext,\%toolhash);
- $r->print(&launch_html($toolhash{'url'},$toolhash{'key'},
- $toolhash{'secret'},$submittext,\%lti));
+ my $url = $toolhash{'url'};
+ if ($toolhash{'crsappend'} ne '') {
+ $url .= $toolhash{'crsappend'};
+ }
+ $r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'},
+ $submittext,\%lti));
} else {
$r->print('<div>'.&mt('External Tool Unavailable').'</div>');
}
@@ -245,14 +250,14 @@
}
if ($passback) {
if ($ltirole eq 'Learner') {
- $ltiparams{'lis_outcome_service_url'} = $crsprotocol.'//'.$crshostname.'/adm/ltipassback';
+ $ltiparams{'lis_outcome_service_url'} = $crsprotocol.'//'.$crshostname.'/adm/service/passback';
$ltiparams{'ext_ims_lis_basic_outcome_url'} = $ltiparams{'lis_outcome_service_url'};
$ltiparams{'lis_result_sourcedid'} = ''; #FIXME
}
}
if ($roster) {
if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
- $ltiparams{'ext_ims_lis_memberships_url'} = $crsprotocol.'//'.$crshostname.'/adm/ltiroster';
+ $ltiparams{'ext_ims_lis_memberships_url'} = $crsprotocol.'//'.$crshostname.'/adm/service/roster';
$ltiparams{'ext_ims_lis_memberships_id'} = ''; #FIXME
}
}
@@ -291,7 +296,14 @@
}
if (keys(%custom)) {
foreach my $key (keys(%custom)) {
- $ltiparams{'custom_'.$key} = $custom{$key};
+ my $value = $custom{$key};
+ $value =~ s/^\s+|\s+\$//g;
+ if ($value =~ /^\QLONCAPA::env{\E([^\}]+)\}$/) {
+ if (exists($env{$1})) {
+ $value = $env{$1};
+ }
+ }
+ $ltiparams{'custom_'.$key} = $value;
}
}
foreach my $key (keys(%ltiparams)) {
@@ -304,12 +316,13 @@
sub launch_html {
my ($url,$key,$secret,$submittext,$paramsref) = @_;
my $hashref = &sign_params($url,$key,$secret,$paramsref);
+ my $action = &HTML::Entities::encode($url,'<>&"');
my $form = <<"END";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<body>
<div id="LCltiLaunch">
-<form name="LCltiLaunchForm" id="LCltiLaunchFormId" action="$url" method="post" encType="application/x-www-form-urlencoded">
+<form name="LCltiLaunchForm" id="LCltiLaunchFormId" action="$action" method="post" encType="application/x-www-form-urlencoded">
END
if (ref($hashref) eq 'HASH') {
foreach my $item (keys(%{$hashref})) {
More information about the LON-CAPA-cvs
mailing list