--- rat/lonwrapper.pm 2020/10/26 00:02:48 1.49.2.7.2.5 +++ rat/lonwrapper.pm 2020/01/14 14:26:39 1.70 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Wrapper for external and binary files as standalone resources # -# $Id: lonwrapper.pm,v 1.49.2.7.2.5 2020/10/26 00:02:48 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.70 2020/01/14 14:26:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,6 +38,7 @@ use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonextresedit(); use Apache::lonexttool(); +use Apache::lonhomework(); use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); @@ -50,7 +51,6 @@ sub wrapper { unless ($env{'form.folderpath'}) { $forcereg = 1; } - my %lt = &Apache::lonlocal::texthash( 'noif' => 'No iframe support.', 'show' => 'Show content in pop-up window', @@ -89,26 +89,53 @@ sub wrapper { $args->{'only_body'} = $env{'form.only_body'}; } - my $headjs; - -# -# Where iframe is in use, if window.onload() executes before the custom resize function -# has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef) -# are used to ensure document.ready() triggers a call to resize, so the iframe contents -# do not obscure the Functions menu. -# - - unless (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab') || $uselink) { - $headjs = ' + my ($countdown,$donemsg); + if (($exttool) && (&Apache::lonnet::EXT('resource.0.gradable') =~ /^yes$/i)) { + $Apache::lonhomework::browse = &Apache::lonnet::allowed('bre',$url); + if ($env{'form.markaccess'}) { + my $symb=&Apache::lonnet::symbread($url); + my @interval=&Apache::lonnet::EXT('resource.0.interval',$symb); + my ($timelimit) = split(/_/,$interval[0]); + my $setres = &Apache::lonnet::set_first_access($interval[1],$timelimit); + if ($setres eq 'ok') { + delete($env{'form.markaccess'}); + } + } elsif ($env{'form.LC_interval_done'} eq 'true') { + my $symb=&Apache::lonnet::symbread($url); + if ($symb) { + (my $donebuttonresult,$donemsg) = &Apache::lonhomework::zero_timer($symb); + undef($env{'form.LC_interval_done'}); + undef($env{'form.LC_interval_done_proctorpass'}); + } + } + my ($status,$result,$resource_due) = + &Apache::lonexttool::gradabletool_access_check(); + undef($Apache::lonhomework::browse); + if ($status eq 'CAN_ANSWER') { + if ($resource_due) { + my $time_left = $resource_due - time(); + if ($resource_due && ($time_left > 0)) { + $countdown =' '."\n"; +'."\n". + &Apache::lonhtmlcommon::set_due_date($resource_due); + } + } + } else { + if ($status eq 'SHOW_ANSWER') { + $result = &Apache::lonexttool::display_score(). + &Apache::lonfeedback::list_discussion('tool','OPEN'); + } + return &Apache::loncommon::start_page('Menu',undef,$args). + $result. + &Apache::loncommon::end_page(); + } } - my $startpage = &Apache::loncommon::start_page('Menu',$headjs,$args); + my $startpage = &Apache::loncommon::start_page('Menu',undef,$args).$countdown.$donemsg; my $endpage = &Apache::loncommon::end_page(); if (($uselink) && ($title eq '')) { @@ -167,6 +194,9 @@ ENDLINK if ($explanation ne '') { $output .= '
'.$explanation.'
'; } + if (&Apache::lonnet::EXT('resource.0.gradable')) { + $output .= &Apache::lonfeedback::list_discussion('tool','OPEN'); + } } else { if ($uselink) { $linktext = &mt('Link to resource'); @@ -213,20 +243,8 @@ ENDLINK var pos = height + hdrtop + offset; \$('.LC_iframecontainer').css('top', pos); }); - LCresizedef = 1; - if (LCnotready == 1) { - LCnotready = 0; - \$(window).trigger('resize'); - } }); - window.onload = function(){ - if (LCresizedef) { - LCnotready = 0; - \$(window).trigger('resize'); - } else { - LCnotready = 1; - } - }; + 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,'&<>"'); @@ -274,8 +292,8 @@ sub handler { for ($url){ s|^/adm/wrapper||; - $is_ext = $_ =~ s|^/ext/|http://|; - s|http://https://|https://| if ($is_ext); + $is_ext = $_ =~ s|^/ext/|http://|; + s|http://https://|https://|; s|:|:|g; } @@ -409,7 +427,7 @@ described at http://www.lon-capa.org. =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,$linktext,$explanation,$title,$width,$height) =over