[LON-CAPA-cvs] cvs: doc /loncapafiles loncapafiles.lpml loncom/html/adm/help/tex Course_Prefs_Display.tex loncom/html/adm/lonIcons externallink.gif loncom/interface courseprefs.pm lonconfigsettings.pm rat lonwrapper.pm

raeburn raeburn at source.lon-capa.org
Sat Aug 27 22:41:31 EDT 2022


raeburn		Sun Aug 28 02:41:31 2022 EDT

  Added files:                 
    /loncom/html/adm/lonIcons	externallink.gif 

  Modified files:              
    /loncom/interface	courseprefs.pm lonconfigsettings.pm 
    /rat	lonwrapper.pm 
    /loncom/html/adm/help/tex	Course_Prefs_Display.tex 
    /doc/loncapafiles	loncapafiles.lpml 
  Log:
  - Bug 6972.
    Option in course to display every External Resource Item as link (and  
    launch in a tab or window) instead of in iframe.
  
  
-------------- next part --------------
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.113 loncom/interface/courseprefs.pm:1.114
--- loncom/interface/courseprefs.pm:1.113	Fri Jul  8 04:24:24 2022
+++ loncom/interface/courseprefs.pm	Sun Aug 28 02:41:29 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set configuration settings for a course
 #
-# $Id: courseprefs.pm,v 1.113 2022/07/08 04:24:24 raeburn Exp $
+# $Id: courseprefs.pm,v 1.114 2022/08/28 02:41:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -492,7 +492,8 @@
                      help => 'Course_Prefs_Display',
                      ordered => ['default_xml_style','pageseparators',
                                  'disable_receipt_display','texengine',
-                                 'tthoptions','uselcmath','usejsme','inline_chem'],
+                                 'tthoptions','uselcmath','usejsme',
+                                 'inline_chem','extresource'],
                       itemtext => {
                           default_xml_style       => 'Default XML style file',
                           pageseparators          => 'Visibly Separate Items on Pages',
@@ -502,6 +503,7 @@
                           uselcmath               => 'Student formula entry uses inline preview, not DragMath pop-up',
                           usejsme                 => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
                           inline_chem             => 'Chemical reaction response uses inline preview, not pop-up',
+                          extresource             => 'Display of external resources',   
                                   },
                   },
         'grading' =>
@@ -1464,10 +1466,36 @@
                                     $newvalues{$entry} = '';
                                 }
                             }
+                        } elsif ($entry eq 'extresource') {
+                            if ($env{'form.'.$entry} =~ /^iframe|tab|window$/) {
+                                $newvalues{$entry} = $env{'form.'.$entry};
+                                if ($env{'form.'.$entry} ne 'iframe') {
+                                    if ($env{'form.extwintabreuse'}) {
+                                        $newvalues{$entry} .= ':1';
+                                    } else {
+                                        $newvalues{$entry} .= ':0';
+                                    }
+                                    if ($env{'form.'.$entry} eq 'window') {
+                                        foreach my $dim ('width','height') {
+                                            $env{'form.extreswin'.$dim} =~ s/^\s+|\s+$//g;
+                                            if ($env{'form.extreswin'.$dim} =~ /^\d+$/) {
+                                                $newvalues{$entry} .= ':'.$env{'form.extreswin'.$dim};
+                                            } else {
+                                                $newvalues{$entry} .= ':';
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                            unless (($newvalues{$entry} eq 'iframe') && ($values->{$entry} eq '')) {
+                                if ($newvalues{$entry} ne $values->{$entry}) {
+                                    $changes->{$entry} = $newvalues{$entry};
+                                }
+                            }
                         } else {
                             $newvalues{$entry} = $env{'form.'.$entry};
                         }
-                        unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) {
+                        unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts') || ($entry eq 'extresource')) {
                             if ($newvalues{$entry} ne $values->{$entry}) {
                                 $changes->{$entry} = $newvalues{$entry};
                             }
@@ -1903,7 +1931,7 @@
                                     my ($displayname,$text);
                                     $text = $prefs->{$item}->{'itemtext'}{$key};
                                     my $displayval;
-                                    unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) {
+                                    unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts') || ($key eq 'extresource')) {
                                         $displayval = $changes->{$item}{$key};
                                     }
                                     if ($item eq 'feedback') {
@@ -2028,6 +2056,37 @@
                                         } elsif ($changes->{$item}{$key} eq '0') {
                                             $displayval = &mt('No');
                                         }
+                                    } elsif ($key eq 'extresource') {
+                                        if ($changes->{$item}{$key} eq 'iframe') {
+                                            $displayval = &mt('In iframe');
+                                        } else {
+                                            my ($selected,$reuse,$width,$height) = split(/:/,$changes->{$item}{$key});
+                                            if ($selected eq 'tab') {
+                                                if ($reuse) {
+                                                    $displayval = &mt('[_1]In tab[_2],[_3] and tab re-used for different external resources in course',
+                                                                      "'<b>","</b>'",'<br />');
+                                                } else {
+                                                    $displayval = &mt('[_1]In tab[_2],[_3] with new tab for each external resource in course',
+                                                                      "'<b>","</b>'",'<br />');
+                                                }
+                                            } elsif ($selected eq 'window') {
+                                                 if ($reuse) {
+                                                     $displayval = &mt('[_1]In pop-up window[_2],[_3] and window re-used for different external resources in course',
+                                                                       "'<b>","</b>'",'<br />');
+                                                 } else {
+                                                     $displayval = &mt('[_1]In pop-up window[_2],[_3] with new window for each external resource in course',
+                                                                       "'<b>","</b>'",'<br />');
+                                                 }
+                                                 if (($width ne '') || ($height ne '')) {
+                                                     if ($width ne '') {
+                                                         $displayval .= '<br />'.&mt('Window width: [_1]px',$width);
+                                                     }
+                                                     if ($height ne '') {
+                                                         $displayval .= '<br />'.&mt('Window height: [_1]px',$height);
+                                                     }
+                                                 }
+                                            }
+                                        }
                                     }
                                     if ($key eq 'co-owners') {
                                         if (ref($changes->{$item}{$key}) eq 'HASH') {
@@ -2099,9 +2158,11 @@
                                         $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'<br />'.
                                                    $displayval.'</li>';
                                     } else {
+                                        unless (($key eq 'extresource') && ($changes->{$item}{$key} ne 'iframe')) {
+                                            $displayval = "'<b>$displayval</b>'";
+                                        }
                                         $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
-                                                   '<i>'.$displayname.'</i>',
-                                                   "'<b>$displayval</b>'"));
+                                                   '<i>'.$displayname.'</i>',$displayval));
                                         if ($key eq 'url') {
                                             my $bkuptime=time;
                                             $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
@@ -2490,7 +2551,7 @@
 sub get_jscript {
     my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
     my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
-    my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
+    my ($jscript,$categorize_js,$loncaparev_js,$instcode_js,$extresource_js);
     my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
     my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
     my $cloners_js = &cloners_javascript($phase);
@@ -2697,11 +2758,38 @@
 }
 ENDSCRIPT
     }
+    $extresource_js = <<"ENDSCRIPT";
+function toggleExtRes() {
+    if (document.getElementById('LC_extresource')) {
+        var extressel = document.getElementById('LC_extresource').value;
+        if (document.getElementById('LC_extresreusediv')) {
+            var extresreuse = document.getElementById('LC_extresreusediv');
+            if (document.getElementById('LC_extressize')) {
+                var extressize = document.getElementById('LC_extressize');
+                var setvis;
+                if ((extressel == 'tab') || (extressel == 'window')) {
+                    extresreuse.style.display = 'inline-block';
+                    setvis = 1;
+                    if (extressel == 'window') {
+                        extressize.style.display = 'inline-block';
+                    } else {
+                        extressize.style.display = 'none';
+                    }
+                }
+                if (!setvis) {
+                    extresreuse.style.display = 'none';
+                    extressize.style.display = 'none';
+                }
+            }
+        }
+    }
+}
+ENDSCRIPT
     $jscript = '<script type="text/javascript" language="Javascript">'."\n".
                '// <![CDATA['."\n".  
                $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
                $cloners_js."\n".$instcode_js.
-               $syllabus_js."\n".$menuitems_js."\n".
+               $syllabus_js."\n".$menuitems_js."\n".$extresource_js."\n".
                &linkprot_javascript()."\n".'//]]>'."\n".
                '</script>'."\n".$stubrowse_js."\n";
     return $jscript;
@@ -5076,6 +5164,16 @@
                    text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
                    input => 'radio',
                  },
+         'extresource' => {
+                   text => '<b>'.&mt($itemtext->{'extresource'}).'</b>',
+                   input => 'selectbox',
+                   options => {
+                                iframe => 'In iframe',
+                                tab    => 'In new tab',
+                                window => 'In pop-up window',
+                              },
+                   order  => ['iframe','tab','window'],
+                 },
     );
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
 }
@@ -5992,6 +6090,45 @@
     return $output;
 }
 
+sub print_extresource_row {
+    my ($item,$config,$curr,$noedit) = @_;
+    my $onchange;
+    unless ($noedit) {
+        $onchange = ' onchange="javascript:toggleExtRes();"';
+    }
+    my $id = 'LC_'.$item;
+    my ($selected,$reuse,$width,$height) = split(/:/,$curr);
+    my $output = &select_from_options($item,$config->{'order'},
+                                      $config->{'options'},$selected,
+                                      $config->{'nullval'},
+                                      undef,undef,$onchange,$noedit,$id);
+    my ($checked,$reusesty,$sizesty); 
+    if ($reuse) {
+        $checked = ' checked="checked"';
+    }
+    $reusesty = 'none';
+    $sizesty = 'none';
+    if (($selected eq 'window') || ($selected eq 'tab')) {
+        $reusesty = 'inline-block';
+        if ($selected eq 'window') {
+            $sizesty = 'inline-block';
+        }
+    }
+    $output .= '<div id="LC_extresreusediv" style="display:'.$reusesty.';">'.
+               '<span class="LC_nobreak">'.
+               '<label><input type="checkbox" name="extwintabreuse" value="1"'.$checked.'>'.
+               &mt('Re-use tab/window').'</label>'.
+               '</span></div>'.
+               '<fieldset id="LC_extressize" style="display:'.$sizesty.';">'.
+               '<legend>'.&mt('Window size (optional)').'</legend>'.
+               '<span class="LC_nobreak">'.
+               &mt('width').':<input type="text" name="extreswinwidth" value="'.$width.'" size="3" />px'.
+               (' ' x 3).
+               &mt('height').':<input type="text" name="extreswinheight" value="'.$height.'" size="3" />px'.
+               '</span></fieldset>';
+    return $output;
+}
+
 sub print_other {
     my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
     unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
@@ -6163,10 +6300,16 @@
                 (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
                 $colspan = 2;
             }
+            my $rowdesc;
+            if ($caller eq 'appearance') {
+                $rowdesc = '<span class="LC_nobreak">'.$items->{$item}{text}.'</span>';
+            } else {
+                $rowdesc = $items->{$item}{text};
+            }
             if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
-                $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
+                $datatable .= &item_table_row_start($rowdesc,$count,"advanced",$colspan);
             } else {
-                $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
+                $datatable .= &item_table_row_start($rowdesc,$count,undef,$colspan);
             }
             if ($item eq 'defaultcredits') {
                 my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
@@ -6185,6 +6328,8 @@
                 $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
             } elsif ($item eq 'lti.lcmenu') {
                 $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit);
+            } elsif ($item eq 'extresource') {
+                $datatable .= &print_extresource_row($item,$items->{$item},$settings->{$item},$noedit);
             } elsif ($items->{$item}{input} eq 'dates') {
                my $disabled;
                if ($noedit) {
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.65 loncom/interface/lonconfigsettings.pm:1.66
--- loncom/interface/lonconfigsettings.pm:1.65	Fri Jul  1 01:05:04 2022
+++ loncom/interface/lonconfigsettings.pm	Sun Aug 28 02:41:29 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: lonconfigsettings.pm,v 1.65 2022/07/01 01:05:04 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.66 2022/08/28 02:41:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -439,6 +439,9 @@
                     }
                 }
             }
+            if (grep(/^appearance$/, at actions)) {
+                $onload .= "toggleExtRes();"
+            }
             if ($onload) {
                 my %loaditems = (
                                   'onload' => $onload,
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.77 rat/lonwrapper.pm:1.78
--- rat/lonwrapper.pm:1.77	Tue Oct 19 00:16:32 2021
+++ rat/lonwrapper.pm	Sun Aug 28 02:41:30 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.77 2021/10/19 00:16:32 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.78 2022/08/28 02:41:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,13 +39,15 @@
 use Apache::lonextresedit();
 use Apache::lonexttool();
 use Apache::lonhomework();
+use Apache::lonnavmaps();
 use LONCAPA qw(:DEFAULT :match);
 use HTML::Entities();
+use Digest::MD5();
 
 # ================================================================ Main Handler
 sub wrapper {
     my ($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,
-        $title,$width,$height) = @_;
+        $title,$width,$height,$reuse) = @_;
 
     my $forcereg;
     unless ($env{'form.folderpath'}) {
@@ -69,7 +71,10 @@
         } elsif ($env{'form.anchor'} ne '') {
             $anchor = '#'.$env{'form.anchor'};
         }
-        unless (($is_pdf) && ($clientmobile)) {
+        if (($is_ext eq 'tab') || ($is_ext eq 'window')) {
+            $uselink = 1;
+        }
+        unless (($is_pdf && $clientmobile) || $uselink) {
             my $hostname = $r->hostname();
             my $lonhost = $r->dir_config('lonHostID');
             my $ip = &Apache::lonnet::get_host_ip($lonhost);
@@ -168,22 +173,79 @@
             }
         }
     }
-    if ($clientmobile || ($exttool eq 'window') || ($exttool eq 'tab')) {
+    if ($clientmobile || ($exttool eq 'window') || ($exttool eq 'tab') ||
+        ($is_ext eq 'tab') || ($is_ext eq 'window')) {
         my $output = $startpage;
         if ($is_pdf) {
             $linktext = &mt('Link to PDF (for mobile devices)');
             $output .= &create_link($url,$anchor,$title,$linktext);
-        } elsif (($exttool eq 'window') || ($exttool eq 'tab')) {
+        } elsif (($exttool eq 'window') || ($exttool eq 'tab') ||
+                 ($is_ext eq 'tab') || ($is_ext eq 'window')) {
+            my $preamble;
             if ($linktext eq '') {
-                $linktext = &mt('Launch External Tool');
+                if ($exttool) {
+                    $linktext = &mt('Launch External Tool');
+                } else {
+                    $linktext = &mt('Link to External Resource');
+                }
+            }
+            if ($exttool) {
+                $url = &HTML::Entities::encode($url,'"<>&');
+            } else {
+                $url = &HTML::Entities::encode($url.$anchor,'&<>"');
             }
-            $url = &HTML::Entities::encode($url,'"<>&');
-            if ($exttool eq 'tab') {
-                $output .= '<div>'.
-                           '<a href="'.$url.'" target="LCExternalToolTab" style="padding:0;clear:both;margin:0;border:0">'.
+            if (($exttool eq 'tab') || ($is_ext eq 'tab')) {
+                my $target;
+                if ($exttool) {
+                    $target = 'LCExternalToolTab';
+                } else {
+                    if ($reuse) {
+                        $target = 'LCExternalResTab';
+                    } else {
+                        $target = '_blank';
+                    }
+                    if ($title ne '') {
+                        $preamble = '<span style="font-weight:bold;">'.$title.'</span><br />';
+                    }
+                }
+                $output .= '<div>'.$preamble.
+                           '<a href="'.$url.'" target="'.$target.'" style="padding:0;clear:both;margin:0;border:0">'.
                            $linktext.'</a>'.
                            '</div>';
             } else {
+                my ($target,$extlinkimg);
+                if ($exttool) {
+                    $target = 'LCExternalToolPopUp';
+                } else {
+                    $target = 'LCExternalResPopUp';
+                    if ($title ne '') {
+                        $preamble = '<span style="font-weight:bold;">'.$title.'</span><br />';
+                    }
+                    $extlinkimg = '<img src="'.&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/externallink.gif').'" width="19" height="18" border="0" />';
+                    unless ($reuse) {
+                        my $resid;
+                        if ($env{'request.course.id'}) {
+                            unless ($env{'form.folderpath'} =~ /^supplemental/) {
+                                my $symb=&Apache::lonnet::symbread($r->uri);
+                                if ($symb) {
+                                    my $navmap = Apache::lonnavmaps::navmap->new();
+                                    if (ref($navmap)) {
+                                        my $res = $navmap->getBySymb($symb);
+                                        if (ref($res)) {
+                                            $resid = $res->id;
+                                            $resid =~ s/\./_/g;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        if ($resid eq '') {
+                            $resid = substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 8);
+                        }
+                        &js_escape(\$resid);
+                        $target .= $resid;
+                    }
+                }
                 $output .= <<"ENDLINK";
 <script type="text/javascript">
 // <![CDATA[
@@ -192,10 +254,10 @@
 
 function openSinglePopup(strUrl) {
     if (windowObjectReference == null || windowObjectReference.closed) {
-        windowObjectReference = window.open(strUrl, "LCExternalToolPopUp",
+        windowObjectReference = window.open(strUrl, "$target",
                                             "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
     } else if(PreviousUrl != strUrl) {
-        windowObjectReference = window.open(strUrl, "LCExternalToolPopUp",
+        windowObjectReference = window.open(strUrl, "$target",
                                             "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
         windowObjectReference.focus();
     } else {
@@ -205,17 +267,19 @@
 }
 // ]]>
 </script>
-<div>
-<a href="$url" target="LCExternalToolPopUp" onclick="openSinglePopup(this.href); return false;">
-$linktext</a>
+<div>$preamble
+<a href="$url" target="$target" onclick="openSinglePopup(this.href); return false;">
+$linktext$extlinkimg</a>
 </div>
 ENDLINK
             }
-            if ($explanation ne '') {
-                $output .= '<div>'.$explanation.'</div>';
-            }
-            if (&Apache::lonnet::EXT('resource.0.gradable')) {
-                $output .= &Apache::lonfeedback::list_discussion('tool','OPEN');
+            if ($exttool) {
+                if ($explanation ne '') {
+                    $output .= '<div>'.$explanation.'</div>';
+                }
+                if (&Apache::lonnet::EXT('resource.0.gradable')) {
+                    $output .= &Apache::lonfeedback::list_discussion('tool','OPEN');
+                }
             }
         } else {
             if ($uselink) {
@@ -320,7 +384,7 @@
 
     my $url = $r->uri;
     my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,
-        $linktext,$explanation,$width,$height);
+        $linktext,$explanation,$width,$height,$reuse);
 
     for ($url){
         s|^/adm/wrapper||;
@@ -331,6 +395,27 @@
 
     if ($url =~ /\.pdf$/i) {
         $is_pdf = 1;
+    } elsif (($is_ext) && ($env{'request.course.id'})) {
+        if ($env{'course.'.$env{'request.course.id'}.'.extresource'}) {
+            (my $selected,$reuse,$width,$height) = split(/:/,$env{'course.'.$env{'request.course.id'}.'.extresource'});
+            if ($selected eq 'tab') {
+                $is_ext = 'tab';
+                $width = '';
+                $height = '';
+            } elsif ($selected eq 'window') {
+                $is_ext = 'window';
+                unless ($width =~ /^\d+$/) {
+                    $width = '';
+                }
+                unless ($height =~ /^\d+$/) {
+                    $height = '';
+                } 
+            } else {
+                $width = '';
+                $height = '';
+                $reuse = '';
+            }
+        }
     } elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
         $cdom = $1;
         $cnum = $2;
@@ -432,7 +517,7 @@
         }
 
         $r->print( wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,
-                           $linktext,$explanation,undef,$width,$height) );
+                           $linktext,$explanation,undef,$width,$height,$reuse) );
 
     } # not just the menu
     
@@ -459,7 +544,7 @@
 
 =over
 
-=item wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height)
+=item wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height,$reuse)
 
 =over
 
@@ -502,7 +587,11 @@
 
 =item $is_ext
 
-true if URL is for an external resource.
+true if URL is for an external resource. Default true value
+is 1 (display in iframe, unless $uselink is true). 
+If external resource is to be displayed in a tab,
+value of $is_ext will be tab, if to be displayed in a pop-up window,
+value of $is_ext will be window.  
 
 =item $is_pdf
 
@@ -537,14 +626,24 @@
 optional. If URL is for an External Tool, and target type is window,
 then a default width may have been defined in the domain for all instances of 
 the tool.  If so, that width will be used for the window opened (via a link)
-to launch the external tool.
+to launch the external tool. If the URL is for an External Resource, and 
+$is_ext is window, then a default width (px) may have been defined in the current
+course for all external resource instances.
 
 =item $height
 
 optional. If URL is for an External Tool, and target type is window,
 then a default height may have been defined in the domain for all instances of 
 the tool.  If so, that height will be used for the window opened (via a link)
-to launch the external tool.
+to launch the external tool.  If the URL is for an External Resource, and 
+$is_ext is window, then a default height (px) may have been defined in the current
+course for all external resource instances.
+
+=item $reuse
+
+optional. If the URL is for an External Resource, and $is_ext is tab or window,
+then $reuse will be true if the same tab or window is to be reused for display
+of all external resource instances in a a course.
 
 =back
 
Index: loncom/html/adm/help/tex/Course_Prefs_Display.tex
diff -u loncom/html/adm/help/tex/Course_Prefs_Display.tex:1.9 loncom/html/adm/help/tex/Course_Prefs_Display.tex:1.10
--- loncom/html/adm/help/tex/Course_Prefs_Display.tex:1.9	Fri Dec 24 14:19:38 2021
+++ loncom/html/adm/help/tex/Course_Prefs_Display.tex	Sun Aug 28 02:41:30 2022
@@ -11,6 +11,8 @@
         \item Student formula entry uses inline preview, not DragMath pop-up
         \item Molecule editor uses JSME (HTML5) in place of JME (Java)
         \item Chemical reaction response uses inline preview, not pop-up
+        \item Display of external resources
+\end{itemize}
 
 Style files (.sty extension) created in Authoring Space and published to the shared content pool
 can be selected for use when rendering resources in the course by clicking the 
@@ -38,6 +40,11 @@
 
 Similarly, the the molecular editor display will use the domain setting, unless overridden within a specific course.  If nothing is explicitly set in the domain or the course, then the default is to use JSME instead of its JME predecessor.
 
+The Course Editor can be used to add the URL for an external resource to be displayed within a LON-CAPA course. By default, the remote content will be displayed in an iframe with standard LON-CAPA menu links/icons present in the page header above the resource. LON-CAPA attempts to gracefully handle mixed active content issues for external resources by injecting usehttp=1 into the query string for the LON-CAPA URL, in order to force serving of an http:// external URL in an http:// LON-CAPA page, where the LON-CAPA server uses https:// by default for all other pages.  A separate session cookie which confers reduced rights is used when usehttp=1 is present in the query string because LON-CAPA's standard session cookie includes the 'secure' attribute.
 
-\end{itemize}
+LON-CAPA also attempts to circumvent the lack of scrolling for multi-page PDFs in iframes on iOS by replacing inline display in an iframe with a link when viewing on a mobile device.  Another instance where LON-CAPA replaces display of an external resource in an iframe with a link to display the resource in a separate browser tab is when Content-Security-Policy or X-Frame-Options prevent display in an iframe.
+
+The automatic display adjustments described above occur on a case-by-case basis depending on the external resource itself.
+
+The ``Display of external resources'' item can be used to force display of all external resources in a course in either a separate browser tab, or in a new browser window. In the latter case an optional width and height (in pixels) can be specified.  When tab or window are selected, there is also an option to re-use the same (named) tab or window when displaying different external resources in a course in order to limit the number of tabs or windows which may be created by browsing in a single course.
 
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.1031 doc/loncapafiles/loncapafiles.lpml:1.1032
--- doc/loncapafiles/loncapafiles.lpml:1.1031	Thu Jun 30 21:04:15 2022
+++ doc/loncapafiles/loncapafiles.lpml	Sun Aug 28 02:41:31 2022
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.1031 2022/06/30 21:04:15 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.1032 2022/08/28 02:41:31 raeburn Exp $ -->
 
 <!--
 
@@ -7499,6 +7499,7 @@
 eps_big.gif;
 exam.gif;
 exam_big.gif;
+externallink.gif;
 face-angel.png;
 face-angry.png;
 face-cool.png;


More information about the LON-CAPA-cvs mailing list