[LON-CAPA-cvs] cvs: loncom /interface lonsearchcourse.pm

raeburn raeburn at source.lon-capa.org
Sun Feb 11 17:20:06 EST 2024


raeburn		Sun Feb 11 22:20:06 2024 EDT

  Modified files:              
    /loncom/interface	lonsearchcourse.pm 
  Log:
  - For session launched via LTI-mediated deep link, set appropriate target
    in links listed in search results.
  
  
Index: loncom/interface/lonsearchcourse.pm
diff -u loncom/interface/lonsearchcourse.pm:1.10 loncom/interface/lonsearchcourse.pm:1.11
--- loncom/interface/lonsearchcourse.pm:1.10	Sun Feb 11 21:41:48 2024
+++ loncom/interface/lonsearchcourse.pm	Sun Feb 11 22:20:06 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Course
 #
-# $Id: lonsearchcourse.pm,v 1.10 2024/02/11 21:41:48 raeburn Exp $
+# $Id: lonsearchcourse.pm,v 1.11 2024/02/11 22:20:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -123,6 +123,11 @@
     my $discuss=$env{'form.crsdiscuss'};
     my @allwords=($search_string, at New_Words);
     $totalfound=0;
+    my $target = 'cat';
+    if ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
+        (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) {
+        $target = '_self';
+    }
 
     $r->print(
               '<hr /><center><font size="+2" face="arial">'.
@@ -148,7 +153,7 @@
                 }
                 my $symb=&make_symb($1);
                 &checkonthis($r,$1,$hash{$_},0,&Apache::lonnet::gettitle($symb),
-                             $fulltext,$symb, at allwords);
+                             $fulltext,$symb,$target, at allwords);
             }
         }
         untie(%hash);
@@ -220,7 +225,7 @@
                     }
                     $url .= &escape($resource->symb());
                     my $title = $resource->compTitle();
-                    $r->print('<br /><a href="'.$url.'" target="cat">'.
+                    $r->print('<br /><a href="'.$url.'" target="'.$target.'">'.
                          ($title?$title:$url).'</a>  - '.
                          $disctype.'<br />');
                     $totaldiscussions++;
@@ -240,7 +245,7 @@
 # =============================== This pulls up a resource and its dependencies
 
 sub checkonthis {
-    my ($r,$id,$url,$level,$title,$fulltext,$symb, at allwords)=@_;
+    my ($r,$id,$url,$level,$title,$fulltext,$symb,$target, at allwords)=@_;
     $alreadyseen{$id}=1;
     if (&Apache::loncommon::connection_aborted($r)) { return; }
     $r->rflush();
@@ -281,7 +286,7 @@
                $href .= '?symb='.&escape($symb);
            }
        }
-       $r->print('<a href="'.$href.'" target="cat">'.($title?$title:$url).
+       $r->print('<a href="'.$href.'" target="'.$target.'">'.($title?$title:$url).
                  '</a><br />');
        $totalfound++;
     } elsif ($fulltext) {
@@ -293,7 +298,7 @@
                 &Apache::lonnet::metadata($url,'dependencies');
     foreach (split(/\,/,$dependencies)) {
        if (($_=~/^\/res\//) && (!$alreadyseen{$id})) {
-          &checkonthis($r,$id,$_,$level+1,'',$fulltext,undef, at allwords);
+          &checkonthis($r,$id,$_,$level+1,'',$fulltext,undef,$target, at allwords);
        }
     }
 }




More information about the LON-CAPA-cvs mailing list