--- loncom/homework/edit.pm 2002/01/11 16:32:29 1.27 +++ 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.27 2002/01/11 16:32:29 matthew Exp $ +# $Id: edit.pm,v 1.37 2002/10/25 19:02:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,10 +27,12 @@ # # 3/20 Guy # 01/10/02 Matthew +# 03/06/02 Matthew package Apache::edit; use strict; -use Apache::lonnet; +use Apache::lonnet(); +use HTML::Entities(); # Global Vars # default list of colors to use in editing @@ -163,9 +165,12 @@ sub get_insert_list { } } if (@tagnums) { + my %options; foreach my $tagnum (@tagnums) { - $result.='\n"; + my $descrip=$Apache::lonxml::insertlist{"$tagnum.description"}; + $options{$descrip} ="\n"; } + foreach my $option (sort(keys(%options))) { $result.=$options{$option}; } if ($result) { $result=''.$result; } } return $result; @@ -244,6 +249,13 @@ sub insert_stringresponse { '; } +sub insert_essayresponse { + return ' + + +'; +} + sub insert_optionresponse { return ' @@ -280,6 +292,12 @@ sub insert_numericalhint { '; } +sub insert_radiobuttonhint { + return ' + +'; +} + sub insert_startouttext { return "\n"; } @@ -300,6 +318,18 @@ sub textarea_sizes { return ($rows,$cols); } +sub editline { + my ($tag,$data,$description,$size)=@_; + $data=&HTML::Entities::encode($data); + if ($description) { $description="
".$description."
"; } + my $result = <<"END"; +$description + +END + return $result; +} + sub editfield { my ($tag,$data,$description,$minwidth,$minheight)=@_; @@ -308,7 +338,9 @@ sub editfield { if ($cols < $minwidth ) { $cols = $minwidth; } if ($rows < $minheight) { $rows = $minheight; } if ($description) { $description="
".$description."
"; } - return "$description\n   \n"; + return $description."\n".'   '."\n"; } sub modifiedfield { @@ -320,13 +352,6 @@ sub modifiedfield { # &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth"); # &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"}); $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"}; - if (defined $token) { - if (defined $token->[4]) { - $result=$token->[4].$result; - } else { - $result=$result.$token->[2]; - } - } return $result; } @@ -414,7 +439,7 @@ sub select_or_text_arg { } } $optionlist.="\n"; - if ($found) { + if (($found) || (!$selected)) { $result.=$description.''; @@ -423,6 +448,32 @@ sub select_or_text_arg { } return $result; } + +#----------------------------------------------------- browse +sub browse { + # insert a link to call up the filesystem browser (lonindexer) + $_ = shift; + my $form = 'lonhomework'; + my $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$_"); + my $result = <<"ENDBUTTON"; +Browse +ENDBUTTON + return $result; +} + +#----------------------------------------------------- browse +sub search { + # insert a link to call up the filesystem browser (lonindexer) + $_ = shift; + my $form = 'lonhomework'; + my $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$_"); + my $result = <<"ENDBUTTON"; +Search +ENDBUTTON + return $result; +} + + 1; __END__ @@ -522,6 +573,21 @@ from lonxml; return a scalar string get_insert_list($token) : provide an insertion list based on possibilities from lonxml; return a scalar string +=item * +browse($elementname) : provide a link which will open up the filesystem +browser (lonindexer) and, once a file is selected, place the result in +the form element $elementname. + +=item * +search($elementname) : provide a link which will open up the filesystem +searcher (lonsearchcat) and, once a file is selected, place the result in +the form element $elementname. + +=item * +editline(tag,data,description,size): Provide a for +single-line text entry. This is to be used for text enclosed by tags, not +arguements/parameters associated with a tag. + =back incomplete...