';
- } else {
- $result.=&text_arg($description,$name,$token,$size);
- }
- return $result;
+ my ($description,$name,$list,$token,$size) = @_;
+ my $result;
+ my $optionlist="";
+ my $found=0;
+ my $selected=$token->[2]{$name};
+ foreach my $option (@$list) {
+ my ($text,$value);
+ if ( ref($option) eq 'ARRAY') {
+ $value='value="'.$$option[0].'"';
+ $text=$$option[1];
+ $option=$$option[0];
+ } else {
+ $text=$option;
+ $value='value="'.$option.'"';
+ }
+ if ( $selected eq $option ) {
+ $optionlist.="\n";
+ $found=1;
+ } else {
+ $optionlist.="\n";
+ }
+ }
+ $optionlist.="\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';
+ $description=&mt($description);
+#
+ return (<
+$description
+
+
+
+
+ENDSELECTORTYPE
+}
+
+#----------------------------------------------------- image coordinates
+# single image coordinates, x, y
+sub entercoords {
+ my ($idx,$idy,$mode,$width,$height) = @_;
+ unless ($Apache::edit::bgimgsrc) { return ''; }
+ if ($idx) { $idx.='_'; }
+ if ($idy) { $idy.='_'; }
+ my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
+ my $form = 'lonhomework';
+ my $element;
+ if (! defined($mode) || $mode eq 'attribute') {
+ $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth");
+ } elsif ($mode eq 'textnode') { # for data between ...
+ $element = &Apache::lonnet::escape('homework_edit_'.
+ $Apache::lonxml::curdepth);
+ }
+ my $id=$Apache::lonxml::curdepth;
+ my %data=("imagechoice.$id.type" =>'point',
+ "imagechoice.$id.formname" =>$form,
+ "imagechoice.$id.formx" =>"$idx$element",
+ "imagechoice.$id.formy" =>"$idy$element",
+ "imagechoice.$id.file" =>$bgfile,
+ "imagechoice.$id.formcoord" =>$element);
+ if ($height) {
+ $data{"imagechoice.$id.formheight"}=$height.'_'.
+ $Apache::edit::bgimgsrccurdepth;
+ }
+ if ($width) {
+ $data{"imagechoice.$id.formwidth"}=$width.'_'.
+ $Apache::edit::bgimgsrccurdepth;
+ }
+ &Apache::lonnet::appenv(%data);
+ my $text="Click Coordinates";
+ my $result=''.$text.'';
+ return $result;
+}
+
+# coordinates (x1,y1)-(x2,y2)...
+# mode can be either box, or polygon
+sub entercoord {
+ my ($idx,$mode,$width,$height,$type) = @_;
+ unless ($Apache::edit::bgimgsrc) { return ''; }
+ my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
+ my $form = 'lonhomework';
+ my $element;
+ if (! defined($mode) || $mode eq 'attribute') {
+ $element = &Apache::lonnet::escape("$idx\_$Apache::lonxml::curdepth");
+ } elsif ($mode eq 'textnode') { # for data between ...
+ $element = &Apache::lonnet::escape('homework_edit_'.
+ $Apache::lonxml::curdepth);
+ }
+ my $id=$Apache::lonxml::curdepth;
+ my %data=("imagechoice.$id.type" =>$type,
+ "imagechoice.$id.formname" =>$form,
+ "imagechoice.$id.file" =>$bgfile,
+ "imagechoice.$id.formcoord" =>$element);
+ if ($height) {
+ $data{"imagechoice.$id.formheight"}=$height.'_'.
+ $Apache::edit::bgimgsrccurdepth;
+ }
+ if ($width) {
+ $data{"imagechoice.$id.formwidth"}=$width.'_'.
+ $Apache::edit::bgimgsrccurdepth;
+ }
+ &Apache::lonnet::appenv(%data);
+ my $text="Enter Coordinates";
+ if ($type eq 'polygon') { $text='Create Polygon Data'; }
+ my $result=''.$text.'';
+ return $result;
+}
+
+sub deletecoorddata {
+ &Apache::lonnet::delenv("imagechoice\\.");
+}
+
+#----------------------------------------------------- browse
+sub browse {
+ # insert a link to call up the filesystem browser (lonindexer)
+ my ($id, $mode, $titleid) = @_;
+ my $form = 'lonhomework';
+ my $element;
+ if (! defined($mode) || $mode eq 'attribute') {
+ $element = &Apache::lonnet::escape("$id\_$Apache::lonxml::curdepth");
+ } elsif ($mode eq 'textnode') { # for data between ...
+ $element = &Apache::lonnet::escape('homework_edit_'.
+ $Apache::lonxml::curdepth);
+ }
+ my $titleelement;
+ if ($titleid) {
+ $titleelement=",'','','".&Apache::lonnet::escape("$titleid\_$Apache::lonxml::curdepth")."'";
+ }
+ my $result = <<"ENDBUTTON";
+Select
+ENDBUTTON
+ return $result;
+}
+
+#----------------------------------------------------- browse
+sub search {
+ # insert a link to call up the filesystem browser (lonindexer)
+ my ($id, $mode, $titleid) = @_;
+ my $form = 'lonhomework';
+ my $element;
+ if (! defined($mode) || $mode eq 'attribute') {
+ $element = &Apache::lonnet::escape("$id\_$Apache::lonxml::curdepth");
+ } elsif ($mode eq 'textnode') { # for data between ...
+ $element = &Apache::lonnet::escape('homework_edit_'.
+ $Apache::lonxml::curdepth);
+ }
+ my $titleelement;
+ if ($titleid) {
+ $titleelement=",'".&Apache::lonnet::escape("$titleid\_$Apache::lonxml::curdepth")."'";
+ }
+ my $result = <<"ENDBUTTON";
+Search
+ENDBUTTON
+ return $result;
}
+
+
1;
__END__
@@ -473,6 +889,18 @@ end_table() : reduce color depth; end ta
=item *
+start_spanning_row() : start a new table row spanning the 'edit' environment.
+
+=item *
+
+start_row() : start a new table row and element.
+
+=item *
+
+end_row() : end current table element and row.
+
+=item *
+
movebuttons($target,$token) : move-up and move-down buttons; return scalar
string
@@ -507,6 +935,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...
|