--- loncom/interface/lonnavdisplay.pm 2024/07/02 02:17:56 1.22.4.11
+++ loncom/interface/lonnavdisplay.pm 2025/02/26 19:50:21 1.46
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Display Handler
#
-# $Id: lonnavdisplay.pm,v 1.22.4.11 2024/07/02 02:17:56 raeburn Exp $
+# $Id: lonnavdisplay.pm,v 1.46 2025/02/26 19:50:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,6 +39,7 @@ use Apache::lonnet;
use Apache::lonlocal;
use Apache::londocs();
use Apache::lonuserstate;
+use LONCAPA::ltiutils;
sub handler {
my $r = shift;
@@ -54,8 +55,8 @@ sub real_handler {
return OK;
}
- # Check for critical messages and redirect if present.
- my ($redirect,$url) = &Apache::loncommon::critical_redirect(300);
+ # Check for critical messages and redirect if present.
+ my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'contents');
if ($redirect) {
&Apache::loncommon::content_type($r,'text/html');
$r->header_out(Location => $url);
@@ -77,10 +78,14 @@ sub real_handler {
$r->send_http_header;
$r->print(&Apache::loncommon::check_release_result(@reinit));
return OK;
- } elsif ($result eq 'update') {
- my $cid = $env{'request.course.id'};
- my $cnum = $env{'course.'.$cid.'.num'};
- my $cdom = $env{'course.'.$cid.'.domain'};
+ }
+ my ($cid,$cnum,$cdom);
+ if ($result) {
+ $cid = $env{'request.course.id'};
+ $cnum = $env{'course.'.$cid.'.num'};
+ $cdom = $env{'course.'.$cid.'.domain'};
+ }
+ if (($result eq 'main') || ($result eq 'both')) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
&startpage($r);
@@ -110,12 +115,52 @@ ENDCLOSE
return HTTP_NOT_ACCEPTABLE;
}
}
+ if (($result eq 'both') || ($result eq 'supp')) {
+ my $possdel;
+ if ($result eq 'supp') {
+ $possdel = 1;
+ }
+ my ($supplemental,$refs_updated) = &Apache::loncommon::get_supplemental($cnum,$cdom,'',$possdel);
+ unless ($refs_updated) {
+ &Apache::loncommon::set_supp_httprefs($cnum,$cdom,$supplemental,$possdel);
+ }
+ }
+
+ my $course_type = &Apache::loncommon::course_type();
+ if (($course_type eq 'Placement') && (!$env{'request.role.adv'})) {
+ my $furl = &Apache::lonpageflip::first_accessible_resource();
+ if (($result eq 'main') || ($result eq 'both')) {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print($closure.&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ unless ($furl eq '/adm/navmaps') {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $furl);
+ return REDIRECT;
+ }
+ }
+ }
+
+ if ($env{'request.lti.login'}) {
+ if ($env{'request.lti.uri'} ne '') {
+ my $cid = $env{'request.course.id'};
+ my $cnum = $env{'course.'.$cid.'.num'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my ($scope,$url) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
+ if (($scope eq 'map') || ($scope eq 'resource')) {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $url);
+ return REDIRECT;
+ }
+ }
+ }
# Create the nav map
my $navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
- if ($result eq 'update') {
+ if (($result eq 'main') || ($result eq 'both')) {
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
$r->print($closure.&Apache::loncommon::end_page());
}
@@ -125,7 +170,7 @@ ENDCLOSE
return HTTP_NOT_ACCEPTABLE;
}
- if ($result eq 'update') {
+ if (($result eq 'main') || ($result eq 'both')) {
$r->rflush();
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
$r->print($closure);
@@ -137,8 +182,8 @@ ENDCLOSE
&startpage($r);
}
- &startContentScreen($r,'navmaps');
- unless ($result eq 'update') {
+ &startContentScreen($r,'navmaps',$course_type);
+ unless (($result eq 'main') || ($result eq 'both')) {
$r->rflush();
}
@@ -272,13 +317,14 @@ ENDCLOSE
'
');
}
@@ -336,28 +382,33 @@ sub startpage {
}
sub startContentScreen {
- my ($r,$mode)=@_;
+ my ($r,$mode,$course_type)=@_;
- $r->print("\n".''."\n");
+ $r->print("\n".''.
+ '
'."\n");
$r->print('- '.&mt('Main Content').'
'."\n");
- my $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
- my ($suppcount,$errors);
- unless ($allowed) {
+ my $supptab;
+ if ($env{'request.role.adv'}) {
+ $supptab = 1;
+ } else {
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- ($suppcount,$errors) = &Apache::lonnet::get_numsuppfiles($cnum,$cdom);
+ $supptab = &Apache::lonnet::has_unhidden_suppfiles($cnum,$cdom);
}
- if ($allowed || $suppcount) {
+ if ($supptab) {
$r->print('- '.&mt('Supplemental Content').'
');
}
- $r->print('- '.&mt('Content Search').'
'."\n");
+ unless ($course_type eq 'Placement') {
+ $r->print('- '.&mt('Content Search').'
'."\n");
+ $r->print('- '.&mt('Content Index').'
'."\n");
+ }
$r->print("\n".'
'."\n");
$r->print('
');
}
sub endContentScreen {
my ($r)=@_;
- $r->print('
');
+ $r->print('
');
}
1;