[LON-CAPA-cvs] cvs: rat / lonratparms.pm loncom/homework structuretags.pm loncom/interface loncommon.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 25 Feb 2003 21:49:45 -0000


albertel		Tue Feb 25 16:49:45 2003 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
    /loncom/interface	loncommon.pm 
    /rat	lonratparms.pm 
  Log:
  
  - Fixes some of BUG#55, can now inhibit the display of part ids
  
  - New function in loncommon &check_if_partid_hidden to be used for checking 
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.148 loncom/homework/structuretags.pm:1.149
--- loncom/homework/structuretags.pm:1.148	Fri Feb 14 16:22:04 2003
+++ loncom/homework/structuretags.pm	Tue Feb 25 16:49:45 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.148 2003/02/14 21:22:04 www Exp $
+# $Id: structuretags.pm,v 1.149 2003/02/25 21:49:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -666,28 +666,35 @@
   $Apache::inputtags::part=$id;
   @Apache::inputtags::responselist = ();
   @Apache::inputtags::previous=();
+  my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
+
   if ($target eq 'meta') {
     return &Apache::response::mandatory_part_meta;
-  } elsif ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
-    my ($status,$accessmsg) = &Apache::lonhomework::check_access($id);
-    push (@Apache::inputtags::status,$status);
-    my $expression='$external::datestatus="'.$status.'";';
-    $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';
-    &Apache::run::run($expression,$safeeval);
-    if ( $status eq 'CLOSED' ) {
-      my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
-      if ( $target eq "web" ) {
-	$result="<br />Part is not open to be viewed. It $accessmsg<br />";
-      } elsif ( $target eq 'tex' ) {
-	$result="\\end{minipage}\\vskip 0 mm Part is not open to be viewed. It $accessmsg \\\\\\begin{minipage}{\\textwidth}";
-      }
-    } else {
-      if ($target eq 'tex') {
-	if ($$tagstack[-2] ne 'problem') {
-	  $result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
-	}
+  } elsif ($target eq 'web' || $target eq 'grade' ||
+	   $target eq 'answer' || $target eq 'tex') {
+      if ($hidden) {
+	  my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
+      } else {
+	  my ($status,$accessmsg) = &Apache::lonhomework::check_access($id);
+	  push (@Apache::inputtags::status,$status);
+	  my $expression='$external::datestatus="'.$status.'";';
+	  $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';
+	  &Apache::run::run($expression,$safeeval);
+	  if ( $status eq 'CLOSED' ) {
+	      my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
+	      if ( $target eq "web" ) {
+		  $result="<br />Part is not open to be viewed. It $accessmsg<br />";
+	      } elsif ( $target eq 'tex' ) {
+		  $result="\\end{minipage}\\vskip 0 mm Part is not open to be viewed. It $accessmsg \\\\\\begin{minipage}{\\textwidth}";
+	      }
+	  } else {
+	      if ($target eq 'tex') {
+		  if ($$tagstack[-2] ne 'problem') {
+		      $result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
+		  }
+	      }
+	  }
       }
-    }
   } elsif ($target eq 'edit') {
       $result.=&Apache::edit::tag_start($target,$token);
       $result.=&Apache::edit::text_arg('Part ID:','id',$token).
@@ -709,12 +716,13 @@
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   &Apache::lonxml::debug("in end_part $target ");
   my $status=$Apache::inputtags::status['-1'];
+  my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
   my $result='';
   if ( $target eq 'meta' ) {
       $result='';
-  } elsif ( $target eq 'grade' && $status eq 'CAN_ANSWER') {
+  } elsif ( $target eq 'grade' && $status eq 'CAN_ANSWER' && !$hidden) {
     $result=&Apache::inputtags::grade;
-  } elsif ($target eq 'web' || $target eq 'tex' ) {
+  } elsif (($target eq 'web' || $target eq 'tex') && !$hidden ) {
     my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part,
 						    $target);
     if ($Apache::lonhomework::type eq 'exam') {$gradestatus='';}
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.83 loncom/interface/loncommon.pm:1.84
--- loncom/interface/loncommon.pm:1.83	Mon Feb 24 18:32:32 2003
+++ loncom/interface/loncommon.pm	Tue Feb 25 16:49:45 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.83 2003/02/24 23:32:32 albertel Exp $
+# $Id: loncommon.pm,v 1.84 2003/02/25 21:49:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1920,6 +1920,21 @@
     $i--;
     return($i);
 }
+
+
+sub check_if_partid_hidden {
+    my ($id,$symb,$udom,$uname) = @_;
+    my $hiddenparts=&Apache::lonnet::EXT('resource.0.parameter_hiddenparts',
+					 $symb,$udom,$uname);
+    my @hiddenlist=split(/,/,$hiddenparts);
+    foreach my $checkid (@hiddenlist) {
+	if ($checkid =~ /^\s*\Q$id\E\s*$/) { return 1; }
+    }
+    return undef;
+}
+
+
+
 1;
 __END__;
 
Index: rat/lonratparms.pm
diff -u rat/lonratparms.pm:1.13 rat/lonratparms.pm:1.14
--- rat/lonratparms.pm:1.13	Tue Feb 25 10:58:51 2003
+++ rat/lonratparms.pm	Tue Feb 25 16:49:45 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Set parameters inside of the RAT
 #
-# $Id: lonratparms.pm,v 1.13 2003/02/25 15:58:51 www Exp $
+# $Id: lonratparms.pm,v 1.14 2003/02/25 21:49:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,6 +88,12 @@
         $content{'parameter_mapalias'}='';
         $type{'parameter_mapalias'}='string';
 	$display{'parameter_mapalias'}='Resource alias name for conditions';
+    }
+    if ($uri=~/\.(problem|exam|quiz|assess|survey|form|library)\.meta$/) {
+	$content{'parameter_hiddenparts'}='';
+        $type{'parameter_hiddenparts'}='string';
+	$display{'parameter_hiddenparts'}=
+	    'A comma separted list of Part Ids to not display.';
     }
 # ---------------------------------------------------------- Current Parameters