File:  [LON-CAPA] / loncom / homework / edit.pm
Revision 1.3: download - view: text, annotated - select for diffs
Thu Apr 26 21:21:48 2001 UTC (23 years ago) by albertel
Branches: MAIN
CVS tags: HEAD
- improved and works in some cases

    1: # The LearningOnline Network with CAPA 
    2: # edit mode helpers
    3: # 3/20 Guy
    4: package Apache::edit; 
    5: 
    6: use strict;
    7: use Apache::lonnet;
    8: 
    9: sub tag_start {
   10:   my ($tag) = @_;
   11:   my $result='';
   12: 
   13:   $result.="<table width=\"100%\" border=\"2\"><tr><td>&lt;$tag&gt;</td>
   14: <td>Delete:
   15: <select name=\"delete_$Apache::lonxml::curdepth\">
   16: <option>Nothing</option>
   17: <option>Tag</option>
   18: <option>Subtags</option>
   19: </select></td>
   20: <td>Insert:
   21: <select name=\"insert_$Apache::lonxml::curdepth\">
   22: <option>Nothing</option>
   23: <option>Text Block</option>
   24: <option>Script Block</option>
   25: </select>
   26: </td>
   27: </tr><tr><td colspan=\"3\">\n";
   28:   return $result;
   29: }
   30: 
   31: sub tag_end {
   32:   my ($tag) = @_;
   33:   my $result='';
   34: 
   35:   $result.="</td></tr><tr><td>&lt;/$tag&gt;</td></tr></table>\n";
   36:   return $result;
   37: }
   38: 
   39: sub editfield {
   40:   my ($tag,$data,$description)=@_;
   41:   
   42:   my $count=0;
   43:   my $maxlength=-1;
   44:   map { $count++;
   45: 	if (length($_) > $maxlength) { $maxlength = length ($_); }
   46:       } split ("\n", $data);
   47:   if ($maxlength > 80) { $maxlength = 80; }
   48:   if ($description) { 
   49:     $description="<br />".$description; 
   50:   }
   51:   return "$description<br />\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea>\n";
   52: #  return "<br />\n&lt;$tag&gt;<br />\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea><br />\n&lt;/$tag&gt;<br />\n";
   53: }
   54: 
   55: sub modifiedfield {
   56:   my ($token) = @_;
   57:   my $result;
   58: #  foreach my $envkey (sort keys %ENV) {
   59: #    &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");
   60: #  }
   61: #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
   62: #  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
   63:   $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
   64:   if (defined $token) {
   65:     if (defined $token->[4]) {
   66:       $result=$token->[4].$result;
   67:     } else {
   68:       $result=$result.$token->[2];
   69:     }
   70:   }
   71:   return $result;
   72: }
   73: 
   74: 1;
   75: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>