--- loncom/homework/radiobuttonresponse.pm 2010/06/14 02:08:28 1.146 +++ loncom/homework/radiobuttonresponse.pm 2012/01/20 13:26:34 1.154 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # mutliple choice style responses # -# $Id: radiobuttonresponse.pm,v 1.146 2010/06/14 02:08:28 raeburn Exp $ +# $Id: radiobuttonresponse.pm,v 1.154 2012/01/20 13:26:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -138,14 +138,10 @@ sub end_radiobuttonresponse { %Apache::response::foilgroup=(); sub start_foilgroup { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; - my $result; %Apache::response::foilgroup=(); $Apache::radiobuttonresponse::conceptgroup=0; - &Apache::response::pushrandomnumber(); - if ($target eq 'tex' && $Apache::lonhomework::type eq 'exam') { - $result.='\item[\textbf{'.$Apache::lonxml::counter.'}.]'; - } - return $result; + &Apache::response::pushrandomnumber(undef,$target); + return; } sub storesurvey { @@ -222,15 +218,10 @@ sub end_foilgroup { my $result; my $bubble_lines; - my $bubbles_per_line; my $answer_count; my $id = $Apache::inputtags::response['-1']; my $part = $Apache::inputtags::part; - $bubbles_per_line = - &Apache::response::get_response_param($Apache::inputtags::part."_$id", - 'numbubbles', - $default_bubbles_per_line); - + my $bubbles_per_line = &getbubblesnum($part,$id); if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') { @@ -260,7 +251,7 @@ sub end_foilgroup { $answer_count = scalar(@shown); if ($target eq 'web' || $target eq 'tex') { - $result=&displayfoils($target, + $result=&displayfoils($target, $answer, \@shown, $direction, $bubbles_per_line); @@ -295,6 +286,20 @@ sub end_foilgroup { return $result; } +sub getbubblesnum { + my ($part,$id) = @_; + my $bubbles_per_line; + my $default_numbubbles = $default_bubbles_per_line; + if (($env{'form.bubbles_per_row'} =~ /^\d+$/) && + ($env{'form.bubbles_per_row'} > 0)) { + $default_numbubbles = $env{'form.bubbles_per_row'}; + } + $bubbles_per_line = + &Apache::response::get_response_param($part."_$id",'numbubbles', + $default_numbubbles); + return $bubbles_per_line; +} + sub getfoilcounts { my @names; my $truecnt=0; @@ -336,14 +341,24 @@ sub displayallfoils { my $i =0; my $id=$Apache::inputtags::response['-1']; my $part=$Apache::inputtags::part; - my $lastresponse; - unless ((($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) && (defined($env{'form.grade_symb'}))) { + my ($lastresponse,$newvariation,$showanswer); + 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; + } + } + $showanswer = &Apache::response::show_answer(); + unless ((($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) && (defined($env{'form.grade_symb'})) || + ($newvariation && !$showanswer)) { $lastresponse = $Apache::lonhomework::history{"resource.$part.$id.submission"}; } if ($direction eq 'horizontal') { $result.='