[LON-CAPA-cvs] cvs: loncom /homework matchresponse.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Thu, 08 Jul 2004 17:45:28 -0000
sakharuk Thu Jul 8 13:45:28 2004 EDT
Modified files:
/loncom/homework matchresponse.pm
Log:
Bug 3176 (Match Response - specifying the print width) is fixed. Additional
attribute of <itemgroup> tag is introduced - TeXitemgroupwidth. It defines the
width of corresponding field in % of the TeXwidth (of line). Example:
TeXitemgroupwidth="30%").
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.42 loncom/homework/matchresponse.pm:1.43
--- loncom/homework/matchresponse.pm:1.42 Fri Jul 2 04:20:55 2004
+++ loncom/homework/matchresponse.pm Thu Jul 8 13:45:28 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.42 2004/07/02 08:20:55 albertel Exp $
+# $Id: matchresponse.pm,v 1.43 2004/07/08 17:45:28 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -110,6 +110,7 @@
} elsif ($target eq 'web' or $target eq 'tex') {
$Apache::matchresponse::itemtable{'location'}=
&Apache::lonxml::get_param('location',$parstack,$safeeval);
+ $Apache::matchresponse::TeXitemgroupwidth=&Apache::lonxml::get_param('TeXitemgroupwidth',$parstack,$safeeval,undef,0);
}
return $result;
}
@@ -491,10 +492,19 @@
'</td></tr></table>';
} else {
my $tabsize=&Apache::londefdef::recalc($ENV{'form.textwidth'});
- $tabsize=~/(\d+\.?\d*)/;
- $tabsize=$1/2.1;
- $tabsize.=' mm ';
- $result='\setlength{\tabcolsep}{1 mm}\begin{tabular}{p{'.$tabsize.'}p{'.$tabsize.'}}\begin{minipage}{'.$tabsize.'}'.$question.'\end{minipage}&\begin{minipage}{'.$tabsize.'}'.$result.'\end{minipage}\end{tabular}';
+ my ($lefttabsize,$righttabsize)=(0,0);
+ if ($Apache::matchresponse::TeXitemgroupwidth ne '') {
+ $Apache::matchresponse::TeXitemgroupwidth=~/(\d*.?\d*)/;
+ $lefttabsize=$tabsize*$1/100;
+ $righttabsize=0.95*($tabsize-$lefttabsize);
+ } else {
+ $tabsize=~/(\d+\.?\d*)/;
+ $lefttabsize=$1/2.1;
+ $righttabsize=0.95*($1-$lefttabsize);
+ }
+ $lefttabsize.=' mm ';
+ $righttabsize.=' mm ';
+ $result='\setlength{\tabcolsep}{1 mm}\begin{tabular}{p{'.$righttabsize.'}p{'.$lefttabsize.'}}\begin{minipage}{'.$righttabsize.'}'.$question.'\end{minipage}&\begin{minipage}{'.$lefttabsize.'}'.$result.'\end{minipage}\end{tabular}';
}
} elsif ($result=&itemdisplay('left')) {
if ($target ne 'tex') {
@@ -502,10 +512,19 @@
'</td></tr></table>';
} else {
my $tabsize=&Apache::londefdef::recalc($ENV{'form.textwidth'});
- $tabsize=~/(\d+\.?\d*)/;
- $tabsize=$1/2.1;
- $tabsize.=' mm ';
- $result='\setlength{\tabcolsep}{1 mm}\begin{tabular}{p{'.$tabsize.'}p{'.$tabsize.'}}\begin{minipage}{'.$tabsize.'}'.$result.'\end{minipage}&\begin{minipage}{'.$tabsize.'}'.$question.'\end{minipage}\end{tabular}';
+ my ($lefttabsize,$righttabsize)=(0,0);
+ if ($Apache::matchresponse::TeXitemgroupwidth ne '') {
+ $Apache::matchresponse::TeXitemgroupwidth=~/(\d*.?\d*)/;
+ $lefttabsize=$tabsize*$1/100;
+ $righttabsize=0.95*($tabsize-$lefttabsize);
+ } else {
+ $tabsize=~/(\d+\.?\d*)/;
+ $tabsize=$1/2.1;
+ $righttabsize=0.95*($1-$lefttabsize);
+ }
+ $lefttabsize.=' mm ';
+ $righttabsize.=' mm ';
+ $result='\setlength{\tabcolsep}{1 mm}\begin{tabular}{p{'.$lefttabsize.'}p{'.$righttabsize.'}}\begin{minipage}{'.$lefttabsize.'}'.$result.'\end{minipage}&\begin{minipage}{'.$righttabsize.'}'.$question.'\end{minipage}\end{tabular}';
}
}
if ($target ne 'tex') {$result.="<br />";} else {$result.=' \\\\ ';}