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

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.4     ! albertel   10:   my ($token,$target) = @_;
1.1       albertel   11:   my $result='';
1.4     ! albertel   12:   if ($target eq "web") {
        !            13:     my $tag=$token->[1];
        !            14:     $result.="<table width=\"100%\" border=\"2\"><tr><td>&lt;$tag&gt;</td>
1.3       albertel   15: <td>Delete:
                     16: <select name=\"delete_$Apache::lonxml::curdepth\">
                     17: <option>Nothing</option>
                     18: <option>Tag</option>
                     19: <option>Subtags</option>
                     20: </select></td>
1.4     ! albertel   21: <td>".
        !            22:   &insertlist($token,$target).
        !            23:     "</td>
1.1       albertel   24: </tr><tr><td colspan=\"3\">\n";
1.4     ! albertel   25:   }
1.1       albertel   26:   return $result;
                     27: }
                     28: 
                     29: sub tag_end {
1.4     ! albertel   30:   my ($token,$target) = @_;
1.1       albertel   31:   my $result='';
1.4     ! albertel   32:   if ($target eq 'edit') {
        !            33:     my $tag=$token->[1];
        !            34:     $result.="</td></tr><tr><td>&lt;/$tag&gt;</td></tr></table>\n";
        !            35:   }
        !            36:   return $result;
        !            37: }
1.1       albertel   38: 
1.4     ! albertel   39: sub insertlist {
        !            40:   my ($token,$target) = @_;
        !            41:   my $result;
        !            42:   if ($target eq 'edit') {
        !            43:     $result = "Insert:
        !            44: <select name=\"insert_$Apache::lonxml::curdepth\">
        !            45: <option>Nothing</option>
        !            46: <option>Text Block</option>
        !            47: <option>Script Block</option>
        !            48: </select>"
        !            49:   }
1.1       albertel   50:   return $result;
                     51: }
                     52: 
1.2       albertel   53: sub editfield {
                     54:   my ($tag,$data,$description)=@_;
                     55:   
                     56:   my $count=0;
                     57:   my $maxlength=-1;
                     58:   map { $count++;
                     59: 	if (length($_) > $maxlength) { $maxlength = length ($_); }
                     60:       } split ("\n", $data);
                     61:   if ($maxlength > 80) { $maxlength = 80; }
                     62:   if ($description) { 
                     63:     $description="<br />".$description; 
                     64:   }
                     65:   return "$description<br />\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea>\n";
                     66: #  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";
                     67: }
                     68: 
                     69: sub modifiedfield {
                     70:   my ($token) = @_;
1.3       albertel   71:   my $result;
                     72: #  foreach my $envkey (sort keys %ENV) {
                     73: #    &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");
                     74: #  }
                     75: #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
                     76: #  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
                     77:   $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
                     78:   if (defined $token) {
                     79:     if (defined $token->[4]) {
                     80:       $result=$token->[4].$result;
                     81:     } else {
                     82:       $result=$result.$token->[2];
                     83:     }
1.2       albertel   84:   }
1.3       albertel   85:   return $result;
1.2       albertel   86: }
                     87: 
1.1       albertel   88: 1;
                     89: __END__

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