--- rat/lonpage.pm 2012/11/30 18:16:53 1.98 +++ rat/lonpage.pm 2014/03/08 18:27:39 1.104 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.98 2012/11/30 18:16:53 raeburn Exp $ +# $Id: lonpage.pm,v 1.104 2014/03/08 18:27:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use strict; use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::loncommon(); +use Apache::lonhtmlcommon; use Apache::lonxml(); use Apache::lonlocal; use Apache::lonmenu; @@ -227,6 +228,7 @@ sub handler { my %ssialink=(); my %cellemb=(); + my %cellexternal=(); my $allscript=''; my $allmeta=''; @@ -244,18 +246,26 @@ sub handler { $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1)); foreach (@colcont) { my $src=$hash{'src_'.$_}; - my ($extension)=($src=~/\.(\w+)$/); + my ($extension)=($src=~/\.(\w+)$/); + $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:'); if ($hash{'encrypted_'.$_}) { $src=&Apache::lonenc::encrypted($src); } $cellemb{$_}= &Apache::loncommon::fileembstyle($extension); - if ($cellemb{$_} eq 'ssi') { + if ($cellexternal{$_}) { + unless (($target eq 'tex') || ($target eq 'tex_answer')) { + $ssibody{$_} = <No iframe support! +ENDEXT + } + } elsif ($cellemb{$_} eq 'ssi') { # --------------------------------------------------------- This is an SSI cell my ($mapid,$resid)=split(/\./,$_); my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src); my $prefix=$_.'_'; + my $idprefix= join('_',($mapid,$resid,'')); my %posthash=('request.prefix' => $prefix, 'LONCAPA_INTERNAL_no_discussion' => 'true', 'symb' => $symb); @@ -361,6 +371,8 @@ sub handler { } $output=~ s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi; + $output=~ + s/\<((?:input|select|button|textarea)[^\>]+)id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 id="$idprefix$2" $3\>/gsi; if ($nuploads) { $output=~ s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi; @@ -423,6 +435,12 @@ sub handler { if (($nforms) && ($nuploads)) { $allscript .= &Apache::lonhtmlcommon::file_submissionchk_js(\%turninpaths,\%multiresps); } + if (($nforms) && (&Apache::lonhtmlcommon::htmlareabrowser())) { + my %textarea_args = ( + dragmath => 'math', + ); + $allscript .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); + } # ------------------------------------------------------------------ Start body $r->print(&Apache::loncommon::start_page(undef,$allscript, {'force_register' => 1, @@ -472,12 +490,11 @@ sub handler { my $avespan=$lcm/($#colcont+1); for ($j=0;$j<=$#colcont;$j++) { my $rid=$colcont[$j]; - my $metainfo =&get_buttons(\%hash,$rid).'
'; unless (($target eq 'tex') || ($target eq 'tex_answer')) { $r->print('print(' bgcolor="'. @@ -499,7 +516,10 @@ sub handler { } $r->print('>'); } - $r->print($ssibody{$rid}); + unless (($cellexternal{$rid}) && + ($target eq 'tex') && ($target eq 'tex_answer')) { + $r->print($ssibody{$rid}); + } unless (($target eq 'tex') || ($target eq 'tex_answer')) { $r->print(''); } @@ -517,9 +537,15 @@ sub handler { $r->print('>'.$metainfo.''); } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) { - $r->print($metainfo.''.$hash{'title_'.$rid}.'
'. - &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'

'. - &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'


'); + $r->print($metainfo.''.$hash{'title_'.$rid}.'
'); + unless ($cellemb{$rid} eq 'wrp') { + $r->print(&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')); + } + $r->print('

'. + &Apache::londocs::entryline(0, + &mt("Click to download or use your browser's Save Link function"), + '/'.&Apache::lonnet::declutter($hash{'src_'.$rid})). + '


'); } unless (($target eq 'tex') || ($target eq 'tex_answer')) { $r->print(''); @@ -544,7 +570,7 @@ sub handler { # ---------------------------------------------------------------- Submit, etc. if ($nforms) { $r->print( - ''); } unless (($target eq 'tex') || ($target eq 'tex_answer')) { @@ -595,19 +621,25 @@ sub get_buttons { $esrc=&Apache::lonenc::encrypted($esrc); } if ($hash->{'src_'.$rid} !~ m-^/uploaded/- + && $hash->{'src_'.$rid} !~ m{^https?://} && !$env{'request.enc'} && ($env{'request.role.adv'} || !$hash->{'encrypted_'.$rid})) { $metainfo .=''. ''. - ''. + ''.&mt('Show Metadata').''. ''; } - if ($hash->{'src_'.$rid} !~ m{^/uploaded/}) { + if (($hash->{'src_'.$rid} !~ m{^/uploaded/}) && + ($hash->{'src_'.$rid} !~ m{^https?://})) { $metainfo .= ''. - ''. + ''.&mt('Provide my evaluation of this resource').''. ''; } if (($hash->{'src_'.$rid}=~/$LONCAPA::assess_re/) && @@ -618,12 +650,16 @@ sub get_buttons { ''. '&command=submission">'. - ''. + ''.&mt('View Submissions for a Student or a Group of Students').''. ''. ''. '&command=gradingmenu">'. - ''. + ''.&mt('Content Grades').''. ''; } if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { @@ -631,10 +667,32 @@ sub get_buttons { ''. '" >'. - ''. + ''.&mt('Content Settings').''. ''; } } + if (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $file=&Apache::lonnet::declutter($hash->{'src_'.$rid}); + my ($cfile,$home,$switchserver,$forceedit,$forceview) = + &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb); + if ($cfile ne '') { + my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, + $forceedit,1,$symb,undef, + &escape($env{'form.title'})); + if ($jscall) { + my $icon = 'pcstr.png'; + my $label = &mt('Edit'); + my $title = &mt('Edit this resource'); + my $pic = ''.$label.''; + $metainfo .= ' '.$pic.''; + } + } + } return $metainfo; }