[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm /interface lonhtmlcommon.pm lonnavmaps.pm slotrequest.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Wed Apr 2 19:44:03 EDT 2025
raeburn Wed Apr 2 23:44:03 2025 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm slotrequest.pm lonnavmaps.pm
/loncom/homework bridgetask.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Reservation setting screens support URLs with encrypturl set to yes.
Note: Checking "URL hidden" for a folder in Course Editor will override
any encrypturl settings set using the Parameter Manager.
-------------- next part --------------
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.358.2.19.2.7 loncom/interface/lonhtmlcommon.pm:1.358.2.19.2.8
--- loncom/interface/lonhtmlcommon.pm:1.358.2.19.2.7 Fri Feb 3 04:29:22 2023
+++ loncom/interface/lonhtmlcommon.pm Mon Sep 11 12:10:39 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.358.2.19.2.7 2023/02/03 04:29:22 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.358.2.19.2.8 2023/09/11 12:10:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1762,6 +1762,48 @@
END
}
+##
+# Client-side javascript to convert any dashes in text pasted
+# into textbox(es) for numericalresponse item(s) to a standard
+# minus, i.e., - . Calls to dash_to_minus_js() in end_problem()
+# and in loncommon::endbodytag() for a .page (arg: dashjs => 1)
+#
+# Will apply to any input tag with class: LC_numresponse_text.
+# Currently set in start_textline for numericalresponse items.
+#
+
+sub dash_to_minus_js {
+ return <<'ENDJS';
+
+<script type="text/javascript">
+//<![CDATA[
+//<!-- BEGIN LON-CAPA Internal
+document.addEventListener("DOMContentLoaded", (event) => {
+ const numresp = document.querySelectorAll("input.LC_numresponse_text");
+ if (numresp.length > 0) {
+ numresp.forEach((el) => {
+ el.addEventListener("paste", (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let p = (e.clipboardData || window.clipboardData).getData("text");
+ p.toString();
+ p = p.replace(/\p{Dash}/gu, '-');
+ putInText(p);
+ });
+ });
+ }
+ const putInText = (newText, el = document.activeElement) => {
+ const [start, end] = [el.selectionStart, el.selectionEnd];
+ el.setRangeText(newText, start, end, 'end');
+ }
+});
+// END LON-CAPA Internal -->
+//]]>
+</script>
+
+ENDJS
+}
+
############################################################
############################################################
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.151 loncom/interface/slotrequest.pm:1.152
--- loncom/interface/slotrequest.pm:1.151 Mon Mar 31 13:55:06 2025
+++ loncom/interface/slotrequest.pm Wed Apr 2 23:44:01 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for requesting to have slots added to a students record
#
-# $Id: slotrequest.pm,v 1.151 2025/03/31 13:55:06 raeburn Exp $
+# $Id: slotrequest.pm,v 1.152 2025/04/02 23:44:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -83,6 +83,9 @@
($env{'form.command'} eq 'remove_registration')))) {
if ($env{'form.symb'}) {
my $symb=&unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($symb);
if ($resurl =~ /ext\.tool$/) {
my $target;
@@ -714,7 +717,11 @@
my $name = &Apache::loncommon::plainname($env{'form.uname'},
$env{'form.udom'});
- my $title = &Apache::lonnet::gettitle($env{'form.symb'});
+ my $symb = &unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
+ my $title = &Apache::lonnet::gettitle($symb);
my $msg = &mt('Remove [_1] from slot [_2] for [_3]',
$name,$slot_name,$title);
@@ -796,6 +803,9 @@
if ($mgr eq 'F'
&& defined($env{'form.symb'})) {
$symb = &unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
}
my ($result,$msg) =
@@ -1548,6 +1558,15 @@
'<th>'.&mt('Action').'</th><th>'.&mt('Name').'</th>'.
&Apache::loncommon::end_data_table_header_row();
}
+ my $shownsymb;
+ if ($env{'request.role.adv'}) {
+ $shownsymb = $symb;
+ } elsif (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i) {
+ $shownsymb = &Apache::lonenc::encrypted($symb);
+ } else {
+ $shownsymb = $symb;
+ }
+ $shownsymb = &escape($shownsymb);
foreach my $slot (@{$available}) {
my $description=&get_description($slot,$slots->{$slot});
my $form;
@@ -1572,7 +1591,6 @@
}
}
}
- my $escsymb=&escape($symb);
if (!$form) {
my $name;
if ($formname) {
@@ -1585,7 +1603,7 @@
$form=<<STUFF;
<form method="post" action="/adm/slotrequest" $name>
<input type="submit" name="Select" value="$text" />
- <input type="hidden" name="symb" value="$escsymb" />
+ <input type="hidden" name="symb" value="$shownsymb" />
<input type="hidden" name="slotname" value="$slot" />
<input type="hidden" name="command" value="$command" />
<input type="hidden" name="context" value="$context" />
@@ -1698,11 +1716,20 @@
undef($udom);
}
+ my $shownsymb;
+ if ($env{'request.role.adv'}) {
+ $shownsymb = $symb;
+ } elsif (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i) {
+ $shownsymb = &Apache::lonenc::encrypted($symb);
+ } else {
+ $shownsymb = $symb;
+ }
+
$slotname = &escape($slotname);
$entry = &escape($entry);
$uname = &escape($uname);
$udom = &escape($udom);
- $symb = &escape($symb);
+ $symb = &escape($shownsymb);
return <<"END_LINK";
<a href="/adm/slotrequest?command=remove_registration&slotname=$slotname&entry=$entry&uname=$uname&udom=$udom&symb=$symb&context=manage"
@@ -2378,6 +2405,14 @@
$currcontainer = $parent{$depth};
} elsif (ref($resource)) {
my $symb = $resource->symb();
+ my $src = $resource->src();
+ my ($shownsymb,$shownsrc);
+ $shownsymb = $resource->shown_symb();
+ if ($resource->encrypted()) {
+ $shownsrc = &Apache::lonenc::encrypted($src);
+ } else {
+ $shownsrc = $src;
+ }
next if (!$resource->is_problem() && !$resource->is_tool() &&
!$resource->is_sequence() && !$resource->is_page());
$count ++;
@@ -2409,7 +2444,7 @@
for (my $i=0; $i<$depth; $i++) {
$r->print('<img src="'.$location.'" alt="" />');
}
- $r->print('<a href="'.$resource->src().'?symb='.$symb.'">'.
+ $r->print('<a href="'.$shownsrc.'?symb='.$shownsymb.'">'.
'<img class="LC_contentImage" src="/adm/lonIcons/');
if ($resource->is_task()) {
$r->print('task.gif" alt="'.&mt('Task'));
@@ -3558,6 +3593,9 @@
}
if ($env{'form.requestattempt'}) {
$symb=&unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
if ($symb) {
$brcrum = &get_user_breadcrumbs($symb);
}
@@ -3587,16 +3625,22 @@
push(@{$brcrum},{href=>"/adm/slotrequest?command=$env{'form.command'}",text=>$crumb_titles{$env{'form.command'}}});
}
} elsif ($env{'form.context'} eq 'user') {
- if ($env{'form.symb'}) {
- $symb=&unescape($env{'form.symb'});
- $brcrum = &get_user_breadcrumbs($symb);
- } else {
- $brcrum =[];
- }
+ if ($env{'form.symb'}) {
+ $symb = &unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
+ $brcrum = &get_user_breadcrumbs($symb);
+ } else {
+ $brcrum =[];
+ }
}
} elsif (($env{'form.command'} eq 'get') && ($env{'form.context'} eq 'user')) {
if ($env{'form.symb'}) {
$symb=&unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
$brcrum = &get_user_breadcrumbs($symb);
} else {
$brcrum =[];
@@ -3654,6 +3698,9 @@
&show_reservations_log($r);
} else {
$symb = &unescape($env{'form.symb'});
+ if ($symb =~ m{^/enc/}) {
+ $symb = &Apache::lonenc::unencrypted($symb);
+ }
if (!defined($symb)) {
&fail($r,'not_valid');
return OK;
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.572 loncom/interface/lonnavmaps.pm:1.573
--- loncom/interface/lonnavmaps.pm:1.572 Wed Feb 26 19:50:21 2025
+++ loncom/interface/lonnavmaps.pm Wed Apr 2 23:44:01 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.572 2025/02/26 19:50:21 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.573 2025/04/02 23:44:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3067,7 +3067,7 @@
}
sub recurseup_maps {
- my ($self,$mapname,$getsymb) = @_;
+ my ($self,$mapname,$getsymb,$inclusive) = @_;
my @recurseup;
if ($mapname) {
my $res = $self->getResourceByUrl($mapname);
@@ -3081,6 +3081,13 @@
@recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->src()); } reverse(@pcs);
}
}
+ if ($inclusive) {
+ if ($getsymb) {
+ unshift(@recurseup,$res->symb());
+ } else {
+ unshift(@recurseup,$mapname);
+ }
+ }
}
}
return @recurseup;
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.274 loncom/homework/bridgetask.pm:1.275
--- loncom/homework/bridgetask.pm:1.274 Mon Mar 31 13:55:08 2025
+++ loncom/homework/bridgetask.pm Wed Apr 2 23:44:02 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.274 2025/03/31 13:55:08 raeburn Exp $
+# $Id: bridgetask.pm,v 1.275 2025/04/02 23:44:02 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -412,11 +412,16 @@
.'</p>';
}
- if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); }
- $symb=&escape($symb);
+ my $shownsymb;
+ if ($env{'request.enc'}) {
+ $shownsymb = &Apache::lonenc::encrypted($symb);
+ } else {
+ $shownsymb = $symb;
+ }
+ $shownsymb=&escape($shownsymb);
$result.=
"\n\t".'<form method="post" action="/adm/slotrequest">'."\n\t\t".
- '<input type="hidden" name="symb" value="'.$symb.'" />'."\n\t\t".
+ '<input type="hidden" name="symb" value="'.$shownsymb.'" />'."\n\t\t".
'<input type="hidden" name="command" value="'.$action.'" />'."\n\t\t".
'<input type="submit" name="requestattempt" value="'.
$text.'" />'."\n\t".
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1537 loncom/lonnet/perl/lonnet.pm:1.1538
--- loncom/lonnet/perl/lonnet.pm:1.1537 Wed Mar 19 14:44:04 2025
+++ loncom/lonnet/perl/lonnet.pm Wed Apr 2 23:44:03 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1537 2025/03/19 14:44:04 raeburn Exp $
+# $Id: lonnet.pm,v 1.1538 2025/04/02 23:44:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -13216,6 +13216,15 @@
# When this was last done
my $cachedmaptime='';
+# Cache (5 seconds) of mapsymb hierarchy for speedup of reservations display
+#
+# The course for which we cache
+my $cachedmapsymbkey='';
+# The cached recursive map symbs for this course
+my %cachedmapsymbs=();
+# When this was last done
+my $cachedmapsymbtime='';
+
sub clear_EXT_cache_status {
&delenv('cache.EXT.');
}
@@ -13407,6 +13416,43 @@
#print '<br>'.$space.' - '.$qualifier.' - '.$spacequalifierrest;
+# --------------------------------------------- Special handling for encrypturl
+
+ if ($spacequalifierrest eq '0.encrypturl') {
+ unless ($recursed) {
+ my ($map_from_symb, at mapsymbs);
+ if ($symbparm =~ /\.(page|sequence)$/) {
+ push(@mapsymbs,$symbparm);
+ $map_from_symb = &deversion((&decode_symb($symbparm))[2]);
+ } else {
+ $map_from_symb = &deversion((&decode_symb($symbparm))[0]);
+ }
+ if (($map_from_symb ne '') && ($map_from_symb !~ /default\.sequence$/)) {
+ my @parents = &get_mapsymb_hierarchy($map_from_symb,$courseid);
+ if (@parents) {
+ push(@mapsymbs, at parents);
+ }
+ }
+ if (@mapsymbs) {
+ my $earlyout;
+ my %parmhash=();
+ if (tie(%parmhash,'GDBM_File',
+ $env{'request.course.fn'}.'_parms.db',
+ &GDBM_READER(),0640)) {
+ foreach my $mapsymb (@mapsymbs) {
+ if ((exists($parmhash{$mapsymb.'.'.$spacequalifierrest})) &&
+ (lc($parmhash{$mapsymb.'.'.$spacequalifierrest}) eq 'yes')) {
+ $earlyout = $parmhash{$mapsymb.'.'.$spacequalifierrest};
+ last;
+ }
+ }
+ untie(%parmhash);
+ }
+ if ($earlyout) { return &get_reply([$earlyout,'map']); }
+ }
+ }
+ }
+
# ----------------------------------------------------- Cascading lookup scheme
my $symbp=$symbparm;
$mapp=&deversion((&decode_symb($symbp))[0]);
@@ -13610,6 +13656,30 @@
return @recurseup;
}
+sub get_mapsymb_hierarchy {
+ my ($mapname,$courseid) = @_;
+ my @recurseup;
+ if ($mapname) {
+ if (($cachedmapsymbkey eq $courseid) &&
+ (abs($cachedmapsymbtime-time)<5)) {
+ if (ref($cachedmapsymbs{$mapname}) eq 'ARRAY') {
+ return @{$cachedmapsymbs{$mapname}};
+ }
+ }
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ my $getsymb = 1;
+ my $inclusive = 1;
+ @recurseup = $navmap->recurseup_maps($mapname,$getsymb,$inclusive);
+ undef($navmap);
+ $cachedmapsymbs{$mapname} = \@recurseup;
+ $cachedmapsymbtime=time;
+ $cachedmapsymbkey=$courseid;
+ }
+ }
+ return @recurseup;
+}
+
}
sub sort_course_groups { # Sort groups based on defined rankings. Default is sort().
More information about the LON-CAPA-cvs
mailing list