version 1.153, 2012/01/05 11:56:34
|
version 1.153.6.2, 2012/01/21 20:54:57
|
Line 387 sub format_prior_answer {
|
Line 387 sub format_prior_answer {
|
|
|
} |
} |
|
|
|
## |
sub displayallfoils { |
sub displayallfoils { |
my ( $direction, $target ) = @_; |
my ( $direction, $target ) = @_; |
my $result; |
my $result; |
Line 767 sub whichfoils {
|
Line 768 sub whichfoils {
|
&Apache::lonxml::debug("Answer is $answer"); |
&Apache::lonxml::debug("Answer is $answer"); |
return ( $answer, @whichfalse ); |
return ( $answer, @whichfalse ); |
} |
} |
|
## |
|
# Generate the HTML for a single html foil. |
|
# @param $part - The part for which the response is being generated. |
|
# @param $fieldname - The basename of the radiobutton field |
|
# @param $name - The foilname. |
|
# @param $last_responses - Reference to a hash that holds the most recent |
|
# responses. |
|
# @param $value - radiobutton value. |
|
# |
|
# @return text |
|
# @retval The generated html. |
|
# |
|
sub html_radiobutton { |
|
my ($part, $fieldname, $name, $last_responses, $value) = @_; |
|
|
|
my $result='<label>'; |
|
|
|
$result .= '<input type="radio" |
|
onchange="javascript:setSubmittedPart(' . "'$part');\"" |
|
. 'name="HWVAL_' . $fieldname . '"' |
|
. "value='$value'"; |
|
|
|
if (defined($last_responses->{$name})) { |
|
$result .= ' checked="checked" '; |
|
} |
|
$result .= ' />'; |
|
$result .= $Apache::response::foilgroup{$name . '.text'}; |
|
$result .= '</label>'; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
## |
|
# Display foils in html rendition: |
|
# |
|
# @param $whichfoils - Set of foils to display. |
|
# @param $target - Rendition target...there are several html targets. |
|
# @param $direction - 'horizontal' if layout is horizontal. |
|
# @param $part - Part of the problem that's being displayed. |
|
# @param $solved - Solution state of the problem. |
|
# @param $show_answer- True if answers should be shown. |
|
# |
|
# @return string |
|
# @retval generated html. |
|
# |
|
sub display_foils_html { |
|
my ($whichfoils, $target, $direction, $part, $solved, $show_answer) = @_; |
|
my $result; |
|
|
|
# if the answers get shown, we need to label each item as correct or |
|
# incorrect. |
|
|
|
if ($show_answer) { |
|
my $item_pretext = '<br />'; # html prior to each item |
|
my $item_posttext = ''; # html after each item. |
|
my $finalclose = ''; # html to close off the whole shebang |
|
|
|
|
|
# Horizontal layout is a table with each foil in a cell |
|
|
|
if ($direction eq 'horizontal') { |
|
$result = '<table><tr>'; |
|
$item_pretext = '<td>' . $item_pretext; |
|
$item_posttext = '</td>'; |
|
$finalclose = '</tr></table>'; |
|
} |
|
|
|
foreach my $name (@{$whichfoils}) { |
|
|
|
# If the item gets further surrounded by tags, this |
|
# holds the closures for those tages. |
|
|
|
my $item_closetag = ''; |
|
|
|
$result .= $item_pretext; |
|
|
|
# Label each foil as correct or incorrect: |
|
|
|
if ($Apache::response::foilgroup{$name . '.value'} eq 'true') { |
|
$result .= &mt('Correct:') . '<b>'; |
|
$item_closetag .= '</b>'; |
|
|
|
} else { |
|
$result .= &mt('Incorrect'); |
|
} |
|
|
|
# Web rendition encloses the |
|
# item text in a label tag as well: |
|
|
|
if ($target eq 'web') { |
|
$result .= '<label>'; |
|
$item_closetag = '</label>' . $item_closetag; |
|
} |
|
$result .= $Apache::response::foilgroup{$name . '.text'}; |
|
$result .= $item_closetag; |
|
$result .= $item_posttext; |
|
$result .= "\n"; # make the html a bit more readable. |
|
} |
|
|
|
$result .= $finalclose; |
|
|
|
} else { |
|
# Not showing the answers, we need to generate the HTML appropriate |
|
# to allowing the student to respond. |
|
|
|
|
|
} |
|
|
|
return $result; |
|
} |
|
|
|
|
|
## |
|
|
sub displayfoils { |
sub displayfoils { |
my ( $target, $answer, $whichfoils, $direction, $bubbles_per_line ) = @_; |
my ( $target, $answer, $whichfoils, $direction, $bubbles_per_line ) = @_; |
Line 777 sub displayfoils {
|
Line 892 sub displayfoils {
|
if ( ( $target ne 'tex' ) |
if ( ( $target ne 'tex' ) |
&& &Apache::response::show_answer() ) |
&& &Apache::response::show_answer() ) |
{ |
{ |
if ( $direction eq 'horizontal' ) { |
|
if ( $target ne 'tex' ) { |
$result = &display_foils_html( |
$result .= '<table><tr>'; |
$whichfoils, $target, $direction, $part, $solved, 1); |
} |
|
} |
|
foreach my $name ( @{$whichfoils} ) { |
|
if ( $direction eq 'horizontal' ) { |
|
if ( $target ne 'tex' ) { $result .= '<td>'; } |
|
} |
|
if ( $target ne 'tex' ) { |
|
$result .= "<br />"; |
|
} |
|
else { |
|
$result .= '\item \vskip -2 mm '; |
|
} |
|
if ( $Apache::response::foilgroup{ $name . '.value' } eq 'true' ) { |
|
if ( $target ne 'tex' ) { |
|
$result .= &mt('Correct:') . '<b>'; |
|
} |
|
else { |
|
$result .= &mt('Correct:') . ' \textbf{'; |
|
} |
|
} |
|
else { |
|
$result .= &mt('Incorrect:'); |
|
} |
|
if ( $target eq 'web' ) { $result .= "<label>"; } |
|
$result .= $Apache::response::foilgroup{ $name . '.text' }; |
|
if ( $target eq 'web' ) { $result .= "</label>"; } |
|
if ( $Apache::response::foilgroup{ $name . '.value' } eq 'true' ) { |
|
if ( $target ne 'tex' ) { $result .= '</b>'; } |
|
else { $result .= '}'; } |
|
} |
|
if ( $direction eq 'horizontal' ) { |
|
if ( $target ne 'tex' ) { $result .= '</td>'; } |
|
} |
|
} |
|
if ( $direction eq 'horizontal' ) { |
|
if ( $target ne 'tex' ) { |
|
$result .= '</tr></table>'; |
|
} |
|
} |
|
} |
} |
else { |
else { |
my @alphabet = ( 'A' .. 'Z' ); |
my @alphabet = ( 'A' .. 'Z' ); |
Line 884 sub displayfoils {
|
Line 961 sub displayfoils {
|
$result .= '\item[\textbf{' . $Apache::lonxml::counter . '}.]'; |
$result .= '\item[\textbf{' . $Apache::lonxml::counter . '}.]'; |
} |
} |
} |
} |
|
my $item_pretext; |
|
my $item_posttext; |
|
if ( $target ne 'tex' ) { |
|
if ( $direction eq 'horizontal' ) { |
|
$item_pretext = '<td>'; |
|
$item_posttext = '</td>'; |
|
} |
|
else { |
|
$item_pretext = '<br/>'; |
|
} |
|
} |
foreach my $name ( @{$whichfoils} ) { |
foreach my $name ( @{$whichfoils} ) { |
|
|
if ( $target ne 'tex' ) { |
if ( $target ne 'tex' ) { |
if ( $direction eq 'horizontal' ) { |
$result .= $item_pretext; |
$result .= "<td>"; |
$result .= &html_radiobutton( |
} |
$part, $Apache::inputtags::response[-1], |
else { |
$name, $lastresponse, $temp |
$result .= "<br />"; |
); |
} |
$result .= $item_posttext; |
} |
|
if ( $target ne 'tex' ) { |
|
$result .= '<label>'; |
|
$result .= "<input type=\"radio\" |
|
onchange=\"javascript:setSubmittedPart('$part');\" |
|
name=\"HWVAL_$Apache::inputtags::response['-1']\" |
|
value=\"$temp\""; |
|
if ( defined( $lastresponse{$name} ) ) { |
|
$result .= ' checked="checked"'; |
|
} |
|
$result .= ' />' |
|
. $Apache::response::foilgroup{ $name . '.text' } |
|
. "</label>"; |
|
} |
} |
else { |
else { |
if ( $Apache::lonhomework::type eq 'exam' ) { |
if ( $Apache::lonhomework::type eq 'exam' ) { |
Line 951 sub displayfoils {
|
Line 1027 sub displayfoils {
|
} |
} |
} |
} |
} |
} |
if ( $target ne 'tex' && $direction eq 'horizontal' ) { |
|
$result .= "</td>"; |
|
} |
|
$temp++; |
$temp++; |
} |
} |
if ( $target ne 'tex' && $direction eq 'horizontal' ) { |
if ( $target ne 'tex' && $direction eq 'horizontal' ) { |
$result .= "</tr></table>"; |
$result .= "</tr></table>"; |
} |
} |
} |
} |
if ( $target ne 'tex' ) { |
if ( $target ne 'tex' |
if ( $direction ne 'horizontal' ) { $result .= "<br />"; } |
&& ( $direction ne 'horizontal' ) |
|
) { |
|
$result .= "<br />"; |
|
} |
|
if ($target eq 'tex') { |
|
$result .= '\vskip 0 mm '; |
} |
} |
else { $result .= '\vskip 0 mm '; } |
|
return $result; |
return $result; |
} |
} |
|
|