--- loncom/homework/optionresponse.pm 2012/11/30 11:45:50 1.188 +++ loncom/homework/optionresponse.pm 2013/07/19 18:24:21 1.191 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: optionresponse.pm,v 1.188 2012/11/30 11:45:50 foxr Exp $ +# $Id: optionresponse.pm,v 1.191 2013/07/19 18:24:21 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -499,8 +499,11 @@ sub check_for_invalid { sub displayfoils { my ($target,$max,$randomize,$TeXlayout,$checkboxvalue,$checkboxchoices, $tex_option_switch, $no_tfprompt, @opt)=@_; - if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;} - my @names = @{ $Apache::response::foilgroup{'names'} }; + my @names; + if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') { + @names = @{ $Apache::response::foilgroup{'names'} }; + } + unless (@names > 0) { return;} my @truelist; my @falselist; my $result; @@ -520,8 +523,15 @@ sub displayfoils { foreach $name (@whichopt) { my $text=$Apache::response::foilgroup{$name.'.text'}; my $lastresp; - unless ((($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) && (defined($env{'form.grade_symb'}))) { + if ((($env{'form.grade_username'} eq '') && ($env{'form.grade_domain'} eq '')) || + (($env{'form.grade_username'} eq $env{'user.name'}) && + ($env{'form.grade_domain'} eq $env{'user.domain'}))) { $lastresp = $Apache::lonhomework::history{"resource.$part.$id.submission"}; + } else { + unless (($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || + ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) { + $lastresp = $Apache::lonhomework::history{"resource.$part.$id.submission"}; + } } my %lastresponse=&Apache::lonnet::str2hash($lastresp); my $lastopt=$lastresponse{$name}; @@ -560,14 +570,25 @@ sub displayfoils { } } unless ($newvariation) { - %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"}); + if ((($env{'form.grade_username'} eq '') && ($env{'form.grade_domain'} eq '')) || + (($env{'form.grade_username'} eq $env{'user.name'}) && + ($env{'form.grade_domain'} eq $env{'user.domain'}))) { + %lastresponse = + &Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"}); + } else { + unless (($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || + ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) { + %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 && (!$no_tfprompt)) { $result.='
'. ($checkboxchoices?&mt('Choices: ').''.$opt[0].','.$opt[1].'. ':''). - &mt('Select all that are [_1].',$checkboxopt); + &mt('Select all that are [_1].',''.$checkboxopt.''); } foreach $name (@whichopt) { my $text=$Apache::response::foilgroup{$name.'.text'};