--- loncom/xml/londefdef.pm 2004/03/12 15:21:49 1.202 +++ loncom/xml/londefdef.pm 2004/03/15 19:19:04 1.203 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.202 2004/03/12 15:21:49 sakharuk Exp $ +# $Id: londefdef.pm,v 1.203 2004/03/15 19:19:04 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -1795,13 +1795,14 @@ sub start_table { if (not defined $TeXwidth) { my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,$safeeval,undef,1); if ($htmlwidth=~/%/) { + $Apache::londefdef::table[-1]{'percent'}=1; $htmlwidth=~/(\d+)/; - my $value=$1*$textwidth/100; - $Apache::londefdef::table[-1]{'width'}=$value; + $Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100;; } else { $Apache::londefdef::table[-1]{'width'}=$textwidth; } } elsif ($TeXwidth=~/%/) { + $Apache::londefdef::table[-1]{'percent'}=1; $TeXwidth=~/(\d+)/; my $value=$1*$textwidth/100; $Apache::londefdef::table[-1]{'width'}=$value; @@ -1881,6 +1882,17 @@ sub end_table { $length_row_final[$jn]=0.9*$available_length/$needed; } } + #recalculation for the use of all available width if width is defined in % + if ($Apache::londefdef::table[-1]{'percent'}==1) { + my $current=0; + for (my $i=0;$i<=$#length_row_final;$i++) { + $current+=$length_row_final[$i]; + } + my $coef=$Apache::londefdef::table[-1]{'width'}/$current; + for (my $i=0;$i<=$#length_row_final;$i++) { + $length_row_final[$i]*=$coef; + } + } #fill the table for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { for (my $jn=0;$jn<=$#length_row_final;$jn++) {