--- loncom/interface/lonextresedit.pm 2025/06/14 20:48:54 1.8.2.4.4.5
+++ loncom/interface/lonextresedit.pm 2025/02/03 22:52:36 1.35
@@ -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.35 2025/02/03 22:52:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -284,10 +284,8 @@ sub process_changes {
if ($ferr) {
$errormsg = &mt('Reload failed: [_1].',$ferr);
} else {
- unless ($supplementalflag) {
- &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,
- $cdom.'_'.$cnum);
- }
+ &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,
+ $cdom.'_'.$cnum);
}
}
if (($type eq 'tool') && ($newgradable)) {
@@ -311,33 +309,12 @@ sub update_exttool {
my ($marker,$cdom,$cnum,$supplementalflag,$args) = @_;
my (%newhash,$changed,$newgradable,@deleted,$errormsg);
($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'linktext'},$newhash{'explanation'},
- $newhash{'crslabel'},$newhash{'crstitle'},$newhash{'crsappend'},$newhash{'gradable'},
- $newhash{'returnurl'},$newhash{'backtourl'},$newhash{'desturl'},$newhash{'delay'}) = split(/:/,$args);
- foreach my $item ('linktext','explanation','crslabel','crstitle','crsappend','backtourl','desturl','delay') {
+ $newhash{'crslabel'},$newhash{'crstitle'},$newhash{'crsappend'},$newhash{'gradable'}) = split(/:/,$args);
+ foreach my $item ('linktext','explanation','crslabel','crstitle','crsappend') {
$newhash{$item} = &unescape($newhash{$item});
}
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 '')) {
- my %tools;
- my %tooltypes = &Apache::loncommon::usable_exttools();
- if ($tooltypes{$tooltype}) {
- if ($tooltype eq 'dom') {
- %tools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
- } elsif ($tooltypes{'crs'}) {
- %tools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer');
- }
- $ltihash = $tools{$tool};
- }
- }
- foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle','crsappend','gradable','returnurl','backtourl','desturl','delay') {
+ foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle','crsappend','gradable') {
$newhash{$item} =~ s/^\s+//;
$newhash{$item} =~ s/\s+$//;
if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
@@ -352,26 +329,6 @@ sub update_exttool {
unless ($newhash{$item} == 1) {
$newhash{$item} = '';
}
- } elsif ($item eq 'backtourl') {
- unless ($newhash{'returnurl'} eq 'custom') {
- $newhash{$item} = '';
- }
- } elsif ($item eq 'desturl') {
- my $nocrsdest = 1;
- if ((ref($ltihash) eq 'HASH') && (ref($ltihash->{'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)) {
@@ -395,7 +352,7 @@ sub update_exttool {
}
} else {
$toolhash{$item} = $newhash{$item};
- $changed = 1;
+ $changed = 1;
}
}
}
@@ -438,20 +395,17 @@ sub extedit_form {
$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);
+ $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
+ $appendstyle,$gradablestyle,$subdivstyle,$legend,$urlelem,$toolelem,%toolattr);
$formname = 'new'.$type;
$toggle = $type;
- $fieldsetid = 'upload'.$type.'form';
+ $fieldsetid = 'external'.$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');
+ 'gradablediv','crstitle','crslabel','crsappend',
+ 'windiv','linktextdiv','explanationdiv',
+ 'linktext','explanation','providerurl');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
$windivstyle = 'display:none';
@@ -459,26 +413,19 @@ sub extedit_form {
$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;
- $fieldsetid = 'uploadsupp'.$type.'form';
+ $fieldsetid = 'externalsupp'.$type.'form';
$urlid = 'supp'.$type.'url';
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);
+ $linktext,$explanation,$providerurl,$chkgrd,$chknogrd,%chkstate);
$fieldsetstyle = 'display: none;';
$action = '/adm/coursedocs';
my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
@@ -510,7 +457,7 @@ sub extedit_form {
$active = '';
}
$formname = 'edit'.$type.'_'.$residx;
- $fieldsetid = 'upload'.$type.$residx;
+ $fieldsetid = 'external'.$type.$residx;
$urlid = $type.'url_'.$residx;
map { $toolattr{$_} .= '_'.$residx; } (keys(%toolattr));
$srcclass = ' class="LC_nobreak"';
@@ -525,7 +472,7 @@ sub extedit_form {
if ($type eq 'tool') {
$link = $lt{'et'};
}
- $link = ''.$link.''.$helpitem;
+ $link = ''.$link.''.$helpitem;
if ($type eq 'tool') {
$legend = $lt{'te'};
} else {
@@ -552,7 +499,6 @@ 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$}) {
@@ -562,13 +508,18 @@ sub extedit_form {
if ($toolhash{'id'} =~/^c(\d+)$/) {
$tool = $1;
$tooltype = 'crs';
+ if (ref($ltitools) eq 'HASH') {
+ if (ref($ltitools->{'crs'}) eq 'HASH') {
+ $ltihash = $ltitools->{'crs'}->{$tool};
+ }
+ }
} 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 (ref($ltitools) eq 'HASH') {
+ if (ref($ltitools->{'dom'}) eq 'HASH') {
+ $ltihash = $ltitools->{'dom'}->{$tool};
+ }
}
}
if (($tool ne '') && (ref($ltihash) eq 'HASH')) {
@@ -578,10 +529,10 @@ sub extedit_form {
if ($icon) {
$image = '';
}
- if ($ltihash->{'url'} =~ m{^https?\://}) {
- ($scheme,$provider,$path) = ($ltihash->{'url'} =~ m{^(https?\://)([^/]+)(|/.+)$});
+ if ($ltihash->{'url'} =~ m{://}) {
+ (my $prot,my $host,$providerurl) = ($ltihash->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
} else {
- $path = $ltihash->{'url'};
+ $providerurl = $ltihash->{'url'};
}
$tooltarget = $toolhash{'target'};
if ($tooltarget eq 'window') {
@@ -615,7 +566,6 @@ sub extedit_form {
if ($ltihash->{'crsconf'}->{'append'}) {
$crsappend = $toolhash{'crsappend'};
$appendstyle = 'display:inline';
- $showprovider = 1;
}
if ($ltihash->{'crsconf'}->{'target'}) {
$dispdivstyle = 'display:block';
@@ -626,52 +576,9 @@ sub extedit_form {
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"';
- }
- } 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 {
@@ -751,49 +658,9 @@ sub extedit_form {
$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.= '