--- loncom/homework/edit.pm	2003/05/10 23:04:58	1.51
+++ loncom/homework/edit.pm	2003/07/29 15:05:53	1.58
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.51 2003/05/10 23:04:58 www Exp $
+# $Id: edit.pm,v 1.58 2003/07/29 15:05:53 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,10 +63,17 @@ sub tag_start {
   &deletelist($target,$token)
   ."</td>
 <td>".
-    &insertlist($target,$token).&end_row().&start_spanning_row();
+    &insertlist($target,$token);
 #<td>". 
 #  &movebuttons($target,$token).
 #    "</tr><tr><td colspan=\"3\">\n";
+    my @help = Apache::lonxml::helpinfo($token);
+    if ($help[0]) {
+	$result .= '<td align="right" valign="top">' .
+	    Apache::loncommon::help_open_topic(@help) .
+	    '</td>';
+    } else { $result .= "<td>&nbsp;</td>"; }
+    $result .= &end_row().&start_spanning_row();
   }
   return $result;
 }
@@ -75,13 +82,7 @@ sub tag_end {
   my ($target,$token,$description) = @_;
   my $result='';
   if ($target eq 'edit') {
-    my $tag=$token->[1];
-    if (!defined($description)) {
-      $result.="</td></tr><tr><td>&lt;/$tag&gt;</td><td colspan=\"2\">&nbsp;</td>";
-    } else {
-      if ($description ne '') { $result.="</td></tr><tr><td>$description</td><td colspan=\"2\">&nbsp;</td>"; }
-    }
-    $result.="</tr>".&end_table()."\n";
+    $result.="</td></tr>".&end_table()."\n";
   }
   return $result;
 }
@@ -125,7 +126,7 @@ sub end_table {
   return $result;
 }
 
-sub start_spanning_row { return '<tr><td colspan="3" bgcolor="#DDDDDD">';}
+sub start_spanning_row { return '<tr><td colspan="4" bgcolor="#DDDDDD">';}
 sub start_row          { return '<tr><td bgcolor="#DDDDDD">';            }
 sub end_row            { return '</td></tr>';          }
 
@@ -310,6 +311,16 @@ sub insert_essayresponse {
 </essayresponse>';
 }
 
+sub insert_imageresponse {
+  return '
+<imageresponse max="1">
+    <foilgroup>
+    </foilgroup>
+    <hintgroup>
+    </hintgroup>
+</imageresponse>';
+}
+
 sub insert_optionresponse {
   return '
 <optionresponse max="10">
@@ -404,9 +415,11 @@ sub textarea_sizes {
   my ($data)=@_;
   my $count=0;
   my $maxlength=-1;
-  foreach (split ("\n", $$data)) { $count++;
-	if (length($_) > $maxlength) { $maxlength = length($_); }
-      }
+  foreach (split ("\n", $$data)) {
+      $count+=int(length($_)/79);
+      $count++;
+      if (length($_) > $maxlength) { $maxlength = length($_); }
+  }
   my $rows = $count;
   my $cols = $maxlength;
   return ($rows,$cols);
@@ -460,7 +473,7 @@ sub get_new_args {
     my $element=&html_element_name($arg);
     my $newvalue=$ENV{"form.$element"};
     &Apache::lonxml::debug(" for:$arg: cur is :$value: new is :$newvalue:");
-    if ($value ne $newvalue) {
+    if (defined($newvalue) && $value ne $newvalue) {
       $token->[2]->{$arg}=$newvalue;
       $rebuild=1;
     }
@@ -512,7 +525,7 @@ sub text_arg {
   my $arg=$token->[2]{$name};
   $result=$description.'&nbsp;<input name="'.&html_element_name($name).
     '" type="text" value="'.$arg.'" size="'.$size.'" />';
-  return $result;
+  return '<nobr>'.$result.'</nobr>';
 }
 
 sub select_arg {
@@ -534,10 +547,10 @@ sub select_arg {
 	    $optionlist.="<option $value >$option</option>\n";
 	}
     }
-    $result.=$description.'&nbsp;<select name="'.&html_element_name($name).
-        '">
+    $result.='<nobr>'.$description.'&nbsp;<select name="'.
+	&html_element_name($name).'">
        '.$optionlist.'
-      </select>';
+      </select></nobr>';
     return $result;
 }
 
@@ -571,7 +584,7 @@ sub select_or_text_arg {
     } else {
 	$result.=&text_arg($description,$name,$token,$size);
     }
-    return $result;
+    return '<nobr>'.$result.'</nobr>';
 }
 
 #----------------------------------------------------- image coordinates
@@ -645,7 +658,7 @@ sub browse {
                                            $Apache::lonxml::curdepth);
     }
     my $result = <<"ENDBUTTON";
-<a href=\"javascript:openbrowser('$form','$element')\"\>Browse</a>
+<a href=\"javascript:openbrowser('$form','$element')\"\>Select</a>
 ENDBUTTON
     return $result;
 }