[LON-CAPA-cvs] cvs: rat / lonuserstate.pm loncom/auth lonroles.pm loncom/interface lonnavdisplay.pm lonnavmaps.pm
raeburn
raeburn at source.lon-capa.org
Mon May 26 15:55:11 EDT 2025
raeburn Mon May 26 19:55:11 2025 EDT
Modified files:
/loncom/interface lonnavmaps.pm lonnavdisplay.pm
/loncom/auth lonroles.pm
/rat lonuserstate.pm
Log:
- For courses composed exclusively of deep-link only resources, display
something besides: "This course is empty" to students who login to
LON-CAPA directly, select a student role, and list Course Contents.
-------------- next part --------------
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.573 loncom/interface/lonnavmaps.pm:1.574
--- loncom/interface/lonnavmaps.pm:1.573 Wed Apr 2 23:44:01 2025
+++ loncom/interface/lonnavmaps.pm Mon May 26 19:55:09 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.573 2025/04/02 23:44:01 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.574 2025/05/26 19:55:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1729,7 +1729,8 @@
$args->{'counter'} = 0; # counts the rows
$args->{'indentLevel'} = 0;
$args->{'isNewBranch'} = 0;
- $args->{'condensed'} = 0;
+ $args->{'condensed'} = 0;
+ $args->{'deeplinknolist'} = 0;
my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif");
$args->{'indentString'} = setDefault($args->{'indentString'}, "<img src='$location' alt='' />");
@@ -1904,6 +1905,9 @@
# If this has been filtered out, continue on
if (!(&$filterFunc($curRes))) {
+ if (!$userCanSeeHidden && !$curRes->randomout && $curRes->deeplinkout) {
+ $args->{'deeplinknolist'} ++;
+ }
$args->{'isNewBranch'} = 0; # Don't falsely remember this
next;
}
@@ -1928,6 +1932,7 @@
if ($userCanSeeHidden) {
$args->{'mapHiddenDeepLink'} = 1;
} else {
+ $args->{'deeplinknolist'} ++;
next;
}
} else {
@@ -1937,6 +1942,7 @@
if ($userCanSeeHidden) {
$args->{'mapUnlisted'} = 1;
} else {
+ $args->{'deeplinknolist'} ++;
next;
}
}
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.46 loncom/interface/lonnavdisplay.pm:1.47
--- loncom/interface/lonnavdisplay.pm:1.46 Wed Feb 26 19:50:21 2025
+++ loncom/interface/lonnavdisplay.pm Mon May 26 19:55:09 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Display Handler
#
-# $Id: lonnavdisplay.pm,v 1.46 2025/02/26 19:50:21 raeburn Exp $
+# $Id: lonnavdisplay.pm,v 1.47 2025/05/26 19:55:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,7 @@
use Apache::londocs();
use Apache::lonuserstate;
use LONCAPA::ltiutils;
+use LONCAPA;
sub handler {
my $r = shift;
@@ -348,11 +349,57 @@
# If no resources were printed, print a reassuring message so the
# user knows there was no error.
if ($renderArgs->{'counter'} == 0) {
+ my $noresmsg;
if ($showOnlyHomework) {
- $r->print("<p><span class=\"LC_info\">".&mt("All homework is currently completed.")."</span></p>");
+ $noresmsg = &mt('All homework is currently completed.');
} else { # both jumpToFirstHomework and normal use the same: course must be empty
- $r->print("<p><span class=\"LC_info\">".&mt("This course is empty.")."</span></p>");
+ $noresmsg = &mt('This course is empty.');
+ if (($renderArgs->{'deeplinknolist'}) &&
+ ($env{'request.course.deeponlyprot'})) {
+ my ($linkprot,$currmatch,$othermatches, at names);
+ if ($env{'request.linkprot'}) {
+ ($linkprot) = split(/:/,$env{'request.linkprot'});
+ }
+ foreach my $launcher (split(/&/,$env{'request.course.deeponlyprot'})) {
+ my ($name,$itemnums) = split(/:/,$launcher);
+ my @nums = split(/,/,$itemnums);
+ if (($linkprot) &&
+ (grep(/^\Q$linkprot\E$/, at nums))) {
+ $currmatch = &LONCAPA::unescape($name);
+ if (@nums > 1) {
+ $othermatches = 1;
+ }
+ } else {
+ push(@names,&LONCAPA::unescape($name));
+ }
+ }
+ if ($linkprot) {
+ if ($currmatch) {
+ $noresmsg = &mt('No main content available when accessed using the link you followed from [_1].',
+ $currmatch);
+ if ($othermatches) {
+ $noresmsg = '<br />'.
+ &mt('Main content may be available by following a different link from [_1].',
+ $currmatch);
+ }
+ } else {
+ $noresmsg = &mt('No main content available using the link you followed.');
+ }
+ } elsif (@names > 0) {
+ $noresmsg = &mt('No main content available from direct login to this course.');
+ }
+ if (@names == 1) {
+ $noresmsg .= '<br />'.
+ &mt('Main content is likely available by following links from [_1]',
+ $names[0]);
+ } elsif (@names > 1) {
+ $noresmsg .= '<br />'.
+ &mt('Main content is likely available by following links from the following: [_1]',
+ join(', ', at names));
+ }
+ }
}
+ $r->print('<p><span class="LC_info">'.$noresmsg.'</span></p>');
}
&endContentScreen($r);
$r->print(&Apache::loncommon::end_page());
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.376 loncom/auth/lonroles.pm:1.377
--- loncom/auth/lonroles.pm:1.376 Sun Feb 23 05:16:01 2025
+++ loncom/auth/lonroles.pm Mon May 26 19:55:10 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.376 2025/02/23 05:16:01 raeburn Exp $
+# $Id: lonroles.pm,v 1.377 2025/05/26 19:55:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -508,6 +508,7 @@
"request.course.tied" => '',
"request.course.timechecked" => '',
"request.course.suppupdated" => '',
+ "request.course.deeponlyprot" => '',
"request.role" => 'cm',
"request.role.adv" => $env{'user.adv'},
"request.role.domain" => $env{'user.domain'}});
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.170 rat/lonuserstate.pm:1.171
--- rat/lonuserstate.pm:1.170 Wed Oct 5 16:11:25 2022
+++ rat/lonuserstate.pm Mon May 26 19:55:11 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construct and maintain state and binary representation of course for user
#
-# $Id: lonuserstate.pm,v 1.170 2022/10/05 16:11:25 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.171 2025/05/26 19:55:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -63,6 +63,7 @@
my %encurl; # URLs in this folder are supposed to be encrypted
my %hiddenurl; # this URL (or complete folder) is supposed to be hidden
my %deeplinkout; # this URL (or complete folder) unavailable in deep-link session
+my %deeplinkonlyprot; # Link protection items used for deep-link only resources.
my %rescount; # count of unhidden items in each map
my %mapcount; # count of unhidden maps in each map
@@ -1186,8 +1187,14 @@
}
unless (@deeplink < 2) {
$hash{'deeplinkonly_'.$rid}=join(':',map { &escape($_); } @deeplink);
+ my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink[0]);
+ if (($state eq 'only') && ($protect ne 'none') && ($protect ne '')) {
+ my ($acctype,$item) = split(/:/,$protect);
+ if ($acctype =~ /lti(c|d)$/) {
+ $deeplinkonlyprot{$1}{$item} = 1;
+ }
+ }
}
-
if (defined($hash{'conditions_'.$rid})) {
$hash{'conditions_'.$rid}=simplify(
'('.$hash{'conditions_'.$rid}.')|('.$sofar.')');
@@ -1521,6 +1528,7 @@
undef %hiddenurl;
undef %encurl;
undef %deeplinkout;
+ undef %deeplinkonlyprot;
undef %rescount;
undef %mapcount;
$retfrid='';
@@ -1670,6 +1678,7 @@
undef %hiddenurl;
undef %encurl;
undef %deeplinkout;
+ undef %deeplinkonlyprot;
undef %rescount;
undef %mapcount;
$errtext='';
@@ -1794,6 +1803,42 @@
&accinit($uri,$short,$fn);
&hiddenurls();
}
+ my ($cdom,$cnum) = split(/_/,$short);
+ if (keys(%deeplinkonlyprot)) {
+ my %launchers;
+ if (ref($deeplinkonlyprot{'c'}) eq 'HASH') {
+ if (($cdom ne '') && ($cnum ne '')) {
+ my %crs_linkprot = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider');
+ foreach my $num (keys(%{$deeplinkonlyprot{'c'}})) {
+ if ((ref($crs_linkprot{$num}) eq 'HASH') &&
+ ($crs_linkprot{$num}{'name'} ne '')) {
+ push(@{$launchers{$crs_linkprot{$num}{'name'}}},'c'.$num);
+ }
+ }
+ }
+ }
+ if (ref($deeplinkonlyprot{'d'}) eq 'HASH') {
+ if ($cdom ne '') {
+ my %dom_linkprot = &Apache::lonnet::get_domain_lti($cdom,'linkprot');
+ foreach my $num (keys(%{$deeplinkonlyprot{'d'}})) {
+ if ((ref($dom_linkprot{$num}) eq 'HASH') &&
+ ($dom_linkprot{$num}{'name'} ne '')) {
+ push(@{$launchers{$dom_linkprot{$num}{'name'}}},'d'.$num);
+ }
+ }
+ }
+ }
+ if (keys(%launchers)) {
+ my $value = '';
+ foreach my $key (sort(keys(%launchers))) {
+ if (ref($launchers{$key}) eq 'ARRAY') {
+ $value .= &escape($key).':'.join(',',@{$launchers{$key}}).'&';
+ }
+ }
+ $value =~ s/&$//;
+ &Apache::lonnet::appenv({'request.course.deeponlyprot' => $value});
+ }
+ }
$errtext .= &get_mapalias_errors();
# ------------------------------------------------------- Put versions into src
foreach my $key (keys(%hash)) {
@@ -1834,7 +1879,6 @@
}
# Was initial access via a deep-link?
- my ($cdom,$cnum) = split(/_/,$short);
if (($cdom ne '') && ($env{'request.deeplink.login'} ne '')) {
my $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom);
if ($deeplink_symb) {
More information about the LON-CAPA-cvs
mailing list