--- loncom/interface/londocs.pm 2023/10/06 14:21:05 1.484.2.93.2.16 +++ loncom/interface/londocs.pm 2025/06/14 18:25:57 1.484.2.93.2.20 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.93.2.16 2023/10/06 14:21:05 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.93.2.20 2025/06/14 18:25:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -716,7 +716,7 @@ sub group_import { my $marker = $2; my $info = $3; my ($toolid,$toolprefix,$tooltype,%toolhash,%toolsettings); - my @extras = ('linktext','explanation','crslabel','crstitle','crsappend'); + my @extras = ('linktext','explanation','crslabel','crstitle','crsappend','returnurl','backtourl','desturl','delay'); my @toolinfo = split(/:/,$info); if ($residx) { %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); @@ -733,10 +733,17 @@ sub group_import { $toolid =~ s/\D//g; ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}, $toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'}, - $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo; + $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}, + $toolhash{'returnurl'},$toolhash{'backtourl'},$toolhash{'desturl'}, + $toolhash{'delay'}) = @toolinfo; foreach my $item (@extras) { $toolhash{$item} = &unescape($toolhash{$item}); } + foreach my $item ('crsappend','gradable','returnurl', + 'backtourl','desturl','delay') { + $toolhash{$item} =~ s/^\s+//; + $toolhash{$item} =~ s/\s+$//; + } if ($folder =~ /^supplemental/) { delete($toolhash{'gradable'}); } else { @@ -797,6 +804,7 @@ sub group_import { } } } + my $nocrsdest = 1; if (ref($tools{'crsconf'}) eq 'HASH') { foreach my $item ('label','title','linktext','explanation') { my $crsitem; @@ -820,6 +828,25 @@ sub group_import { } } } + if ($tools{'crsconf'}{'returnurl'}) { + unless ($toolhash{'returnurl'} eq 'custom') { + delete($toolhash{'backtourl'}); + } + } else { + delete($toolhash{'returnurl'}); + delete($toolhash{'backtourl'}); + } + if ($tools{'crsconf'}{'desturl'}) { + if ($toolhash{'desturl'} =~ m{^(https?\://|/)}) { + undef($nocrsdest); + } else { + delete($toolhash{'desturl'}); + delete($toolhash{'delay'}); + } + } else { + delete($toolhash{'desturl'}); + delete($toolhash{'delay'}); + } } if ($toolhash{'passback'}) { my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4); @@ -831,6 +858,17 @@ sub group_import { $toolhash{'rostersecret'} = $rostersecret; $toolhash{'rostersecretdate'} = time; } + if ($nocrsdest) { + foreach my $item ('desturl','delay') { + if (exists($toolhash{$item})) { + delete($toolhash{$item}); + } + } + } elsif (exists($toolhash{'delay'})) { + unless ($toolhash{'delay'} =~ /^(\d+\.?\d*)$/) { + delete($toolhash{'delay'}); + } + } my $changegradable; if (($residx) && ($folder =~ /^default/)) { if ($toolsettings{'gradable'}) { @@ -848,6 +886,20 @@ sub group_import { } } } + if ($residx) { + if (($toolsettings{'backtourl'} ne '') && (!exists($toolhash{'backtourl'}))) { + push(@deleted,'backtourl'); + } + if (($toolsettings{'returnurl'} ne '') && (!exists($toolhash{'returnurl'}))) { + push(@deleted,'returnurl'); + } + if (($toolsettings{'desturl'} ne '') && (!exists($toolhash{'desturl'}))) { + push(@deleted,'desturl'); + } + if (($toolsettings{'delay'} ne '') && (!exists($toolhash{'delay'}))) { + push(@deleted,'delay'); + } + } my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum); if ($putres eq 'ok') { if (@deleted) { @@ -4605,7 +4657,7 @@ END $nomodal = 1; } } - my ($checkencrypt,$shownurl); + my $checkencrypt; if (!$env{'request.role.adv'}) { if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) || ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) { @@ -4625,7 +4677,7 @@ END my $currenc = $env{'request.enc'}; $env{'request.enc'} = 1; $shownsymb = &Apache::lonenc::encrypted($symb); - $shownurl = &Apache::lonenc::encrypted($url); + my $shownurl = &Apache::lonenc::encrypted($url); if (&Apache::lonnet::symbverify($symb,$url)) { $url = $shownurl; } else { @@ -4640,7 +4692,8 @@ END $url = &Apache::lonnet::clutter($url); } } - $shownurl = $url; + } else { + $url = ''; } unless ($env{'request.role.adv'}) { if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) { @@ -4651,8 +4704,8 @@ END $hiddenres = 1; } } - if ($url ne '') { - $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb); + if (($url ne '') && ($shownsymb ne '')) { + $url .= (($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb); } } } elsif ($supplementalflag) { @@ -5333,7 +5386,7 @@ sub short_urls { } my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum); $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef, - undef,undef,undef,undef,undef,\%currtiny,$readonly)); + undef,undef,undef,undef,undef,\%currtiny,undef,$readonly)); } $r->print(&endContentScreen()); }