[LON-CAPA-cvs] cvs: loncom /homework edit.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 14 Aug 2003 19:30:34 -0000
www Thu Aug 14 15:30:34 2003 EDT
Modified files:
/loncom/homework edit.pm
Log:
Bug #1859: The behavior of the matching option-response "Correct Option"
field should be a lot more intuitive now with regards to pre-set and
typed-in values.
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.59 loncom/homework/edit.pm:1.60
--- loncom/homework/edit.pm:1.59 Mon Aug 4 18:07:29 2003
+++ loncom/homework/edit.pm Thu Aug 14 15:30:34 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.59 2003/08/04 22:07:29 albertel Exp $
+# $Id: edit.pm,v 1.60 2003/08/14 19:30:34 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -575,16 +575,36 @@
$optionlist.="<option $value>$option</option>\n";
}
}
- $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
- if (($found) || (!$selected)) {
- $result.=$description.' <select name="'.&html_element_name($name)
- .'">
- '.$optionlist.'
- </select>';
- } else {
- $result.=&text_arg($description,$name,$token,$size);
- }
- return '<nobr>'.$result.'</nobr>';
+ $optionlist.="<option value=\"TYPEDINVALUE\"".
+ ((!$found)?' selected="on"':'').
+ ">Type in value</option>\n";
+#
+ my $element=&html_element_name($name);
+ my $selectelement='select_list_'.$element;
+ my $typeinelement='type_in_'.$element;
+ my $typeinvalue=($found?'':$selected);
+#
+ my $hiddenvalue='this.form.'.$element.'.value';
+ my $selectedindex='this.form.'.$selectelement.'.selectedIndex';
+ my $selectedvalue='this.form.'.$selectelement.
+ '.options['.$selectedindex.'].value';
+ my $typedinvalue='this.form.'.$typeinelement.'.value';
+ my $selecttypeinindex='this.form.'.$selectelement.'.options.length';
+#
+ return (<<ENDSELECTORTYPE);
+<nobr>
+$description
+ <select name="$selectelement"
+onChange="if ($selectedvalue!='TYPEDINVALUE') { $hiddenvalue=$selectedvalue; $typedinvalue=''; }"
+$optionlist
+</select>
+<input type="text" size="$size" name="$typeinelement"
+ value="$typeinvalue"
+onChange="$hiddenvalue=$typedinvalue;"
+onFocus="$selectedindex=$selecttypeinindex-1;" />
+<input type="hidden" name="$element" value="$selected" />
+</nobr>
+ENDSELECTORTYPE
}
#----------------------------------------------------- image coordinates