Annotation of loncom/homework/edit.pm, revision 1.3

1.1       albertel    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 {
1.3     ! albertel   10:   my ($tag) = @_;
1.1       albertel   11:   my $result='';
                     12: 
1.3     ! albertel   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>
1.1       albertel   27: </tr><tr><td colspan=\"3\">\n";
                     28:   return $result;
                     29: }
                     30: 
                     31: sub tag_end {
1.3     ! albertel   32:   my ($tag) = @_;
1.1       albertel   33:   my $result='';
                     34: 
1.3     ! albertel   35:   $result.="</td></tr><tr><td>&lt;/$tag&gt;</td></tr></table>\n";
1.1       albertel   36:   return $result;
                     37: }
                     38: 
1.2       albertel   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) = @_;
1.3     ! albertel   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:     }
1.2       albertel   70:   }
1.3     ! albertel   71:   return $result;
1.2       albertel   72: }
                     73: 
1.1       albertel   74: 1;
                     75: __END__

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