--- loncom/homework/edit.pm 2001/06/26 21:39:55 1.14
+++ loncom/homework/edit.pm 2001/07/23 22:40:59 1.20
@@ -146,7 +146,7 @@ $optionlist
}
sub handle_insert {
- if (!$ENV{"form.insert_$Apache::lonxml::curdepth"}) { return ''; }
+ if ($ENV{"form.insert_$Apache::lonxml::curdepth"} eq '') { return ''; }
my $result;
my $tagnum = $ENV{"form.insert_$Apache::lonxml::curdepth"};
my $func=$Apache::lonxml::insertlist{"$tagnum.function"};
@@ -156,14 +156,42 @@ sub handle_insert {
if ($newtag =~ /::/) { ($namespace,$newtag) = split(/::/,$newtag); }
$result.="\n<$newtag>\n$newtag>";
} else {
- {
- no strict 'refs';
- $result.=&$func();
+ if (defined(&$func)) {
+ {
+ no strict 'refs';
+ $result.=&$func();
+ }
+ } else {
+ my $newtag=$Apache::lonxml::insertlist{"$tagnum.tag"};
+ &Apache::lonxml::error("Unable to insert tag $newtag, $func was not defined.");
}
}
return $result;
}
+sub insert_responseparam {
+ return '
+ ';
+}
+
+sub insert_numericalresponse {
+ return '
+
+
+
+
+';
+}
+
+sub insert_stringresponse {
+ return '
+
+
+
+
+';
+}
+
sub insert_optionresponse {
return '
@@ -219,13 +247,14 @@ sub insert_script {
return "\n";
}
-# Returns a 1 if the toekn has been modified and you should rebuild the tag
+# Returns a 1 if the token has been modified and you should rebuild the tag
# side-effects, will modify the $token if new values are found
sub get_new_args {
my ($token,$parstack,$safeeval,@args)=@_;
my $rebuild=0;
foreach my $arg (@args) {
- my $value=&Apache::lonxml::get_param($arg,$parstack,$safeeval);
+ #just want the string that it was set to
+ my $value=$token->[2]->{$arg};
my $newvalue=$ENV{"form.$Apache::lonxml::curdepth.$arg"};
&Apache::lonxml::debug(" for:$arg: cur is :$value: new is :$newvalue:");
if ($value ne $newvalue) {
@@ -236,16 +265,23 @@ sub get_new_args {
return $rebuild;
}
+# looks for /> on start tags
sub rebuild_tag {
my ($token) = @_;
my $result;
if ($token->[0] eq 'S') {
$result = '<'.$token->[1];
while (my ($key,$val)= each(%{$token->[2]})) {
+ $val=~s:^\s+|\s+$::g;
+ $val=~s:"::g; #"
&Apache::lonxml::debug("setting :$key: to :$val:");
$result.=' '.$key.'="'.$val.'"';
}
- $result.=">";
+ if ($token->[4] =~ m:/>$:) {
+ $result.=' />';
+ } else {
+ $result.='>';
+ }
} elsif ( $token->[0] eq 'E' ) {
$result = ''.$token->[1].'>';
}
@@ -280,5 +316,29 @@ sub select_arg {
return $result;
}
+sub select_or_text_arg {
+ my ($description,$name,$list,$token,$size) = @_;
+ my $result;
+ my $optionlist="";
+ my $found=0;
+ my $selected=$token->[2]{$name};
+ foreach my $option (@$list) {
+ if ( $selected eq $option ) {
+ $optionlist.="\n";
+ $found=1;
+ } else {
+ $optionlist.="\n";
+ }
+ }
+ $optionlist.="\n";
+ if ($found) {
+ $result.=$description.'