[LON-CAPA-cvs] cvs: rat / lonwrapper.pm loncom/interface domainprefs.pm londocs.pm lonextresedit.pm
raeburn
raeburn at source.lon-capa.org
Tue Apr 25 18:19:04 EDT 2017
raeburn Tue Apr 25 22:19:04 2017 EDT
Modified files:
/loncom/interface domainprefs.pm lonextresedit.pm londocs.pm
/rat lonwrapper.pm
Log:
- Bug 6754. Make LON-CAPA an LTI Tool Consumer (LTI 1.1).
When LTI Tool set to be accessed via link to open new tab,
domain configuration for each Tool includes:
(a) default link text
(b) default text block
(c) whether link text and/or text block content configurable in course.
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.295 loncom/interface/domainprefs.pm:1.296
--- loncom/interface/domainprefs.pm:1.295 Mon Mar 20 03:19:43 2017
+++ loncom/interface/domainprefs.pm Tue Apr 25 22:18:59 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.295 2017/03/20 03:19:43 raeburn Exp $
+# $Id: domainprefs.pm,v 1.296 2017/04/25 22:18:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -488,7 +488,7 @@
},
'ltitools' =>
{text => 'External Tools (LTI)',
- help => 'Domain_configuration_LTI_Tools',
+ help => 'Domain_Configuration_LTI_Tools',
header => [{col1 => 'Setting',
col2 => 'Value',}],
print => \&print_ltitools,
@@ -3754,6 +3754,8 @@
if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) {
$currdisp{'height'} = $1;
}
+ $currdisp{'linktext'} = $settings->{$item}->{'display'}->{'linktext'};
+ $currdisp{'explanation'} = $settings->{$item}->{'display'}->{'explanation'};
} else {
$currdisp{'iframe'} = ' checked="checked"';
}
@@ -3767,6 +3769,12 @@
'<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'.
(' 'x2);
}
+ $datatable .= '<br />'.
+ '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
+ '<input type="text" name="ltitools_linktext_'.$i.'" size="25" value="'.$currdisp{'linktext'}.'" /></label></div>'.
+ '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
+ '<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}.
+ '</textarea></div><div style=""></div><br />';
$datatable .= '<br />';
foreach my $extra ('passback','roster') {
my $checkedon = '';
@@ -3848,7 +3856,7 @@
}
}
$datatable .= '<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
- foreach my $item ('label','title','target') {
+ foreach my $item ('label','title','target','linktext','explanation') {
my $checked;
if ($courseconfig{$item}) {
$checked = ' checked="checked"';
@@ -3926,7 +3934,12 @@
'<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'.
(' 'x2);
}
- $datatable .= '<br />';
+ $datatable .= '<br />'.
+ '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
+ '<input type="text" name="ltitools_add_linktext" size="5" /></label></div>'.
+ '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
+ '<textarea name=ltitools_add_explanation" rows="5" cols="40"></textarea>'.
+ '</div><div style=""></div><br />';
foreach my $extra ('passback','roster') {
$datatable .= $lt{$extra}.' '.
'<label><input type="radio" name="ltitools_add_'.$extra.'" value="1" />'.
@@ -3964,10 +3977,10 @@
}
$datatable .= '</tr></table></fieldset>'.
'<fieldset><legend>'.&mt('Configurable in course').'</legend><span class="LC_nobreak">';
- foreach my $item ('label','title','target') {
- $datatable .= '<label>'.
- '<input type="checkbox" name="ltitools_courseconfig" value="'.$item.'" checked="checked" />'.
- $lt{'crs'.$item}.'</label>'.(' ' x2)."\n";
+ foreach my $item ('label','title','target','linktext','explanation') {
+ $datatable .= '<label>'.
+ '<input type="checkbox" name="ltitools_courseconfig" value="'.$item.'" checked="checked" />'.
+ $lt{'crs'.$item}.'</label>'.(' ' x2)."\n";
}
$datatable .= '</span></fieldset>'.
'<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'.
@@ -3985,28 +3998,32 @@
sub ltitools_names {
my %lt = &Apache::lonlocal::texthash(
- 'title' => 'Title',
- 'version' => 'Version',
- 'msgtype' => 'Message Type',
- 'url' => 'URL',
- 'key' => 'Key',
- 'secret' => 'Secret',
- 'icon' => 'Icon',
- 'user' => 'Username:domain',
- 'fullname' => 'Full Name',
- 'firstname' => 'First Name',
- 'lastname' => 'Last Name',
- 'email' => 'E-mail',
- 'roles' => 'Role',
- 'window' => 'Window/Tab',
- 'iframe' => 'iFrame',
- 'height' => 'Height',
- 'width' => 'Width',
- 'passback' => 'Tool can return grades:',
- 'roster' => 'Tool can retrieve roster:',
- 'crstarget' => 'Display target',
- 'crslabel' => 'Course label',
- 'crstitle' => 'Course title',
+ 'title' => 'Title',
+ 'version' => 'Version',
+ 'msgtype' => 'Message Type',
+ 'url' => 'URL',
+ 'key' => 'Key',
+ 'secret' => 'Secret',
+ 'icon' => 'Icon',
+ 'user' => 'Username:domain',
+ 'fullname' => 'Full Name',
+ 'firstname' => 'First Name',
+ 'lastname' => 'Last Name',
+ 'email' => 'E-mail',
+ 'roles' => 'Role',
+ 'window' => 'Window/Tab',
+ 'iframe' => 'iFrame',
+ 'height' => 'Height',
+ 'width' => 'Width',
+ 'linktext' => 'Default Link Text',
+ 'explanation' => 'Default Explanation',
+ 'passback' => 'Tool can return grades:',
+ 'roster' => 'Tool can retrieve roster:',
+ 'crstarget' => 'Display target',
+ 'crslabel' => 'Course label',
+ 'crstitle' => 'Course title',
+ 'crslinktext' => 'Link Text',
+ 'crsexplanation' => 'Explanation',
);
return %lt;
}
@@ -9483,11 +9500,17 @@
if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
$confhash{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
}
- foreach my $item ('width','height') {
+ foreach my $item ('width','height','linktext','explanation') {
$env{'form.ltitools_add_'.$item} =~ s/^\s+//;
$env{'form.ltitools_add_'.$item} =~ s/\s+$//;
- if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
+ if (($item eq 'width') || ($item eq 'height')) {
+ if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
+ $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
+ }
+ } else {
+ if ($env{'form.ltitools_add_'.$item} ne '') {
+ $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
+ }
}
}
if ($env{'form.ltitools_add_target'} eq 'window') {
@@ -9599,6 +9622,28 @@
} else {
$changes{$itemid} = 1;
}
+ } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
+ if ($domconfig{$action}{$itemid}{'display'}{$size} ne '') {
+ $changes{$itemid} = 1;
+ }
+ }
+ }
+ foreach my $item ('linktext','explanation') {
+ $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
+ $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
+ if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
+ $confhash{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
+ if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
+ if ($domconfig{$action}{$itemid}{'display'}{$item} ne $confhash{$itemid}{'display'}{$item}) {
+ $changes{$itemid} = 1;
+ }
+ } else {
+ $changes{$itemid} = 1;
+ }
+ } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
+ if ($domconfig{$action}{$itemid}{'display'}{$item} ne '') {
+ $changes{$itemid} = 1;
+ }
}
}
if ($env{'form.ltitools_target_'.$i} eq 'window') {
@@ -9622,7 +9667,7 @@
}
}
my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
- foreach my $item ('label','title','target') {
+ foreach my $item ('label','title','target','linktext','explanation') {
if (grep(/^\Q$item\E$/, at courseconfig)) {
$confhash{$itemid}{'crsconf'}{$item} = 1;
if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') {
@@ -9798,13 +9843,13 @@
$resulttext .= ('*'x$num).'</li>';
}
$resulttext .= '<li>'.&mt('Configurable in course:');
- my @possconfig = ('label','title','target');
+ my @possconfig = ('label','title','target','linktext','explanation');
my $numconfig = 0;
if (ref($confhash{$itemid}{'crsconf'}) eq 'HASH') {
foreach my $item (@possconfig) {
if ($confhash{$itemid}{'crsconf'}{$item}) {
$numconfig ++;
- $resulttext .= ' '.$lt{'crs'.$item};
+ $resulttext .= ' "'.$lt{'crs'.$item}.'"';
}
}
}
@@ -9837,7 +9882,12 @@
$displaylist =~ s/,$//;
$resulttext .= '<li>'.$displaylist.'</li>';
}
- }
+ foreach my $item ('linktext','explanation') {
+ if ($confhash{$itemid}{'display'}{$item}) {
+ $resulttext .= '<li>'.$lt{$item}.': '.$confhash{$itemid}{'display'}{$item}.'</li>';
+ }
+ }
+ }
if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
my $fieldlist;
foreach my $field (@allfields) {
Index: loncom/interface/lonextresedit.pm
diff -u loncom/interface/lonextresedit.pm:1.15 loncom/interface/lonextresedit.pm:1.16
--- loncom/interface/lonextresedit.pm:1.15 Wed Mar 8 02:51:08 2017
+++ loncom/interface/lonextresedit.pm Tue Apr 25 22:18:59 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: lonextresedit.pm,v 1.15 2017/03/08 02:51:08 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.16 2017/04/25 22:18:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -260,14 +260,16 @@
my ($marker,$cdom,$cnum,$args) = @_;
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
my (%newhash,$changed, at deleted,$errormsg);
- ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args);
- $newhash{'crslabel'} = &unescape($newhash{'crslabel'});
- $newhash{'crstitle'} = &unescape($newhash{'crstitle'});
+ ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'linktext'},$newhash{'explanation'},
+ $newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args);
+ foreach my $item ('linktext','explanation','crslabel','crstitle') {
+ $newhash{$item} = &unescape($newhash{$item});
+ }
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- foreach my $item ('target','width','height','crslabel','crstitle') {
+ foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle') {
$newhash{$item} =~ s/^\s+//;
$newhash{$item} =~ s/\s+$//;
- if (($item eq 'width') || ($item eq 'height')) {
+ if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
if ($newhash{'target'} eq 'iframe') {
$newhash{$item} = '';
}
@@ -275,7 +277,7 @@
if ($toolhash{$item} ne $newhash{$item}) {
if ($newhash{$item} eq '') {
unless (($item eq 'target') ||
- ((($item eq 'width') || ($item eq 'height')) &&
+ ((($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) &&
(($newhash{'target'} eq 'window') ||
(($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) {
delete($toolhash{$item});
@@ -325,15 +327,21 @@
$tabid = 'ee';
}
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
- $labelstyle,$titlestyle,$legend,$urlelem,$toolelem,%toolattr);
+ $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
+ $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');
+ 'crstitlediv','crslabeldiv','crstitle','crslabel',
+ 'windiv','linktextdiv','explanationdiv','linktext',
+ 'explanation');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
+ $windivstyle = 'display:none';
+ $linktextstyle = 'display:none';
+ $explanationstyle = 'display:none';
$labelstyle = 'display:none';
$titlestyle = 'display:none';
if ($supplementalflag) {
@@ -344,14 +352,19 @@
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
- $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%chkstate);
+ $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
+ $linktext,$explanation,%chkstate);
$fieldsetstyle = 'display: none;';
$action = '/adm/coursedocs';
my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
+ my $rows = 2;
+ my $cols = 20;
if ($residx) {
if ($caller eq 'direct') {
$fieldsetstyle = 'display: block;';
$action = '/adm/extresedit';
+ $rows = 10;
+ $cols = 45;
if ($type eq 'tool') {
$legend = $lt{'ee'};
} else {
@@ -432,12 +445,15 @@
$tooltarget = $toolhash{'target'};
if ($tooltarget eq 'window') {
$dimendivstyle = 'display:block';
+ $windivstyle = 'display:block';
$chkstate{'window'} = 'checked="checked" ';
} else {
$chkstate{'iframe'} = 'checked="checked" ';
}
$width = $toolhash{'width'};
$height = $toolhash{'height'};
+ $linktext = $toolhash{'linktext'};
+ $explanation = $toolhash{'explanation'};
if (ref($ltitools->{$toolhash{'id'}}->{'crsconf'}) eq 'HASH') {
if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'title'}) {
$crstitle = $toolhash{'crstitle'};
@@ -450,6 +466,12 @@
if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'target'}) {
$dispdivstyle = 'display:block';
}
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'linktext'}) {
+ $linktextstyle = 'padding:0;display:inline';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'explanation'}) {
+ $explanationstyle = 'padding:0;display:inline';
+ }
}
$toolelem = '<span class="LC_nobreak">'.$image.' '.$tooltitle.'</span><br />';
}
@@ -487,21 +509,31 @@
$toolelem .= '<div id="'.$toolattr{'dispdiv'}.'" style="'.$dispdivstyle.'">'.
'<span class="'.$class.'">'.&mt('Display target:').' '.
'<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'.
- "'$toolattr{dimendiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}'".');"'.$disabled.'>'.&mt('iframe').'</label>'.(' 'x2).
+ "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
+ '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.(' 'x2).
'<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'.
- "'$toolattr{dimendiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}'".');"'.$disabled.'>'.&mt('window').'</label>'.
- '</span><div id="'.$toolattr{'dimendiv'}.'" style="'.$dimendivstyle.'">'.
- '<span class="'.$class.'">'.
- &mt('Width').'<input type="text" id="'.$toolattr{'dimenwidth'}.'" name="exttoolwidth" value="'.$width.'"'.$disabled.'>'.(' 'x2).
- &mt('Height').'<input type="text" id="'.$toolattr{'dimenheight'}.'" name="exttoolheight" value="'.$height.'"'.$disabled.'></span>'."\n".
- '</div></div>'.
- '<div id="'.$toolattr{'crslabeldiv'}.'" style="'.$labelstyle.'">'.
+ "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
+ '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'.
+ '<div id="'.$toolattr{'dimendiv'}.'" style="'.$dimendivstyle.'"><span class="'.$class.'">'.
+ &mt('Width').': <input type="text" size="4" id="'.$toolattr{'dimenwidth'}.'" name="exttoolwidth" value="'.$width.'"'.$disabled.' />'.(' 'x2).
+ &mt('Height').': <input type="text" size="4" id="'.$toolattr{'dimenheight'}.'" name="exttoolheight" value="'.$height.'"'.$disabled.' /></span>'."\n".
+ '</div></div>';
+ $toolelem .= '<div id="'.$toolattr{'windiv'}.'" style="'.$windivstyle.'">'.
+ '<div id="'.$toolattr{'linktextdiv'}.'" class="LC_left_float" style="'.$linktextstyle.'">'.
+ '<span class="'.$class.'">'.&mt('Link Text').'</span><br /><input type="text" size="25" id="'.$toolattr{'linktext'}.
+ '" name="exttoollinktext" value="'.$linktext.'"'.$disabled.' />'.
+ '</div><div id="'.$toolattr{'explanationdiv'}.'" class="LC_left_float" style="'.$explanationstyle.'">'.
+ '<span class="'.$class.'">'.&mt('Explanation').'</span><br />'.
+ '<textarea rows="'.$rows.'" cols="'.$cols.'" id="'.$toolattr{'explanation'}.'" name="exttoolexplanation" '.$disabled.'>'.
+ $explanation.'</textarea></div><div style="padding:0;clear:both;margin:0;border:0"></div>'.
+ '</div>';
+ $toolelem .= '<div id="'.$toolattr{'crslabeldiv'}.'" style="'.$labelstyle.'">'.
'<span class="'.$class.'">'.&mt('Course label:').' '.
- '<input type="text" id="'.$toolattr{'crslabel'}.'" name="exttoollabel" value="'.$crslabel.'"'.$disabled.'><br />'.
+ '<input type="text" id="'.$toolattr{'crslabel'}.'" name="exttoollabel" value="'.$crslabel.'"'.$disabled.' /></span><br />'.
'</div>'.
'<div id="'.$toolattr{'crstitlediv'}.'" style="'.$titlestyle.'">'.
'<span class="'.$class.'">'.&mt('Course title:').' '.
- '<input type="text" id="'.$toolattr{'crstitle'}.'" name="exttooltitle" value="'.$crstitle.'"'.$disabled.'><br />'.
+ '<input type="text" id="'.$toolattr{'crstitle'}.'" name="exttooltitle" value="'.$crstitle.'"'.$disabled.' /></span><br />'.
'</div>';
}
my $chooser = $toolelem;
@@ -587,23 +619,36 @@
" var ltitoolsTarget = new Array($num);\n".
" var ltitoolsWidth = new Array($num);\n".
" var ltitoolsHeight = new Array($num);\n".
+ " var ltitoolsLinkDef = new Array($num);\n".
+ " var ltitoolsExplainDef = new Array($num);\n".
" var ltitoolsDisplay = new Array($num);\n".
+ " var ltitoolsLink = new Array($num);\n".
+ " var ltitoolsExplain = new Array($num);\n".
" var ltitoolsLabel = new Array($num);\n".
" var ltitoolsTitle = new Array($num);\n";
my $i = 0;
foreach my $key (sort { $a <=> $b } keys(%{$toolsref})) {
- if (ref($toolsref->{$key})) {
- my $target = $toolsref->{$key}->{'target'};
- my $width = $toolsref->{$key}->{'width'};
- my $height = $toolsref->{$key}->{'height'};
- $toolsjs .= ' ltitools['.$i.'] = '."'$key';\n".
- ' ltitoolsTarget['.$i.'] = '."'$target';\n".
- ' ltitoolsWidth['.$i.'] = '."'$width';\n".
- ' ltitoolsHeight['.$i.'] = '."'$height';\n";
- my %courseconfig;
+ if (ref($toolsref->{$key}) eq 'HASH') {
+ if (ref($toolsref->{$key}->{'display'}) eq 'HASH') {
+ my $target = $toolsref->{$key}->{'display'}->{'target'};
+ my $width = $toolsref->{$key}->{'display'}->{'width'};
+ my $height = $toolsref->{$key}->{'display'}->{'height'};
+ my $linkdef = $toolsref->{$key}->{'display'}->{'linktext'};
+ my $explaindef = $toolsref->{$key}->{'display'}->{'explanation'};
+ $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";
+ }
if (ref($toolsref->{$key}->{'crsconf'}) eq 'HASH') {
my $display = $toolsref->{$key}->{'crsconf'}->{'target'};
$toolsjs .= ' ltitoolsDisplay['.$i.'] = '."'$display';\n";
+ my $linktext = $toolsref->{$key}->{'crsconf'}->{'linktext'};
+ $toolsjs .= ' ltitoolsLink['.$i.'] = '."'$linktext';\n";
+ my $explanation = $toolsref->{$key}->{'crsconf'}->{'explanation'};
+ $toolsjs .= ' ltitoolsExplain['.$i.'] = '."'$explanation';\n";
my $label = $toolsref->{$key}->{'crsconf'}->{'label'};
$toolsjs .= ' ltitoolsLabel['.$i.'] = '."'$label';\n";
my $title = $toolsref->{$key}->{'crsconf'}->{'title'};
@@ -668,8 +713,10 @@
prefix = 'supp';
}
var dispdiv = prefix+'tooldispdiv';
+ var windiv = prefix+'toolwindiv';
if (residx > 0) {
dispdiv += '_'+residx;
+ windiv += '_'+residx;
}
if (document.getElementById(dispdiv)) {
if (document.getElementById(dispdiv).style.display == 'block') {
@@ -681,7 +728,7 @@
width.trim();
var height = extform.exttoolheight.value;
height.trim();
- info += ':window:'+width+':'+height;
+ info += ':window:'+width+':'+height;
} else {
info += ':iframe::';
}
@@ -694,6 +741,34 @@
} else {
info += ':::';
}
+ if (document.getElementById(windiv)) {
+ if (document.getElementById(windiv).style.display == 'block') {
+ var linktextdiv = prefix+'toollinktextdiv';
+ var explanationdiv = prefix+'toolexplanationdiv';
+ if (residx > 0) {
+ linktextdiv += '_'+residx;
+ explanationdiv += '_'+residx;
+ }
+ if (document.getElementById(linktextdiv).style.display == 'inline') {
+ var linktext = extform.exttoollinktext.value;
+ linktext.trim();
+ info += ':'+escape(linktext);
+ } else {
+ info += ':';
+ }
+ if (document.getElementById(explanationdiv).style.display == 'inline') {
+ var explaintext = extform.exttoolexplanation.value;
+ explaintext.trim();
+ info += ':'+escape(explaintext);
+ } else {
+ info += ':';
+ }
+ } else {
+ info += '::';
+ }
+ } else {
+ info += '::';
+ }
var labelinput = prefix+'toolcrslabel';
var titleinput = prefix+'toolcrstitle';
if (residx > 0) {
@@ -760,12 +835,17 @@
}
dispdiv = prefix+'tooldispdiv';
dimendiv = prefix+'tooldimendiv';
- widthinput = prefix+'toolwidth';
- heightinput = prefix+'toolheight';
+ widthinput = prefix+'tooldimenwidth';
+ heightinput = prefix+'tooldimenheight';
labeldiv = prefix+'toolcrslabeldiv';
titlediv = prefix+'toolcrstitlediv';
labelinput = prefix+'toolcrslabel';
titleinput = prefix+'toolcrstitle';
+ windiv = prefix+'toolwindiv';
+ linktextdiv = prefix+'toollinktextdiv';
+ linktextinput = prefix+'toollinktext';
+ explanationdiv = prefix+'toolexplanationdiv';
+ explanationinput = prefix+'toolexplanation';
if (document.getElementById(dispdiv)) {
var toolpick = caller.options[caller.selectedIndex].value;
$toolsjs
@@ -776,6 +856,15 @@
if (document.getElementById(dimendiv)) {
document.getElementById(dimendiv).style.display = 'none';
}
+ if (document.getElementById(windiv)) {
+ document.getElementById(windiv).style.display = 'none';
+ }
+ if (document.getElementById(linktextdiv)) {
+ document.getElementById(linktextdiv).style.display = 'none';
+ }
+ if (document.getElementById(explanationdiv)) {
+ document.getElementById(explanationdiv).style.display = 'none';
+ }
if (document.getElementById(labeldiv)) {
document.getElementById(labeldiv).style.display = 'none';
}
@@ -797,23 +886,57 @@
}
}
}
- if (ltitoolsTarget[j] == 'window') {
- dimen = 'block';
- dimenwidth = ltitoolsWidth[j];
- dimenheight = ltitoolsHeight[j];
+ }
+ var dimen = 'none';
+ var dimenwidth = '';
+ var dimenheight = '';
+ if ((ltitoolsDisplay[j]) && (ltitoolsTarget[j] == 'window')) {
+ dimen = 'block';
+ dimenwidth = ltitoolsWidth[j];
+ dimenheight = ltitoolsHeight[j];
+ }
+ if (document.getElementById(dimendiv)) {
+ document.getElementById(dimendiv).style.display = dimen;
+ }
+ if (document.getElementById(widthinput)) {
+ document.getElementById(widthinput).value = dimenwidth;
+ }
+ if (document.getElementById(heightinput)) {
+ document.getElementById(heightinput).value = dimenheight;
+ }
+ }
+ if (document.getElementById(windiv)) {
+ if (ltitoolsTarget[j] == 'window') {
+ document.getElementById(windiv).style.display = 'block';
+ } else {
+ document.getElementById(windiv).style.display = 'none';
+ }
+ if (document.getElementById(linktextdiv)) {
+ if ((ltitoolsLink[j]) && (ltitoolsTarget[j] == 'window')) {
+ document.getElementById(linktextdiv).style.display = 'inline';
} else {
- dimen = 'none';
- dimenwidth = '';
- dimenheight = '';
+ document.getElementById(linktextdiv).style.display = 'none';
}
- if (document.getElementById(dimendiv)) {
- document.getElementById(dimendiv).style.display = dimen;
+ }
+ if (document.getElementById(linktextinput)) {
+ if ((ltitoolsLink[j]) && (ltitoolsTarget[j] == 'window')) {
+ document.getElementById(linktextinput).value = ltitoolsLinkDef[j];
+ } else {
+ document.getElementById(linktextinput).value = '';
}
- if (document.getElementById(widthinput)) {
- document.getElementById(widthinput).value = dimenwidth;
+ }
+ if (document.getElementById(explanationdiv)) {
+ if ((ltitoolsExplain[j]) && (ltitoolsTarget[j] == 'window')) {
+ document.getElementById(explanationdiv).style.display = 'inline';
+ } else {
+ document.getElementById(explanationdiv).style.display = 'none';
}
- if (document.getElementById(heightinput)) {
- document.getElementById(heightinput).value = dimenheight;
+ }
+ if (document.getElementById(explanationinput)) {
+ if ((ltitoolsExplain[j]) && (ltitoolsTarget[j] == 'window')) {
+ document.getElementById(explanationinput).value = ltitoolsExplainDef[j];
+ } else {
+ document.getElementById(explananationinput).value = '';
}
}
}
@@ -839,13 +962,15 @@
}
}
-function updateTooldim(form,dimendiv,widthinput,heightinput) {
+function updateTooldim(form,dimendiv,windiv,widthinput,heightinput,linkinput,explaininput) {
if (form.exttooltarget.length) {
for (var i=0; i<form.exttooltarget.length; i++) {
if (form.exttooltarget[i].checked) {
var dimen = 'none';
+ var linkconf = 'none';
if (form.exttooltarget[i].value == 'window') {
dimen = 'block';
+ linkconf = 'block';
} else {
if (document.getElementById(widthinput)) {
document.getElementById(widthinput).value = '';
@@ -853,10 +978,19 @@
if (document.getElementById(heightinput)) {
document.getElementById(heightinput).value = '';
}
+ if (document.getElementById(linkinput)) {
+ document.getElementById(linkinput).value = '';
+ }
+ if (document.getElementById(explaininput)) {
+ document.getElementById(explaininput).value = '';
+ }
}
if (document.getElementById(dimendiv)) {
document.getElementById(dimendiv).style.display = dimen;
}
+ if (document.getElementById(windiv)) {
+ document.getElementById(windiv).style.display = linkconf;
+ }
break;
}
}
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.623 loncom/interface/londocs.pm:1.624
--- loncom/interface/londocs.pm:1.623 Wed Mar 8 02:51:07 2017
+++ loncom/interface/londocs.pm Tue Apr 25 22:18:59 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.623 2017/03/08 02:51:07 raeburn Exp $
+# $Id: londocs.pm,v 1.624 2017/04/25 22:18:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -659,6 +659,7 @@
my $marker = $2;
my $info = $3;
my ($toolid,%toolhash,%toolsettings);
+ my @extras = ('linktext','explanation','crslabel','crstitle');
my @toolinfo = split(/:/,$info);
if ($residx) {
%toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
@@ -668,9 +669,11 @@
}
$toolid =~ s/\D//g;
($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
+ $toolhash{'linktext'},$toolhash{'explanation'},
$toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
- $toolhash{'crslabel'} = &unescape($toolhash{'crslabel'});
- $toolhash{'crstitle'} = &unescape($toolhash{'crstitle'});
+ foreach my $item (@extras) {
+ $toolhash{$item} = &unescape($toolhash{$item});
+ }
if (ref($ltitoolsref) eq 'HASH') {
my @deleted;
if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
@@ -683,13 +686,22 @@
foreach my $item ('width','height') {
$toolhash{$item} =~ s/^\s+//;
$toolhash{$item} =~ s/\s+$//;
+ if ($toolhash{$item} =~ /\D/) {
+ delete($toolhash{$item});
+ if ($residx) {
+ if ($toolsettings{$item}) {
+ push(@deleted,$item);
+ }
+ }
+ }
}
}
} elsif ($residx) {
$toolhash{'target'} = $toolsettings{'target'};
if ($toolhash{'target'} eq 'window') {
- $toolhash{'width'} = $toolsettings{'width'};
- $toolhash{'height'} = $toolsettings{'height'};
+ foreach my $item ('width','height') {
+ $toolhash{$item} = $toolsettings{$item};
+ }
}
} elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
$toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
@@ -699,31 +711,35 @@
}
}
if ($toolhash{'target'} eq 'iframe') {
- delete($toolhash{'width'});
- delete($toolhash{'height'});
- if ($residx) {
- if ($toolsettings{'width'}) {
- push(@deleted,'width');
- }
- if ($toolsettings{'height'}) {
- push(@deleted,'height');
+ foreach my $item ('width','height','linktext','explanation') {
+ delete($toolhash{$item});
+ if ($residx) {
+ if ($toolsettings{$item}) {
+ push(@deleted,$item);
+ }
}
}
}
if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
- foreach my $item ('label','title') {
+ foreach my $item ('label','title','linktext','explanation') {
+ my $crsitem;
+ if (($item eq 'label') || ($item eq 'title')) {
+ $crsitem = 'crs'.$item;
+ } else {
+ $crsitem = $item;
+ }
if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
- $toolhash{'crs'.$item} =~ s/^\s+//;
- $toolhash{'crs'.$item} =~ s/\s+$//;
- if ($toolhash{'crs'.$item} eq '') {
- delete($toolhash{'crs'.$item});
+ $toolhash{$crsitem} =~ s/^\s+//;
+ $toolhash{$crsitem} =~ s/\s+$//;
+ if ($toolhash{$crsitem} eq '') {
+ delete($toolhash{$crsitem});
}
} else {
- delete($toolhash{'crs'.$item});
+ delete($toolhash{$crsitem});
}
- if (($residx) && (exists($toolsettings{'crs'.$item}))) {
- unless (exists($toolhash{'crs'.$item})) {
- push(@deleted,'crs'.$item);
+ if (($residx) && (exists($toolsettings{$crsitem}))) {
+ unless (exists($toolhash{$crsitem})) {
+ push(@deleted,$crsitem);
}
}
}
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.59 rat/lonwrapper.pm:1.60
--- rat/lonwrapper.pm:1.59 Sat Apr 22 16:15:13 2017
+++ rat/lonwrapper.pm Tue Apr 25 22:19:03 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Wrapper for external and binary files as standalone resources
#
-# $Id: lonwrapper.pm,v 1.59 2017/04/22 16:15:13 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.60 2017/04/25 22:19:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,7 @@
# ================================================================ Main Handler
sub wrapper {
- my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$title) = @_;
+ my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title) = @_;
my $forcereg;
unless ($env{'form.folderpath'}) {
@@ -100,10 +100,16 @@
}
$output .= '<a href="'.$url.'">'.&mt('Link to PDF (for mobile devices)').'</a>';
} elsif ($exttool eq 'window') {
+ if ($linktext eq '') {
+ $linktext = &mt('Launch External Tool');
+ }
$output .= '<div>'.
'<a href="'.$url.'" target="LC_LTI" style="padding:0;clear:both;margin:0;border:0">'.
- &mt('Launch External Tool').'</a>'.
+ $linktext.'</a>'.
'</div>';
+ if ($explanation ne '') {
+ $output .= '<div>'.$explanation.'</div>';
+ }
} else {
$output .= '<div style="overflow:scroll; -webkit-overflow-scrolling:touch;">'."\n".
'<iframe src="'.$url.$anchor.'" height="100%" width="100%" frameborder="0">'."\n".
@@ -164,7 +170,8 @@
return OK if $r->header_only;
my $url = $r->uri;
- my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname);
+ my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,
+ $linktext,$explanation);
for ($url){
s|^/adm/wrapper||;
@@ -181,9 +188,12 @@
$cnum = $2;
my $marker = $3;
$exttool = 'iframe';
- my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target'],$cdom,$cnum);
+ my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation'],
+ $cdom,$cnum);
if ($toolhash{'target'} eq 'window') {
- $exttool = 'window';
+ $exttool = 'window';
+ $linktext = $toolhash{'linktext'};
+ $explanation = $toolhash{'explanation'};
}
}
if (($is_ext) || ($exttool)) {
@@ -258,7 +268,7 @@
&Apache::lonenc::check_encrypt(\$url);
}
- $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool) );
+ $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation) );
} # not just the menu
More information about the LON-CAPA-cvs
mailing list