--- loncom/homework/radiobuttonresponse.pm 2012/01/20 11:41:31 1.153.6.1
+++ loncom/homework/radiobuttonresponse.pm 2012/01/21 21:40:41 1.153.6.3
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# mutliple choice style responses
#
-# $Id: radiobuttonresponse.pm,v 1.153.6.1 2012/01/20 11:41:31 foxr Exp $
+# $Id: radiobuttonresponse.pm,v 1.153.6.3 2012/01/21 21:40:41 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,9 @@ use Apache::lonnet;
use Apache::response;
my $default_bubbles_per_line = 10;
+my @alphabet = ( 'A' .. 'Z' ); # Foil labels.
+
+
BEGIN {
&Apache::lonxml::register( 'Apache::radiobuttonresponse',
@@ -769,7 +772,77 @@ sub whichfoils {
return ( $answer, @whichfalse );
}
##
-# Display foils in html rendition:
+# 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='';
+
+ return $result;
+
+}
+##
+# Return a reference to the last response hash. This hash has exactly
+# one or zero entries. The one entry is keyed by the foil 'name' of
+# the prior response
+#
+# @param $part - Number of the problem part.
+#
+# @return reference to a hash.
+# @retval see above.
+#
+sub get_last_response {
+ my ($part) = @_;
+
+ my $id = $Apache::inputtags::response['-1'];
+ my ( $lastresponse, $newvariation );
+
+ if ((( $Apache::lonhomework::history{"resource.$part.type"} eq 'randomizetry')
+ || ( $Apache::lonhomework::type eq 'randomizetry' )
+ )
+ && ( $Apache::inputtags::status[-1] eq 'CAN_ANSWER' )
+ )
+ {
+
+ if ( $env{ 'form.' . $part . '.rndseed' } ne
+ $Apache::lonhomework::history{"resource.$part.rndseed"} )
+ {
+ $newvariation = 1;
+ }
+ }
+ unless ($newvariation) {
+ $lastresponse =
+ $Apache::lonhomework::history{"resource.$part.$id.submission"};
+ }
+ my %lastresponse = &Apache::lonnet::str2hash($lastresponse);
+
+ return \%lastresponse;
+}
+
+##
+# Display foils in html rendition.:
#
# @param $whichfoils - Set of foils to display.
# @param $target - Rendition target...there are several html targets.
@@ -838,10 +911,38 @@ sub display_foils_html {
$result .= $finalclose;
} else {
+ $result .= '
'; # end line prior to foilgroup:
+
# Not showing the answers, we need to generate the HTML appropriate
# to allowing the student to respond.
+ my $item_pretext;
+ my $item_posttext;
+ my $lastresponse = &get_last_response($part);
+ if ( $direction eq 'horizontal' ) {
+ $item_pretext = '
'; }
-# }
-# 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 .= "