--- loncom/interface/lonextresedit.pm 2025/06/14 20:48:54 1.8.2.4.4.5 +++ loncom/interface/lonextresedit.pm 2025/03/15 01:03:33 1.36 @@ -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.36 2025/03/15 01:03:33 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)) { @@ -312,32 +310,12 @@ sub update_exttool { 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{'returnurl'},$newhash{'backtourl'}) = split(/:/,$args); + foreach my $item ('linktext','explanation','crslabel','crstitle','crsappend','backtourl') { $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','returnurl','backtourl') { $newhash{$item} =~ s/^\s+//; $newhash{$item} =~ s/\s+$//; if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) { @@ -356,22 +334,6 @@ sub update_exttool { 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)) { @@ -438,20 +400,18 @@ 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,$returnurlstyle,$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'); + 'linktext','explanation','providerurl','customreturnurl'); $dispdivstyle = 'display:none'; $dimendivstyle = 'display:none'; $windivstyle = 'display:none'; @@ -459,26 +419,21 @@ 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,$returnurl,$chkgrd,$chknogrd,%chkstate, + $chknoreturn,$chkreturndef,$chkreturncust,$customreturn,$backtourl); $fieldsetstyle = 'display: none;'; $action = '/adm/coursedocs'; my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http'); @@ -510,7 +465,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 +480,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 +507,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 +516,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 +537,10 @@ sub extedit_form { if ($icon) { $image = ''.$tooltitle.''; } - 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 +574,6 @@ sub extedit_form { if ($ltihash->{'crsconf'}->{'append'}) { $crsappend = $toolhash{'crsappend'}; $appendstyle = 'display:inline'; - $showprovider = 1; } if ($ltihash->{'crsconf'}->{'target'}) { $dispdivstyle = 'display:block'; @@ -629,7 +587,7 @@ sub extedit_form { if ($ltihash->{'crsconf'}->{'returnurl'}) { $returnurl = $toolhash{'returnurl'}; $returnurlstyle = 'display:inline'; - $backtourl = $toolhash{'backtourl'}; + $backtourl = $toolhash{'backtourl'}; if ($returnurl eq 'none') { $chknoreturn = ' checked="checked"'; $customreturn = 'hidden'; @@ -641,37 +599,9 @@ sub extedit_form { $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 { @@ -758,42 +688,9 @@ sub extedit_form { $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.= '
'. - ''.&mt('Provider').': '.$scheme.$provider.'
'. - ''.&mt('Provider path').': '.$path.''."\n". - '
'."\n". - '
'. - '
'. - ''.&mt('Append to LTI login URL').':
'. - ''. - '
'."\n". - '
'. - '
'. - ''.&mt('Post-login destination different from path').': '. - ''.(' 'x2). - ''.(' 'x2). - '
'."\n". - '
'. - ''. - '
'. - '
'."\n". - '
'. - ''.&mt('Destination after provider login').': '. - '
'.$fixeddest.'
'. - '
'. - &mt('Post-login delay before redirect to destination').': '.$fixeddelay.' s'."\n". - '
'. - '
'. - '
'. + $toolelem .= '
'. ''.&mt('Display target:').' '. '
'. - '
'. - '
'. - ''.&mt('Link Text').'
'. - '
'. - ''.&mt('Explanation').'
'. - '
'. - '
'. - '
'. + '
'; + $toolelem .= '
'. + '
'. + ''.&mt('Link Text').'
'. + '
'. + ''.&mt('Explanation').'
'. + '
'. + '
'; + $toolelem .= '
'. ''.&mt('Course label:').' '. '
'. '
'."\n". @@ -825,6 +722,11 @@ sub extedit_form { ''.&mt('Course title:').' '. '
'. ''."\n". + '
'. + ''.&mt('Append to URL[_1]', + ' ('.$providerurl.')
'). + '

'. + '
'."\n". '
'. ''.&mt('Gradable').' '. '