--- loncom/homework/edit.pm 2002/11/03 19:16:19 1.38 +++ loncom/homework/edit.pm 2003/01/19 08:13:54 1.43 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # edit mode helpers # -# $Id: edit.pm,v 1.38 2002/11/03 19:16:19 www Exp $ +# $Id: edit.pm,v 1.43 2003/01/19 08:13:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -99,26 +99,31 @@ sub start_table { } $Apache::edit::colordepth++; push(@Apache::edit::inserttag,$token->[1]); - my $result="

"; + my $result='
'; + $result.='
'; return $result; } sub end_table { $Apache::edit::colordepth--; - my $result="

"; - $result.= - "

". - &innerinsertlist('edit', - (defined($Apache::edit::inserttag[-2])?$Apache::edit::inserttag[-2]:'problem') -, - (defined($Apache::edit::inserttag[-1])?$Apache::edit::inserttag[-1]:'')). - "

"; + my $result=''; + $result.="
"; + + my ($tagname,$closingtag); + if (defined($Apache::edit::inserttag[-2])) { + $tagname=$Apache::edit::inserttag[-2]; + } else {$tagname='problem';} + if (defined($Apache::edit::inserttag[-1])) { + $closingtag=$Apache::edit::inserttag[-1]; + } + $result.=&innerinsertlist('edit',$tagname,$closingtag). + "
"; pop(@Apache::edit::inserttag); return $result; } -sub start_spanning_row { return '';} -sub start_row { return ''; } +sub start_spanning_row { return '';} +sub start_row { return ''; } sub end_row { return ''; } sub movebuttons { @@ -322,6 +327,16 @@ sub insert_radiobuttonresponse { '; } +sub insert_rankresponse { + return ' + + + + + +'; +} + sub insert_displayduedate { return ''; } sub insert_displaytitle { return ''; } sub insert_hintpart { @@ -453,54 +468,75 @@ sub text_arg { } sub select_arg { - my ($description,$name,$list,$token) = @_; - my $result; - my $optionlist=""; - my $selected=$token->[2]{$name}; - foreach my $option (@$list) { - if ( $selected eq $option ) { - $optionlist.="\n"; - } else { - $optionlist.="\n"; + my ($description,$name,$list,$token) = @_; + my $result; + my $optionlist=""; + my $selected=$token->[2]{$name}; + foreach my $option (@$list) { + my $value; + if ( ref($option) eq 'ARRAY') { + $value='value="'.$$option[0].'"'; + $option=$$option[1]; + } else { + $value='value="'.$option.'"'; + } + if ( $selected eq $option ) { + $optionlist.="\n"; + } else { + $optionlist.="\n"; + } } - } - $result.=$description.' '.$optionlist.' '; - return $result; + return $result; } sub select_or_text_arg { - my ($description,$name,$list,$token,$size) = @_; - my $result; - my $optionlist=""; - my $found=0; - my $selected=$token->[2]{$name}; - foreach my $option (@$list) { - if ( $selected eq $option ) { - $optionlist.="\n"; - $found=1; - } else { - $optionlist.="\n"; - } - } - $optionlist.="\n"; - if (($found) || (!$selected)) { - $result.=$description.' '.$optionlist.' '; - } else { - $result.=&text_arg($description,$name,$token,$size); - } - return $result; + } else { + $result.=&text_arg($description,$name,$token,$size); + } + return $result; } #----------------------------------------------------- browse sub browse { # insert a link to call up the filesystem browser (lonindexer) - $_ = shift; + my ($id, $mode) = @_; my $form = 'lonhomework'; - my $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$_"); + my $element; + if (! defined($mode) || $mode eq 'attribute') { + $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$id"); + } elsif ($mode eq 'textnode') { # for data between ... + $element = &Apache::lonnet::escape('homework_edit_'. + $Apache::lonxml::curdepth); + } my $result = <<"ENDBUTTON"; Browse ENDBUTTON