--- rat/lonpage.pm 2016/08/09 23:43:51 1.118 +++ rat/lonpage.pm 2017/02/20 18:29:33 1.121 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.118 2016/08/09 23:43:51 raeburn Exp $ +# $Id: lonpage.pm,v 1.121 2017/02/20 18:29:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -184,6 +184,7 @@ sub handler { if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) { my $fn=$env{'request.course.fn'}; if (-e "$fn.db") { + my %buttonshide; if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) { # ------------------------------------------------------------------- Hash tied my $firstres=$hash{'map_start_'.$requrl}; @@ -300,11 +301,17 @@ sub handler { $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1)); foreach (@colcont) { my $src=$hash{'src_'.$_}; + my $plainsrc = $src; my ($extension)=($src=~/\.(\w+)$/); $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:'); if ($hash{'encrypted_'.$_}) { $src=&Apache::lonenc::encrypted($src); } + my ($mapid,$resid)=split(/\./,$_); + my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src); + unless ($env{'request.role.adv'}) { + $buttonshide{$symb} = &Apache::lonnet::EXT("resource.0.buttonshide",$symb); + } $cellemb{$_}= &Apache::loncommon::fileembstyle($extension); if ($cellexternal{$_}) { @@ -315,9 +322,6 @@ 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, @@ -471,11 +475,11 @@ ENDEXT $output=~ s/\<(input[^\>]+\Qonfocus=\"javascript:disableAutoComplete\E)\(\'([^\']+)\'\)(;\")/\<$1('$idprefix$2')$3/gsi; unless ($hastimer) { - if ($src =~ /$LONCAPA::assess_re/) { + if ($plainsrc =~ /$LONCAPA::assess_re/) { %Apache::lonhomework::history = &Apache::lonnet::restore($symb,$courseid,$domain,$name); my $type = 'problem'; - if ($src =~ /\.task$/) { + if ($extension eq 'task') { $type = 'Task'; } my ($status,$accessmsg,$slot_name,$slot) = @@ -676,10 +680,27 @@ ENDEXT &add_countdown_timer($currdisp,$donebuttontime,$donebuttonextras); } } + my $pagebuttonshide; + if (keys(%buttonshide)) { + my %uniquebuttonhide; + foreach my $item (values(%buttonshide)) { + if (exists($uniquebuttonhide{$item})) { + $uniquebuttonhide{$item} ++; + } else { + $uniquebuttonhide{$item} = 1; + } + } + if (keys(%uniquebuttonhide) == 1) { + if (lc((keys(%uniquebuttonhide))[0]) eq 'yes') { + $pagebuttonshide = 'yes'; + } + } + } # ------------------------------------------------------------------ Start body $r->print(&Apache::loncommon::start_page(undef,$allscript, {'force_register' => 1, - 'bgcolor' => '#ffffff',})); + 'bgcolor' => '#ffffff', + 'hide_buttons' => $pagebuttonshide})); # ------------------------------------------------------------------ Start form if ($nforms) { my $fmtag = '
'; + my $metainfo =&get_buttons(\%hash,$rid,\%buttonshide).'
'; unless (($target eq 'tex') || ($target eq 'tex_answer')) { $r->print('{'src_'.$rid}); @@ -862,7 +883,7 @@ sub get_buttons { $resid, $hash->{'src_'.$rid}); unless ($env{'request.role.adv'}) { - if (&Apache::lonnet::EXT('resource.0.buttonshide',$symb)) { + if ($buttonshide->{$symb} eq 'yes') { return; } } @@ -930,9 +951,11 @@ sub get_buttons { my ($cfile,$home,$switchserver,$forceedit,$forceview) = &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb); if ($cfile ne '') { + my $hostname = $r->hostname(); my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, $forceedit,1,$symb,undef, - &escape($env{'form.title'})); + &escape($env{'form.title'}), + $hostname); if ($jscall) { my $icon = 'pcstr.png'; my $label = &mt('Edit');