Annotation of loncom/homework/edit.pm, revision 1.2
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 {
10: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
11: my $result='';
12:
13: $result.="<table border=\"1\"><tr><td><$token->[1]></td>
14: <td><input type=\"submit\" name=\"delete_$Apache::lonxml::curdepth\" value=\"Delete\" /></td>
15: <td><input type=\"submit\" name=\"insert_$Apache::lonxml::curdepth\" value=\"Insert\" /></td>
16: </tr><tr><td colspan=\"3\">\n";
17: return $result;
18: }
19:
20: sub tag_end {
21: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
22: my $result='';
23:
24: $result.="</td></tr><tr><td></$token->[1]></td></tr></table>\n";
25: return $result;
26: }
27:
1.2 ! albertel 28: sub editfield {
! 29: my ($tag,$data,$description)=@_;
! 30:
! 31: my $count=0;
! 32: my $maxlength=-1;
! 33: map { $count++;
! 34: if (length($_) > $maxlength) { $maxlength = length ($_); }
! 35: } split ("\n", $data);
! 36: if ($maxlength > 80) { $maxlength = 80; }
! 37: if ($description) {
! 38: $description="<br />".$description;
! 39: }
! 40: return "$description<br />\n <textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea>\n";
! 41: # return "<br />\n<$tag><br />\n <textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea><br />\n</$tag><br />\n";
! 42: }
! 43:
! 44: sub modifiedfield {
! 45: my ($token) = @_;
! 46: foreach my $envkey (sort keys %ENV) {
! 47: &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");
! 48: }
! 49: &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
! 50: &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
! 51: if (defined $token->[4]) {
! 52: return $token->[4].$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
! 53: } else {
! 54: return $ENV{"homework_edit_$Apache::lonxml::curdepth"}.$token->[2];
! 55: }
! 56: }
! 57:
1.1 albertel 58: 1;
59: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>