--- loncom/homework/edit.pm 2002/03/08 18:30:33 1.30 +++ loncom/homework/edit.pm 2002/10/25 19:02:38 1.37 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # edit mode helpers # -# $Id: edit.pm,v 1.30 2002/03/08 18:30:33 matthew Exp $ +# $Id: edit.pm,v 1.37 2002/10/25 19:02:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,8 @@ package Apache::edit; use strict; -use Apache::lonnet; +use Apache::lonnet(); +use HTML::Entities(); # Global Vars # default list of colors to use in editing @@ -164,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; @@ -245,6 +249,13 @@ sub insert_stringresponse { </stringresponse>'; } +sub insert_essayresponse { + return ' +<essayresponse> + <textfield></textfield> +</essayresponse>'; +} + sub insert_optionresponse { return ' <optionresponse max="10"> @@ -281,6 +292,12 @@ sub insert_numericalhint { </numericalhint>'; } +sub insert_radiobuttonhint { + return ' +<radiobuttonhint> +</radiobuttonhint>'; +} + sub insert_startouttext { return "<startouttext />\n<endouttext />"; } @@ -301,6 +318,18 @@ sub textarea_sizes { return ($rows,$cols); } +sub editline { + my ($tag,$data,$description,$size)=@_; + $data=&HTML::Entities::encode($data); + if ($description) { $description="<br />".$description."<br />"; } + my $result = <<"END"; +$description +<input type="text" name="homework_edit_$Apache::lonxml::curdepth" + value="$data" size="$size" /> +END + return $result; +} + sub editfield { my ($tag,$data,$description,$minwidth,$minheight)=@_; @@ -309,7 +338,9 @@ sub editfield { if ($cols < $minwidth ) { $cols = $minwidth; } if ($rows < $minheight) { $rows = $minheight; } if ($description) { $description="<br />".$description."<br />"; } - return "$description\n <textarea rows=\"$rows\" cols=\"$cols\" name=\"homework_edit_".$Apache::lonxml::curdepth."\">$data</textarea>\n"; + return $description."\n".' <textarea rows="'.$rows. + '" cols="'.$cols.'" name="homework_edit_'.$Apache::lonxml::curdepth.'">'. + &HTML::Entities::encode($data).'</textarea>'."\n"; } sub modifiedfield { @@ -408,7 +439,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>'; @@ -552,6 +583,11 @@ search($elementname) : provide a link wh searcher (lonsearchcat) and, once a file is selected, place the result in the form element $elementname. +=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. + =back incomplete...