'; }
my %lastresponse=&Apache::lonnet::str2hash($lastresponse);
- if (&Apache::response::show_answer() ) {
+ if ($showanswer) {
foreach my $name (@names) {
if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') {
if (($direction eq 'horizontal') && ($target ne 'tex')) {
@@ -346,13 +386,22 @@ sub displayallfoils {
$result.="
";
} else {
if ($target eq 'tex') {
- $result .= '\item \vskip -2mm ';
- } else {
+ if($env{'form.pdfFormFields'} eq 'yes' && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
+ my $fieldname = $env{'request.symb'}.'&part_'. $Apache::inputtags::part
+ .'&radiobuttonresponse'.'&HWVAL_'.$Apache::inputtags::response['-1'];
+ $result .= '\item[{'.&Apache::lonxml::print_pdf_radiobutton($fieldname,$temp).'}]'
+ .$Apache::response::foilgroup{$name.'.text'}."\n";
+ } else {
+ $result .= '\item \vskip -2mm ';
+ }
+ } else {
$result.=" ";
}
}
if ($target eq 'tex') {
- $result .= '$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\'; #' stupid emacs
+ if($env{'form.pdfFormFields'} ne 'yes' or $Apache::inputtags::status[-1] ne 'CAN_ANSWER') {
+ $result .= '$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\'; #' stupid emacs
+ }
$i++;
} else {
$result .= '';
}
@@ -379,33 +429,6 @@ sub displayallfoils {
return $result;
}
-=pod
-
-=item &whichfoils($max,$randomize)
-
-Randomizes the list of foils.
-Respects
- - each foils desire to be randomized
- - the existance of Concept groups of foils (select 1 foil from each)
- - and selects a single correct statement from all possilble true statments
- - and limits it to a toal of $max foils
-
-WARNING: this routine uses the random number generator, it should only
-be called once per target, otherwise it can cause randomness changes in
-homework problems.
-
-Arguments
- $max - maximum number of foils to select (including the true one)
- (so a max of 5 is: 1 true, 4 false)
-
- $randomize - whether to randomize the listing of foils, by default
- will randomize, only if randomize is 'no' will it not
-
-Returns
- $answer - location in the array of the correct answer
- @foils - array of foil names in to display order
-
-=cut
sub whichfoils {
my ($max,$randomize)=@_;
@@ -440,8 +463,12 @@ sub whichfoils {
&Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in ",'<>&"'));
}
}
- if (!$havetrue && $Apache::lonhomework::type ne 'survey') {
- &Apache::lonxml::error("There are no true statements available. ");
+ if ((!$havetrue) &&
+ ($Apache::lonhomework::type ne 'survey') &&
+ ($Apache::lonhomework::type ne 'surveycred') &&
+ ($Apache::lonhomework::type ne 'anonsurvey') &&
+ ($Apache::lonhomework::type ne 'anonsurveycred')) {
+ &Apache::lonxml::error(&mt('There are no true statements available.').' ');
}
} else {
my $current=0;
@@ -500,9 +527,13 @@ sub whichfoils {
&Apache::lonxml::debug("Answer wants $answer");
my $truename=$truelist[$whichtrue];
my $dosplice=1;
- if ($notrue && $Apache::lonhomework::type ne 'survey') {
+ if (($notrue) &&
+ ($Apache::lonhomework::type ne 'survey') &&
+ ($Apache::lonhomework::type ne 'surveycred') &&
+ ($Apache::lonhomework::type ne 'anonsurvey') &&
+ ($Apache::lonhomework::type ne 'anonsurveycred')) {
$dosplice=0;
- &Apache::lonxml::error("There are no true statements available. ");
+ &Apache::lonxml::error(&mt('There are no true statements available.').' ');
}
#insert the true statement, keeping track of where it wants to be
if ($Apache::response::foilgroup{$truename.'.location'} eq 'top' && $dosplice) {
@@ -524,8 +555,12 @@ sub whichfoils {
$dosplice=0;
} else {
if ($topcount>0 || $bottomcount>0) {
- $answer = int(&Math::Random::random_uniform() * ($#whichfalse+1))
- + $topcount;
+ my $inc = 1;
+ if (($bottomcount > 0) && ($Apache::lonhomework::type ne 'exam')) {
+ $inc = 2;
+ }
+ $answer=int(&Math::Random::random_uniform() * ($#whichfalse+$inc))
+ + $topcount;
}
}
&Apache::lonxml::debug("Answer now wants $answer");
@@ -566,9 +601,13 @@ sub displayfoils {
$result.='\item \vskip -2 mm ';
}
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
- if ($target ne 'tex') { $result.='Correct:'; } else { $result.='Correct: \textbf{';}
+ if ($target ne 'tex') {
+ $result.=&mt('Correct:').'';
+ } else {
+ $result.=&mt('Correct:').' \textbf{';
+ }
} else {
- $result.='Incorrect:';
+ $result.=&mt('Incorrect:');
}
if ($target eq 'web') { $result.="