--- loncom/homework/edit.pm	2001/07/10 22:06:42	1.17
+++ loncom/homework/edit.pm	2001/07/18 20:27:22	1.19
@@ -183,6 +183,15 @@ sub insert_numericalresponse {
 </numericalresponse>';
 }
 
+sub insert_stringresponse {
+  return '
+<stringresponse answer="" type="">
+    <textline />
+    <hintgroup>
+    </hintgroup>
+</stringresponse>';
+}
+
 sub insert_optionresponse {
   return '
 <optionresponse max="10">
@@ -262,6 +271,7 @@ sub rebuild_tag {
   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.'"';
@@ -305,5 +315,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.="<option selected=\"on\">$option</option>\n";
+      $found=1;
+    } else {
+      $optionlist.="<option>$option</option>\n";
+    }
+  }
+  $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
+  if ($found) {
+    $result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">
+       '.$optionlist.'
+      </select></td></tr><tr><td colspan="3">';
+  } else {
+    $result.=&text_arg($description,$name,$token,$size);
+  }
+  return $result;
+}
 1;
 __END__