--- loncom/homework/radiobuttonresponse.pm 2012/01/21 21:40:41 1.153.6.3 +++ 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.6.3 2012/01/21 21:40:41 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,6 +31,7 @@ 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. @@ -121,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"; @@ -143,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', @@ -262,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' @@ -390,21 +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 ( ( ( @@ -422,7 +412,6 @@ sub displayallfoils { $newvariation = 1; } } - $showanswer = &Apache::response::show_answer(); unless ( ( ( @@ -439,122 +428,262 @@ sub displayallfoils { $lastresponse = $Apache::lonhomework::history{"resource.$part.$id.submission"}; } - if ( $direction eq 'horizontal' ) { $result .= '