--- rat/lonpage.pm 2016/08/09 23:43:51 1.118 +++ rat/lonpage.pm 2020/06/03 03:48:37 1.120.2.2 @@ -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.120.2.2 2020/06/03 03:48:37 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,11 +322,8 @@ 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 $prefix='p_'.$_.'_'; + my $idprefix='p_'.join('_',($mapid,$resid,'')); my %posthash=('request.prefix' => $prefix, 'LONCAPA_INTERNAL_no_discussion' => 'true', 'symb' => $symb); @@ -352,6 +356,9 @@ ENDEXT $posthash{'all_submit'}='yes'; } } + if ($env{'environment.remote'} eq 'on') { + $posthash{'inhibitmenu'} = 'yes'; + } my $output=Apache::lonnet::ssi($src,%posthash); $output=~s|//(\s*)?\s||gs; if (($target eq 'tex') || ($target eq 'tex_answer')) { @@ -438,6 +445,8 @@ ENDEXT 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; + $output=~ + s/(\Qthis.form.elements['\E)(HW(?:VAL|CHK)_[^']+\'\]\.(?:value=\'|checked))/$1$prefix$2/gsi; if ($hastimer) { $output=~ s/\<(input[^\>]+name=\Q"$prefix\Eaccessbutton"[^\>]+)(?:\Qdocument.markaccess.submit();\E)([^\>]*)\>/\<$1pageTimer(this.form,'$prefix')$2\>/gsi; @@ -471,11 +480,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 +685,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 +888,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; } }