--- loncom/homework/edit.pm	2002/03/22 20:05:19	1.32
+++ loncom/homework/edit.pm	2002/08/07 16:23:05	1.36
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.32 2002/03/22 20:05:19 albertel Exp $
+# $Id: edit.pm,v 1.36 2002/08/07 16:23:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -165,9 +165,12 @@ sub get_insert_list {
     }
   }
   if (@tagnums) {
+    my %options;
     foreach my $tagnum (@tagnums) {
-      $result.='<option value="'.$tagnum.'">'.$Apache::lonxml::insertlist{"$tagnum.description"}."</option>\n";
+      my $descrip=$Apache::lonxml::insertlist{"$tagnum.description"};
+      $options{$descrip} ="<option value=\"$tagnum\">".$descrip."</option>\n";
     }
+    foreach my $option (sort(keys(%options))) { $result.=$options{$option}; }
     if ($result) { $result='<option selected="on"></option>'.$result; }
   }
   return $result;
@@ -246,6 +249,13 @@ sub insert_stringresponse {
 </stringresponse>';
 }
 
+sub insert_essayresponse {
+  return '
+<essayresponse>
+    <textfield></textfield>
+</essayresponse>';
+}
+
 sub insert_optionresponse {
   return '
 <optionresponse max="10">
@@ -423,7 +433,7 @@ sub select_or_text_arg {
     }
   }
   $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
-  if ($found) {
+  if (($found) || (!$selected)) {
     $result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">
        '.$optionlist.'
       </select>';
@@ -567,7 +577,7 @@ search($elementname) : provide a link wh
 searcher (lonsearchcat) and, once a file is selected, place the result in
 the form element $elementname.
 
-= item *
+=item *
 editline(tag,data,description,size): Provide a <input type="text" ../> for
 single-line text entry.  This is to be used for text enclosed by tags, not
 arguements/parameters associated with a tag.