[LON-CAPA-cvs] cvs: loncom /homework optionresponse.pm
raeburn
raeburn@source.lon-capa.org
Sun, 19 Dec 2010 00:52:00 -0000
raeburn Sun Dec 19 00:52:00 2010 EDT
Modified files:
/loncom/homework optionresponse.pm
Log:
- New Question Type - randomizetry
- Only set dropdown lists to selections last try when displaying options
for new try, if rndseed for last try is the same as for current try.
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.172 loncom/homework/optionresponse.pm:1.173
--- loncom/homework/optionresponse.pm:1.172 Sun Sep 5 20:46:58 2010
+++ loncom/homework/optionresponse.pm Sun Dec 19 00:52:00 2010
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.172 2010/09/05 20:46:58 www Exp $
+# $Id: optionresponse.pm,v 1.173 2010/12/19 00:52:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -103,7 +103,7 @@
my $result='';
%Apache::response::foilgroup=();
$Apache::optionresponse::conceptgroup=0;
- &Apache::response::pushrandomnumber();
+ &Apache::response::pushrandomnumber(undef,$target);
if ($target eq 'edit') {
my $optionlist="<option></option>\n";
my $option;
@@ -262,7 +262,9 @@
$Apache::lonhomework::results{"resource.$part.$id.submission"}=
$responsestr;
$Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=$gradestr;
-
+ if ($Apache::lonhomework::type eq 'randomizetry') {
+ $Apache::lonhomework::results{"resource.$part.$id.foilorder"} = &Apache::lonnet::array2str(@whichopt);
+ }
if (($Apache::lonhomework::type eq 'survey') ||
($Apache::lonhomework::type eq 'surveycred') ||
($Apache::lonhomework::type eq 'anonsurvey') ||
@@ -469,7 +471,19 @@
}
} else {
my $temp=1;
- my %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"});
+ my %lastresponse;
+ my $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::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"});
+ }
my $internal_counter=$Apache::lonxml::counter;
my $checkboxopt=&check_box_opt($target,$checkboxvalue,@opt);
if ($checkboxopt) {
@@ -610,9 +624,12 @@
}
if ($target eq 'web') {
- &Apache::response::setup_prior_tries_hash(\&Apache::rankresponse::format_prior_answer,
- [\@whichopt,
- 'submissiongrading']);
+ my $data = [\@whichopt,'submissiongrading'];
+ my $questiontype;
+ if ($Apache::lonhomework::type eq 'randomizetry') {
+ $questiontype = $Apache::lonhomework::type,
+ }
+ &Apache::response::setup_prior_tries_hash(\&Apache::rankresponse::format_prior_answer,$data,$questiontype);
}
if ($target ne 'tex') {