--- rat/lonwrapper.pm 2017/05/08 14:20:32 1.62 +++ rat/lonwrapper.pm 2017/12/18 23:23:14 1.66 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Wrapper for external and binary files as standalone resources # -# $Id: lonwrapper.pm,v 1.62 2017/05/08 14:20:32 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.66 2017/12/18 23:23:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,11 +38,13 @@ use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonextresedit(); use Apache::lonexttool(); -use LONCAPA qw(:DEFAULT :match);; +use LONCAPA qw(:DEFAULT :match); +use HTML::Entities(); # ================================================================ Main Handler sub wrapper { - my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title) = @_; + my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation, + $title,$width,$height) = @_; my $forcereg; unless ($env{'form.folderpath'}) { @@ -82,8 +84,24 @@ sub wrapper { my $startpage = &Apache::loncommon::start_page('Menu',undef,$args); my $endpage = &Apache::loncommon::end_page(); - - if (($env{'browser.mobile'}) || ($exttool eq 'window')) { + + if (($exttool) && (&Apache::lonnet::EXT('resource.0.gradable'))) { + my $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'}); + if ($resource_due) { + my $time_left = $resource_due - time(); + if ($resource_due && ($time_left > 0)) { + $startpage .=' +'."\n". + &Apache::lonhtmlcommon::set_due_date($resource_due); + } + } + } + + if (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab')) { my $output = $startpage; if ($is_pdf) { if ($title eq '') { @@ -99,20 +117,54 @@ sub wrapper { $output .= $title.'
'; } $output .= ''.&mt('Link to PDF (for mobile devices)').''; - } elsif ($exttool eq 'window') { + } elsif (($exttool eq 'window') || ($exttool eq 'tab')) { if ($linktext eq '') { $linktext = &mt('Launch External Tool'); } - $output .= '
'. - ''. - $linktext.''. - '
'; + $url = &HTML::Entities::encode($url,'"<>&'); + if ($exttool eq 'tab') { + $output .= '
'. + ''. + $linktext.''. + '
'; + } else { + $output .= <<"ENDLINK"; + +
+ +$linktext +
+ENDLINK + } if ($explanation ne '') { $output .= '
'.$explanation.'
'; } + if (&Apache::lonnet::EXT('resource.0.gradable')) { + $output .= &Apache::lonfeedback::list_discussion('tool','OPEN'); + } } else { + my $dest = &HTML::Entities::encode($url.$anchor,'&<>"'); $output .= '
'."\n". - '\n". "
\n"; @@ -151,11 +203,12 @@ sub wrapper { window.onload = function(){ \$(window).trigger('resize') }; SCRIPT # javascript will position the iframe if window was resized (or zoomed) + my $dest = &HTML::Entities::encode($url.$anchor,'&<>"'); return < - + $endpage ENDFRAME @@ -171,7 +224,7 @@ sub handler { my $url = $r->uri; my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname, - $linktext,$explanation); + $linktext,$explanation,$width,$height); for ($url){ s|^/adm/wrapper||; @@ -189,20 +242,26 @@ sub handler { my $marker = $3; $exttool = 'iframe'; my $exttoolremote; - my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id'], + my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'], $cdom,$cnum); if ($toolhash{'id'}) { - my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom); + my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); if (ref($ltitools{$toolhash{'id'}}) eq 'HASH') { $exttoolremote = $ltitools{$toolhash{'id'}}{'url'}; } } if ($toolhash{'target'} eq 'window') { - $exttool = 'window'; + $exttool = 'window'; + $width = $toolhash{'width'}; + $height = $toolhash{'height'}; + } elsif ($toolhash{'target'} eq 'tab') { + $exttool = 'tab'; + } + if (($exttool eq 'window') || ($exttool eq 'tab')) { $linktext = $toolhash{'linktext'}; $explanation = $toolhash{'explanation'}; } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) { - $exttool = 'window'; + $exttool = 'tab'; } } if (($is_ext) || ($exttool)) { @@ -277,7 +336,8 @@ sub handler { &Apache::lonenc::check_encrypt(\$url); } - $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation) ); + $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool, + $linktext,$explanation,undef,$width,$height) ); } # not just the menu @@ -304,7 +364,7 @@ described at http://www.lon-capa.org. =over -=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$title)) +=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$linktext,$explanation,$title,$width,$height) =over