--- loncom/homework/rankresponse.pm 2010/08/02 10:52:54 1.63 +++ loncom/homework/rankresponse.pm 2010/12/19 00:48:50 1.64 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # rank style response # -# $Id: rankresponse.pm,v 1.63 2010/08/02 10:52:54 foxr Exp $ +# $Id: rankresponse.pm,v 1.64 2010/12/19 00:48:50 raeburn Exp $ # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -96,7 +96,7 @@ sub start_foilgroup { my $result; %Apache::response::foilgroup=(); $Apache::rankresponse::conceptgroup=0; - &Apache::response::pushrandomnumber(); + &Apache::response::pushrandomnumber(undef,$target); return $result; } @@ -280,6 +280,11 @@ sub grade_response { } else { $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=$gradestr; } + if ($Apache::lonhomework::type eq 'randomizetry') { + if ($Apache::lonhomework::type eq 'randomizetry') { + $Apache::lonhomework::results{"resource.$part.$id.foilorder"} = &Apache::lonnet::array2str(@whichfoils); + } + } $Apache::lonhomework::results{"resource.$part.$id.submission"}= $responsestr; $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad; @@ -326,8 +331,16 @@ sub displayfoils { my $temp=1; 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); + 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 (((($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) && (defined($env{'form.grade_symb'}))) || $newvariation) { $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; } my %lastresponse=&Apache::lonnet::str2hash($lastresponse); @@ -350,7 +363,7 @@ sub displayfoils { foreach $option (@whichopt) { if ($option eq $lastopt) { if ($target ne 'tex' ) { - $optionlist.="\n"; + $optionlist.="\n"; } elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes') { $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option); } @@ -403,9 +416,14 @@ sub displayfoils { } } if ($target eq 'web') { + my $questiontype; + if ($Apache::lonhomework::type eq 'randomizetry') { + $questiontype = $Apache::lonhomework::type; + } &Apache::response::setup_prior_tries_hash(\&format_prior_answer, [\@whichfoils, - 'submissiongrading']); + 'submissiongrading'], + $questiontype); } if ($target ne 'tex') {$result.="
";} else {$result.=' \vskip 0 mm ';} return $result;