--- loncom/homework/radiobuttonresponse.pm 2012/01/05 11:56:34 1.153 +++ loncom/homework/radiobuttonresponse.pm 2012/02/04 20:40:07 1.153.6.9 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # mutliple choice style responses # -# $Id: radiobuttonresponse.pm,v 1.153 2012/01/05 11:56:34 foxr Exp $ +# $Id: radiobuttonresponse.pm,v 1.153.6.9 2012/02/04 20:40:07 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,8 +31,12 @@ use HTML::Entities(); use Apache::lonlocal; use Apache::lonnet; use Apache::response; +use Apache::caparesponse; my $default_bubbles_per_line = 10; +my @alphabet = ( 'A' .. 'Z' ); # Foil labels. + + BEGIN { &Apache::lonxml::register( 'Apache::radiobuttonresponse', @@ -118,14 +122,7 @@ sub start_radiobuttonresponse { else { $result .= ' \renewcommand{\labelenumi}{\Alph{enumi}.}'; } - if ( $env{'form.pdfFormFields'} eq 'yes' - && $Apache::inputtags::status[-1] eq 'CAN_ANSWER' ) - { - $result .= '\begin{itemize}'; - } - else { - $result .= '\begin{enumerate}'; - } + } elsif ( $target eq 'analyze' ) { my $part_id = "$Apache::inputtags::part.$id"; @@ -140,16 +137,7 @@ sub end_radiobuttonresponse { @_; my $result; if ( $target eq 'edit' ) { $result = &Apache::edit::end_table(); } - if ( $target eq 'tex' ) { - if ( $env{'form.pdfFormFields'} eq 'yes' - and $Apache::inputtags::status[-1] eq 'CAN_ANSWER' ) - { - $result .= '\end{itemize}'; - } - else { - $result .= '\end{enumerate}'; - } - } + &Apache::response::end_response; pop @Apache::lonxml::namespace; &Apache::lonxml::deregister( 'Apache::radiobuttonresponse', @@ -259,6 +247,7 @@ sub end_foilgroup { my $part = $Apache::inputtags::part; my $bubbles_per_line = &getbubblesnum( $part, $id ); + if ( $target eq 'grade' || $target eq 'web' || $target eq 'answer' @@ -387,20 +376,25 @@ sub format_prior_answer { } -sub displayallfoils { - my ( $direction, $target ) = @_; - my $result; - &Apache::lonxml::debug("survey style display"); - my @names; - if ( $Apache::response::foilgroup{'names'} ) { - @names = @{ $Apache::response::foilgroup{'names'} }; - } +## +# Return the last survey response. The logic is slightly different than that of +# get_last_responses. TODO: See if there are chunks of code betweenthis and +# get_last_reponses that are common and can be factored. +# +# @param $part - Problem part under consideration. +# @param $showanswer - True if answers should be shown. +# @param $id - Problem id. +# +# @return hash reference. +# @retval reference to the has indexed by answer selection that +# indicates the most recent answer. +# +sub get_last_survey_response { + my ($part, $showanswer, $id) = @_; + + my $newvariation; + my $lastresponse; # stringified last response. - my $temp = 0; - my $i = 0; - my $id = $Apache::inputtags::response['-1']; - my $part = $Apache::inputtags::part; - my ( $lastresponse, $newvariation, $showanswer ); if ( ( ( @@ -418,7 +412,6 @@ sub displayallfoils { $newvariation = 1; } } - $showanswer = &Apache::response::show_answer(); unless ( ( ( @@ -435,122 +428,262 @@ sub displayallfoils { $lastresponse = $Apache::lonhomework::history{"resource.$part.$id.submission"}; } - if ( $direction eq 'horizontal' ) { $result .= '
' . $item_pretext; + $item_posttext = ' | '; + $finalclose = '
'; }
- }
- if ( $target ne 'tex' ) {
- $result .= " "; - } - else { - $result .= '\item \vskip -2 mm '; - } - if ( $Apache::response::foilgroup{ $name . '.value' } eq 'true' ) { - if ( $target ne 'tex' ) { - $result .= &mt('Correct:') . ''; - } - else { - $result .= &mt('Correct:') . ' \textbf{'; - } - } - else { - $result .= &mt('Incorrect:'); - } - if ( $target eq 'web' ) { $result .= ""; } - if ( $Apache::response::foilgroup{ $name . '.value' } eq 'true' ) { - if ( $target ne 'tex' ) { $result .= ''; } - else { $result .= '}'; } - } - if ( $direction eq 'horizontal' ) { - if ( $target ne 'tex' ) { $result .= ' | '; }
- }
- }
- if ( $direction eq 'horizontal' ) {
- if ( $target ne 'tex' ) {
- $result .= '
";
- }
- else {
- $result .= " "; - } - } - if ( $target ne 'tex' ) { - $result .= ' | ";
- }
- $temp++;
- }
- if ( $target ne 'tex' && $direction eq 'horizontal' ) {
- $result .= "