--- loncom/homework/matchresponse.pm 2012/12/29 01:21:10 1.87 +++ loncom/homework/matchresponse.pm 2014/05/05 17:40:54 1.91 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Full matching style response # -# $Id: matchresponse.pm,v 1.87 2012/12/29 01:21:10 raeburn Exp $ +# $Id: matchresponse.pm,v 1.91 2014/05/05 17:40:54 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -104,15 +104,15 @@ sub start_itemgroup { if ($target eq 'edit') { $result=&Apache::edit::tag_start($target,$token); $result.=&Apache::edit::select_arg('Randomize Order:','randomize', - ['yes','no'],$token).' 'x 3; + ['yes','no'],$token); $result.=&Apache::edit::select_arg('Items Display Location:', 'location', ['top','bottom','left','right'], - $token).' 'x 3; + $token); $result.=&Apache::edit::select_arg('Items Display Direction:', 'direction', ['vertical','horizontal'], - $token).' 'x 3; + $token); $result.=&Apache::edit::select_arg('Items Columns:', 'columns', [['','default'],'1','2','3','4'], @@ -262,7 +262,7 @@ sub start_item { $result=&Apache::edit::tag_start($target,$token,"Item"); $result.=&Apache::edit::text_arg('Name:','name',$token); if ($randomize ne 'no') { - $result.=' 'x 3 . + $result.= &Apache::edit::select_arg('Location:','location', ['random','top','bottom'], $token); @@ -580,7 +580,10 @@ sub format_prior_answer { my $output; foreach my $name (@{ $foil_order }) { - my $item=shift(@items); + my $item = &HTML::Entities::encode(shift(@items),'<>&"'); + if ($item eq '') { + $item = ' '; + } $output .= ''.$item.''; } return if (!defined($output)); @@ -652,9 +655,19 @@ sub displayfoils { $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"}; + unless ($newvariation) { + 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::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::lonhomework::history{"resource.$part.$id.submission"}; + } + } } + my %lastresponse=&Apache::lonnet::str2hash($lastresponse); my @alphabet=('A'..'Z'); my @used_letters=sort(keys(%letter_name_map));