--- loncom/interface/lonextresedit.pm 2025/06/14 20:48:54 1.8.2.4.4.5
+++ loncom/interface/lonextresedit.pm 2017/03/08 02:51:08 1.15
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: lonextresedit.pm,v 1.8.2.4.4.5 2025/06/14 20:48:54 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.15 2017/03/08 02:51:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@ sub handler {
$symb,$type);
if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {
$supplementalflag = 1;
- if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
+ if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) {
$type = 'tool';
}
}
@@ -79,7 +79,7 @@ sub handler {
if ($symb ne $env{'form.symb'}) {
$env{'form.symb'} = $symb;
}
- if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) {
+ if ($url =~ m{/adm/$cdom/$cnum/\d+/exttools?$}) {
$type = 'tool';
}
}
@@ -98,18 +98,7 @@ sub handler {
}
my %ltitools;
if ($type eq 'tool') {
- my (%domtools,%crstools);
- my %tooltypes = &Apache::loncommon::usable_exttools();
- if ($tooltypes{'dom'}) {
- %domtools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
- }
- if ($tooltypes{'crs'}) {
- %crstools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer');
- }
- %ltitools = (
- dom => \%domtools,
- crs => \%crstools,
- );
+ %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
}
my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
my $pathitem = '{'crsconf'}) eq 'HASH') &&
- ($ltihash->{'crsconf'}->{'desturl'})) {
- undef($nocrsdest);
- }
- if ($nocrsdest) {
- $newhash{$item} = '';
- }
- } elsif ($item eq 'delay') {
- if ($newhash{'desturl'} eq '') {
- $newhash{$item} = '';
- }
- unless ($newhash{$item} =~ /^(\d+\.?\d*)$/) {
- $newhash{$item} = '';
}
}
if ($toolhash{$item} ne $newhash{$item}) {
- if (($item eq 'gradable') && (!$supplementalflag)) {
- if ($newhash{$item}) {
- $newgradable = 'yes';
- } else {
- $newgradable = 'no';
- }
- }
if ($newhash{$item} eq '') {
unless (($item eq 'target') ||
((($item eq 'width') || ($item eq 'height')) &&
(($newhash{'target'} eq 'window') ||
- (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window')))) ||
- ((($item eq 'linktext') || ($item eq 'explanation')) &&
- ((($newhash{'target'} =~ /^(window|tab)$/)) ||
- (($newhash{'target'} eq '') && ($toolhash{'target'} =~ /^(window|tab)$/))))) {
+ (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) {
delete($toolhash{$item});
push(@deleted,$item);
$changed = 1;
}
} else {
$toolhash{$item} = $newhash{$item};
- $changed = 1;
+ $changed = 1;
}
}
}
@@ -408,7 +297,7 @@ sub update_exttool {
if (@deleted) {
&Apache::lonnet::del('exttool_'.$marker,\@deleted,$cdom,$cnum);
}
- return ($changed,$newgradable,$errormsg);
+ return ($changed,$errormsg);
}
sub extedit_form {
@@ -429,44 +318,24 @@ sub extedit_form {
ti => 'Title',
al => 'Add Link',
at => 'Add Tool',
- dd => 'Defined in domain',
- dc => 'Defined in course',
);
my $tabid = 'aa';
my $size = 60;
if ($supplementalflag) {
$tabid = 'ee';
}
- my ($formname,$formid,$toggle,$fieldsetid,$urlid,$subdivid,$dispdivstyle,$dimendivstyle,
- $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,$providerstyle,
- $appendstyle,$gradablestyle,$returnurlstyle,$subdivstyle,$desturlstyle,
- $desturlinfostyle,$desturlfixedstyle,$legend,$urlelem,$toolelem,%toolattr);
+ my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
+ $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','crsappenddiv',
- 'gradablediv','returnurldiv','crstitle','crslabel',
- 'crsappend','windiv','linktextdiv','explanationdiv',
- 'linktext','explanation','provider','providerpath','customreturnurl',
- 'desturl','delay','providerdiv','desturldiv','desturlinfodiv',
- 'desturlfixeddiv','fixeddest','fixeddelay');
+ 'crstitlediv','crslabeldiv','crstitle','crslabel');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
- $windivstyle = 'display:none';
- $linktextstyle = 'display:none';
- $explanationstyle = 'display:none';
$labelstyle = 'display:none';
$titlestyle = 'display:none';
- $providerstyle = 'display:none';
- $appendstyle = 'display:none';
- $gradablestyle = 'display:none';
- $returnurlstyle = 'display:none';
- $desturlstyle = 'display:none';
- $desturlinfostyle = 'display:none';
- $desturlfixedstyle = 'display:none';
- $subdivstyle = 'display:block';
if ($supplementalflag) {
$formname = 'newsupp'.$type;
$toggle = 'supp'.$type;
@@ -475,25 +344,18 @@ sub extedit_form {
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
- $crsappend,$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
- $linktext,$explanation,$path,$returnurl,$chkgrd,$chknogrd,%chkstate,
- $chknoreturn,$chkreturndef,$chkreturncust,$customreturn,$backtourl,$desturl,$delay,
- $chknodest,$chkdest);
+ $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%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{'te'};
- } else {
$legend = $lt{'ee'};
+ } else {
+ $legend = $lt{'te'};
}
$legend = '';
if ($symb) {
@@ -543,7 +405,7 @@ sub extedit_form {
} else {
$orig_title = $lt{'et'};
$save = $lt{'at'};
- $orig_url = "/adm/$cdom/$cnum/new/ext\.tool";
+ $orig_url = "/adm/$cdom/$cnum/new/exttool";
}
$pathitem .= '
';
}
@@ -552,295 +414,95 @@ sub extedit_form {
$urlelem = '';
} else {
my $class = 'LC_nobreak';
- my ($nocrsdest,$fixeddest,$fixeddelay,$showprovider,$provider,$scheme);
if ($residx) {
$class = 'LC_docs_ext_edit LC_nobreak';
- if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
+ if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/exttools?$}) {
my $marker = $1;
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- my ($tooltype,$tool,$ltihash);
- if ($toolhash{'id'} =~/^c(\d+)$/) {
- $tool = $1;
- $tooltype = 'crs';
- } elsif ($toolhash{'id'} =~/^\d+$/) {
- $tooltype = 'dom';
- $tool = $toolhash{'id'};
- }
- if (($tool ne '') && ($tooltype ne '') && (ref($ltitools) eq 'HASH')) {
- if (ref($ltitools->{$tooltype}) eq 'HASH') {
- $ltihash = $ltitools->{$tooltype}->{$tool};
- }
- }
- if (($tool ne '') && (ref($ltihash) eq 'HASH')) {
- my $tooltitle = $ltihash->{'title'};
- my $icon = $ltihash->{'image'};
- my $image;
- if ($icon) {
- $image = '';
- }
- if ($ltihash->{'url'} =~ m{^https?\://}) {
- ($scheme,$provider,$path) = ($ltihash->{'url'} =~ m{^(https?\://)([^/]+)(|/.+)$});
- } else {
- $path = $ltihash->{'url'};
- }
- $tooltarget = $toolhash{'target'};
- if ($tooltarget eq 'window') {
- $dimendivstyle = 'display:block';
- $windivstyle = 'display:block';
- $chkstate{'window'} = 'checked="checked" ';
- } elsif ($tooltarget eq 'tab') {
- $windivstyle = 'display:block';
- $chkstate{'tab'} = 'checked="checked" ';
- } else {
- $chkstate{'iframe'} = 'checked="checked" ';
- }
- $width = $toolhash{'width'};
- $height = $toolhash{'height'};
- $linktext = $toolhash{'linktext'};
- $explanation = $toolhash{'explanation'};
- if ($toolhash{'gradable'}) {
- $chkgrd = ' checked="checked"';
- } else {
- $chknogrd = ' checked="checked"';
- }
- if (ref($ltihash->{'crsconf'}) eq 'HASH') {
- if ($ltihash->{'crsconf'}->{'title'}) {
- $crstitle = $toolhash{'crstitle'};
- $titlestyle = 'display:inline';
- }
- if ($ltihash->{'crsconf'}->{'label'}) {
- $crslabel = $toolhash{'crslabel'};
- $labelstyle = 'display:inline';
- }
- if ($ltihash->{'crsconf'}->{'append'}) {
- $crsappend = $toolhash{'crsappend'};
- $appendstyle = 'display:inline';
- $showprovider = 1;
- }
- if ($ltihash->{'crsconf'}->{'target'}) {
- $dispdivstyle = 'display:block';
- }
- if ($ltihash->{'crsconf'}->{'linktext'}) {
- $linktextstyle = 'padding:0;display:inline';
- }
- if ($ltihash->{'crsconf'}->{'explanation'}) {
- $explanationstyle = 'padding:0;display:inline';
- }
- if ($ltihash->{'crsconf'}->{'returnurl'}) {
- $returnurl = $toolhash{'returnurl'};
- $returnurlstyle = 'display:inline';
- $backtourl = $toolhash{'backtourl'};
- if ($returnurl eq 'none') {
- $chknoreturn = ' checked="checked"';
- $customreturn = 'hidden';
- } elsif (($returnurl eq 'custom') && ($backtourl ne '')) {
- $chkreturncust = ' checked="checked"';
- $customreturn = 'text';
- } else {
- $chkreturndef = ' checked="checked"';
- $customreturn = 'hidden';
- }
- }
- if ($ltihash->{'crsconf'}->{'desturl'}) {
- $desturl = $toolhash{'desturl'};
- $desturlstyle = 'display:inline';
- $delay = $toolhash{'delay'};
- $showprovider = 1;
- if ($desturl ne '') {
- $desturlinfostyle = 'display:inline';
- $chkdest = ' checked="checked"';
- $chknodest = '';
- } else {
- $desturlinfostyle = 'display:none';
- $chkdest = '';
- $chknodest = ' checked="checked"';
+ if ($toolhash{'id'}) {
+ if (ref($ltitools) eq 'HASH') {
+ if (keys(%{$ltitools})) {
+ if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') {
+ my $tooltitle = $ltitools->{$toolhash{'id'}}->{'title'};
+ my $icon = $ltitools->{$toolhash{'id'}}->{'image'};
+ my $image;
+ if ($icon) {
+ $image = '
';
+ }
+ $tooltarget = $toolhash{'target'};
+ if ($tooltarget eq 'window') {
+ $dimendivstyle = 'display:block';
+ $chkstate{'window'} = 'checked="checked" ';
+ } else {
+ $chkstate{'iframe'} = 'checked="checked" ';
+ }
+ $width = $toolhash{'width'};
+ $height = $toolhash{'height'};
+ if (ref($ltitools->{$toolhash{'id'}}->{'crsconf'}) eq 'HASH') {
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'title'}) {
+ $crstitle = $toolhash{'crstitle'};
+ $titlestyle = 'display:inline';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'label'}) {
+ $crslabel = $toolhash{'crslabel'};
+ $labelstyle = 'display:inline';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'target'}) {
+ $dispdivstyle = 'display:block';
+ }
+ }
+ $toolelem = ''.$image.' '.$tooltitle.'
';
}
- } else {
- $nocrsdest = 1;
}
}
- $toolelem = ''.$image.' '.$tooltitle.'
';
- $gradablestyle = 'display:inline';
- if (($ltihash->{'desturl'}) && ($nocrsdest) && ($ltihash->{'defdest'} =~ m{^(https?\://|/)})) {
- $fixeddest = $ltihash->{'defdest'};
- if ($ltihash->{'defdelay'} =~ /^\d+\.?\d*$/) {
- $fixeddelay = $ltihash->{'defdelay'};
- }
- $desturlfixedstyle = 'display:inline-block';
- $showprovider = 1;
- }
- if (($showprovider) && ($provider ne '')) {
- $providerstyle = 'display:inline-block';
- }
}
}
} else {
- $subdivstyle = 'display:none';
- my $toolradio = 'exttooltype';
- my $exttypeon = 'LC_exttoolon';
- my $exttypeoff = 'LC_exttooloff';
- my $exttypeonsty = 'display:none';
- my $exttypeoffsty = 'display:none';
- my $exttypeofftext;
- if ($supplementalflag) {
- $toolradio = 'suppexttooltype';
- $exttypeon = 'LC_exttoolonsupp';
- $exttypeoff = 'LC_exttooloffsupp';
- }
- my ($numcrstools,$numdomtools,$typeclick,%defcheck,%typedesc);
- %typedesc = (
- crs => 'Defined in course',
- dom => 'Defined in domain',
- );
-#FIXME need crstype
- my $seloptions;
- $subdivid = 'LC_addtool';
- if ($supplementalflag) {
- $subdivid = 'LC_addtoolsupp';
- }
+ $toolelem = ''."\n".
+ '
';
$crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
$crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
- $crsappend = '';
- $returnurl = '';
- $backtourl = '';
- $customreturn = 'hidden';
- $chknogrd = ' checked="checked"';
- $chknoreturn = '';
- $chkreturndef = ' checked="checked"';
- $chkreturncust = '';
- $chknodest = ' checked="checked"';
- $chkdest = '';
- }
- my $onclickreturl = ' onclick="updateReturnUrl('."this.form,'$toolattr{'customreturnurl'}','$toolattr{'returnurldiv'}','exttoolreturnurl'".');"';
- my $onclickdest = ' onclick="updateDestUrl('."this.form,'$toolattr{'desturlinfodiv'}','$toolattr{'desturldiv'}','exttooldest'".');"';
- $toolelem.= '