';
+ return $output;
+}
+
sub itemdisplay {
my ($location)=@_;
if ($location eq 'top' &&
@@ -401,8 +461,11 @@ sub itemdisplay {
}
return undef;
}
+
sub displayfoils {
my ($target,$max,$randomize)=@_;
+ my ($tabsize, $lefttabsize, $righttabsize);
+
my $result;
my $question;
my (@whichfoils)=&Apache::response::whichorder(&getfoilcounts($max),
@@ -429,7 +492,7 @@ sub displayfoils {
if ($target eq 'tex') {
$question.=' \\\\ '.$letter.':'.$text;
} else {
- $question.=' '.$letter.':'.$text;
+ $question.=' '.$letter.': '.$text;
}
}
} else {
@@ -450,23 +513,47 @@ sub displayfoils {
$optionlist="\n";
} else {
if ($Apache::lonhomework::type ne 'exam') {
- $optionlist='\framebox[5 mm][s]{\tiny\strut}';
- }
+ $optionlist='\framebox[10 mm][s]{\tiny\strut}';
+ }
}
my $option;
foreach $option (@used_letters) {
if ($option eq $last_letter) {
- if ($target ne 'tex') {$optionlist.="\n";}
+ if ($target ne 'tex') {
+ $optionlist.="\n";
+ }
} else {
- if ($target ne 'tex') {$optionlist.="\n";}
+ if ($target ne 'tex') {
+ $optionlist.="\n";
+ }
}
}
if ($target ne 'tex' && $Apache::lonhomework::type ne 'exam') {
- $optionlist='\n";
}
my $text=$Apache::response::foilgroup{$name.'.text'};
+ #
+ # Factor out the tex computations of the left/right 1/2 minipage
+ # widths for left or right positioning. This allows us
+ # to, if necessary constrain the bubble widths:
+ #
+ if ($target eq 'tex' &&
+ (&itemdisplay('left') || &itemdisplay('right'))) {
+ $tabsize=&Apache::londefdef::recalc($env{'form.textwidth'});
+ ($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);
+ }
+ }
if ($target ne 'tex') {
if ($Apache::lonhomework::type ne 'exam') {
$question.=" \n".$optionlist.$text;
@@ -478,14 +565,25 @@ sub displayfoils {
$question.=&Apache::optionresponse::webbubbles(\@used_letters,\@blank,$temp,$last_letter);
}
} else {
+ # Note that if left or right positioned, we must
+ # confine the bubbles to righttabsize:
+ #
if ($Apache::lonhomework::type eq 'exam') {
$question.=' '.$optionlist.$text."\n";
my @emptyItems = ();
for (my $i=0;$i<=$#used_letters;$i++) {push @emptyItems, ' ';}
- $question.='\vskip -1 mm\noindent\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]'.&Apache::optionresponse::bubbles(\@used_letters,\@emptyItems).'\end{enumerate} \vskip -8 mm \strut ';
+ $question.='\vskip -1 mm\noindent\begin{list}{}{\setlength{\listparindent}{0mm}\setlength{\leftmargin}{2mm}}'
+ .'\item \hskip -3mm \textbf{'.$internal_counter.'}';
+ if (&itemdisplay('left') || &itemdisplay('right')) {
+ $question .= &Apache::optionresponse::bubbles(\@used_letters,\@emptyItems, "", $righttabsize);
+ }
+ else {
+ $question .= &Apache::optionresponse::bubbles(\@used_letters,\@emptyItems);
+ }
+ $question .= '\end{list} \vskip -8 mm \strut ';
$internal_counter++;
} else {
- $question.=' '.$optionlist.$text.'\strut\\\\\strut '."\n";
+ $question.=' '.$optionlist.$text.'\strut\\\\\strut '."\n";
}
}
$temp++;
@@ -502,17 +600,6 @@ sub displayfoils {
$result='
'.$question.
'
'.$result.'
';
} else {
- my $tabsize=&Apache::londefdef::recalc($ENV{'form.textwidth'});
- 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}';
@@ -524,22 +611,17 @@ sub displayfoils {
$result='
'.$result.
'
'.$question.'
';
} else {
- my $tabsize=&Apache::londefdef::recalc($ENV{'form.textwidth'});
- 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{'.$lefttabsize.'}p{'.$righttabsize.'}}\begin{minipage}{'.$lefttabsize.'}'.$result.'\end{minipage}&\begin{minipage}{'.$righttabsize.'}'.$question.'\end{minipage}\end{tabular}';
}
}
+ if ($target eq 'web') {
+ &Apache::response::setup_prior_tries_hash(\&format_prior_answer,
+ [\@whichfoils,
+ 'submissiongrading',
+ 'submissionitems']);
+ }
if ($target ne 'tex') {$result.=" ";} else {$result.=' \\\\ ';}
return $result;
}
@@ -646,10 +728,13 @@ sub end_foil {
if ($value ne 'unused') {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
&Apache::lonxml::debug("Got a name of :$name:");
- if (!$name) { $name=$Apache::lonxml::curdepth; }
+ if (!$name) {
+ &Apache::lonxml::warning(&mt('Foils without names exist. This can cause problems to malfunction.'));
+ $name=$Apache::lonxml::curdepth;
+ }
&Apache::lonxml::debug("Using a name of :$name:");
if (defined($Apache::response::foilnames{$name})) {
- &Apache::lonxml::error(&mt("Foil name [_1] appears more than once. Foil names need to be unique.",$name));
+ &Apache::lonxml::error(&mt("Foil name [_1] appears more than once. Foil names need to be unique.",''.$name.''));
}
$Apache::response::foilnames{$name}++;
my $location =&Apache::lonxml::get_param('location',$parstack,