';
+ return $output;
+}
+
sub itemdisplay {
my ($location)=@_;
if ($location eq 'top' &&
@@ -426,8 +456,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),
@@ -475,15 +508,28 @@ sub displayfoils {
$optionlist="\n";
} else {
if ($Apache::lonhomework::type ne 'exam') {
- $optionlist='\framebox[5 mm][s]{\tiny\strut}';
- }
+ if($env{'form.pdfFormFields'} eq 'yes') {
+ my $fieldname = $env{'request.symb'} . '&part_'. $Apache::inputtags::part .'&matchresponse'. '&HWVAL_' . $Apache::inputtags::response['-1'] . ':' . $temp . '&submit_' . $Apache::inputtags::part . '&';
+ $optionlist = &Apache::lonxml::print_pdf_start_combobox($fieldname);
+ } else {
+ $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";
+ } elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes') {
+ $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option);
+ }
} else {
- if ($target ne 'tex') {$optionlist.="\n";}
+ if ($target ne 'tex') {
+ $optionlist.="\n";
+ } elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes') {
+ $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option);
+ }
}
}
if ($target ne 'tex' && $Apache::lonhomework::type ne 'exam') {
@@ -493,6 +539,25 @@ sub displayfoils {
$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;
@@ -504,14 +569,29 @@ sub displayfoils {
$question.=&Apache::optionresponse::webbubbles(\@used_letters,\@blank,$temp,$last_letter);
}
} else {
- if ($Apache::lonhomework::type eq 'exam') {
+ # Note that if left or right positioned, we must
+ # confine the bubbles to righttabsize:
+ #
+ if ($Apache::lonhomework::type eq 'exam' && $env{'form.pdfFormFields'} ne 'yes') {
$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";
+ if($env{'form.pdfFormFields'} eq 'yes') {
+ $question .= " $optionlist ". &Apache::lonxml::print_pdf_end_combobox($text).'\strut';
+ } else {
+ $question.=' '.$optionlist.$text.'\strut\\\\\strut '."\n";
+ }
}
}
$temp++;
@@ -528,17 +608,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}';
@@ -550,22 +619,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;
}
@@ -673,12 +737,12 @@ sub end_foil {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
&Apache::lonxml::debug("Got a name of :$name:");
if (!$name) {
- &Apache::lonxml::warning("Foils without names exist. This can cause problems to malfunction.");
+ &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,