[LON-CAPA-cvs] cvs: rat(version_2_11_X) / lonpage.pm

raeburn raeburn at source.lon-capa.org
Sat Oct 29 01:59:30 EDT 2016


raeburn		Sat Oct 29 05:59:30 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /rat	lonpage.pm 
  Log:
  - For 2.11
    Backport 1.119, 1.120
  
  
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.111.2.2 rat/lonpage.pm:1.111.2.3
--- rat/lonpage.pm:1.111.2.2	Wed Aug 10 04:37:32 2016
+++ rat/lonpage.pm	Sat Oct 29 05:59:30 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Page Handler
 #
-# $Id: lonpage.pm,v 1.111.2.2 2016/08/10 04:37:32 raeburn Exp $
+# $Id: lonpage.pm,v 1.111.2.3 2016/10/29 05:59:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -183,6 +183,7 @@
   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};
@@ -260,11 +261,17 @@
                       $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{$_}) {
@@ -275,9 +282,6 @@
                               }
                           } 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,
@@ -431,11 +435,11 @@
                                   $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) =
@@ -508,7 +512,7 @@
                       &Apache::loncommon::content_type($r,'text/html');
                       $r->send_http_header;
                       $r->print(&Apache::loncommon::start_page(undef,undef,
-							       {'force_register' => 1,}));
+							       {'force_register' => 1}));
                       $r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. ');
                       $r->print('<br /><br />'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').
 				&Apache::loncommon::end_page());
@@ -576,10 +580,27 @@
                                   &add_countdown_timer($currdisp);
                               }
                           }
+                          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 = '<form name="lonhomework" method="post"  enctype="multipart/form-data"';
@@ -625,7 +646,7 @@
                           my $avespan=$lcm/($#colcont+1);
                           for ($j=0;$j<=$#colcont;$j++) {
                               my $rid=$colcont[$j];
-			      my $metainfo =&get_buttons(\%hash,$rid).'<br />';
+			      my $metainfo =&get_buttons(\%hash,$rid,\%buttonshide).'<br />';
 			    unless (($target eq 'tex') || ($target eq 'tex_answer')) {
 				$r->print('<td colspan="'.$avespan.'"');
 			    }
@@ -753,7 +774,7 @@
 }
 
 sub get_buttons {
-    my ($hash,$rid) = @_;
+    my ($hash,$rid,$buttonshide) = @_;
 
     my $metainfo = '';
     my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
@@ -762,7 +783,7 @@
 					  $resid,
 					  $hash->{'src_'.$rid});
     unless ($env{'request.role.adv'}) {
-        if (&Apache::lonnet::EXT('resource.0.buttonshide',$symb)) {
+        if ($buttonshide->{$symb} eq 'yes') {
             return;
         }
     }




More information about the LON-CAPA-cvs mailing list