[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 28 Mar 2002 22:53:55 -0000


albertel		Thu Mar 28 17:53:55 2002 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  - cleaned up <rnadomlist> edit mode
  - added arg show to <randomlist>, to optionally limit the number of internal tags it shows.
  
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.85 loncom/homework/structuretags.pm:1.86
--- loncom/homework/structuretags.pm:1.85	Wed Mar 20 17:13:19 2002
+++ loncom/homework/structuretags.pm	Thu Mar 28 17:53:55 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.85 2002/03/20 22:13:19 sakharuk Exp $
+# $Id: structuretags.pm,v 1.86 2002/03/28 22:53:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -437,6 +437,7 @@
 # </randomlist>
 sub start_randomlist {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+  my $result;
   if ($target eq 'answer' || $target eq 'grade' || $target eq 'web') {
     my $body= &Apache::lonxml::get_all_text("/randomlist",$$parser[$#$parser]);
     my $b_parser= HTML::TokeParser->new(\$body);
@@ -461,16 +462,27 @@
       #  print "<b>END-TAG $b_tok->[1]</b><br />";
       # }
     }
-
     my @idx_arr = (0 .. $#randomlist);
     &Apache::structuretags::shuffle(\@idx_arr);
     my $bodytext = '';
-    for(0 .. $#randomlist) {
+    my $show=$#randomlist;
+    my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
+    $showarg--;
+    if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; }
+    for(0 .. $show) {
       $bodytext .= "$randomlist[ $idx_arr[$_] ]";
     }
     &Apache::lonxml::newparser($parser,\$bodytext);
+  } elsif ($target eq 'edit' ) {
+    $result .= &Apache::edit::tag_start($target,$token);
+    $result .= &Apache::edit::text_arg('Maximum Tags to Show:','show',$token,5);
+    $result .= &Apache::edit::end_row().&Apache::edit::start_spanning_row();
+  } elsif ($target eq 'modified' ) {
+    my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,
+						 'show');
+    if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
   }
-  return "";
+  return $result;
 }
 
 sub shuffle {
@@ -487,7 +499,12 @@
 }
 
 sub end_randomlist {
-  return '';
+  my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+  my $result;
+  if ($target eq 'edit' ) {
+    $result=&Apache::edit::tag_end($target,$token,'End Randomly Parsed Block');
+  }
+  return $result;
 }
 
 sub start_part {