version 1.83, 2011/10/07 22:39:59
|
version 1.85, 2011/11/29 13:24:38
|
Line 30 package Apache::matchresponse;
|
Line 30 package Apache::matchresponse;
|
use strict; |
use strict; |
use HTML::Entities(); |
use HTML::Entities(); |
use Math::Random(); |
use Math::Random(); |
|
use Apache::inputtags(); |
use Apache::optionresponse(); |
use Apache::optionresponse(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
Line 131 sub end_itemgroup {
|
Line 132 sub end_itemgroup {
|
my $result; |
my $result; |
|
|
if ($target eq 'edit') { $result=&Apache::edit::end_table(); } |
if ($target eq 'edit') { $result=&Apache::edit::end_table(); } |
if (!defined(@{ $Apache::response::itemgroup{'names'} })) { return; } |
if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') { |
|
if(!@{ $Apache::response::itemgroup{'names'} }) { return; } |
|
} else { |
|
return; |
|
} |
my @names=@{ $Apache::response::itemgroup{'names'} }; |
my @names=@{ $Apache::response::itemgroup{'names'} }; |
my $randomize =&Apache::lonxml::get_param('randomize',$parstack,$safeeval); |
my $randomize =&Apache::lonxml::get_param('randomize',$parstack,$safeeval); |
if ($randomize ne 'no' ) { |
if ($randomize ne 'no' ) { |
Line 345 sub whichfoils {
|
Line 350 sub whichfoils {
|
|
|
sub displayanswers { |
sub displayanswers { |
my ($max,$randomize,@opt)=@_; |
my ($max,$randomize,@opt)=@_; |
if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; } |
if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') { |
|
if (!@{ $Apache::response::foilgroup{'names'} }) { return; } |
|
} else { |
|
return; |
|
} |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @whichfoils = &Apache::response::whichorder(&getfoilcounts($max), |
my @whichfoils = &Apache::response::whichorder(&getfoilcounts($max), |
$randomize, |
$randomize, |
&Apache::response::showallfoils(), |
&Apache::response::showallfoils(), |
\%Apache::response::foilgroup); |
\%Apache::response::foilgroup); |
my %name_letter_map; |
my %name_letter_map; |
if (defined(%{ $Apache::response::itemgroup{'name_letter_map'} })) { |
if (ref($Apache::response::itemgroup{'name_letter_map'}) eq 'HASH') { |
%name_letter_map= |
if (%{$Apache::response::itemgroup{'name_letter_map'}}) { |
%{ $Apache::response::itemgroup{'name_letter_map'} }; |
%name_letter_map= |
|
%{ $Apache::response::itemgroup{'name_letter_map'} }; |
|
} |
} |
} |
my $result; |
my $result; |
if ($Apache::lonhomework::type eq 'exam') { |
if ($Apache::lonhomework::type eq 'exam') { |
Line 391 sub grade_response {
|
Line 402 sub grade_response {
|
my %answerhash; |
my %answerhash; |
my ($temp,$right,$wrong,$ignored)=(1,0,0,0); |
my ($temp,$right,$wrong,$ignored)=(1,0,0,0); |
my %letter_name_map; |
my %letter_name_map; |
if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) { |
if (ref($Apache::response::itemgroup{'letter_name_map'}) eq 'HASH') { |
%letter_name_map= |
if (%{$Apache::response::itemgroup{'letter_name_map'}}) { |
%{ $Apache::response::itemgroup{'letter_name_map'} }; |
%letter_name_map= |
|
%{ $Apache::response::itemgroup{'letter_name_map'} }; |
|
} |
} |
} |
my @items; |
my @items; |
my $numitems = scalar(@{ $Apache::response::itemgroup{'names'} }); |
my $numitems = scalar(@{ $Apache::response::itemgroup{'names'} }); |
Line 450 sub grade_response {
|
Line 463 sub grade_response {
|
} |
} |
} |
} |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
my $nonlenient=&Apache::optionresponse::is_nonlenient($part); |
my $nonlenient=&Apache::inputtags::grading_is_nonlenient($part); |
my $id = $Apache::inputtags::response['-1']; |
my $id = $Apache::inputtags::response['-1']; |
my $responsestr=&Apache::lonnet::hash2str(%responsehash); |
my $responsestr=&Apache::lonnet::hash2str(%responsehash); |
my $itemstr =&Apache::lonnet::array2str(@items); |
my $itemstr =&Apache::lonnet::array2str(@items); |
Line 564 sub displayfoils {
|
Line 577 sub displayfoils {
|
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
my $solved=$Apache::lonhomework::history{"resource.$part.solved"}; |
my $solved=$Apache::lonhomework::history{"resource.$part.solved"}; |
my %letter_name_map; |
my %letter_name_map; |
if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) { |
if (ref($Apache::response::itemgroup{'letter_name_map'}) eq 'HASH') { |
%letter_name_map= |
if (%{$Apache::response::itemgroup{'letter_name_map'}}) { |
%{ $Apache::response::itemgroup{'letter_name_map'} }; |
%letter_name_map= |
|
%{ $Apache::response::itemgroup{'letter_name_map'} }; |
|
} |
} |
} |
my %name_letter_map; |
my %name_letter_map; |
if (defined(%{ $Apache::response::itemgroup{'name_letter_map'} })) { |
if (ref($Apache::response::itemgroup{'name_letter_map'}) eq 'HASH') { |
%name_letter_map= |
if (%{$Apache::response::itemgroup{'name_letter_map'}}) { |
%{ $Apache::response::itemgroup{'name_letter_map'} }; |
%name_letter_map= |
|
%{ $Apache::response::itemgroup{'name_letter_map'} }; |
|
} |
} |
} |
if ( &Apache::response::show_answer() && ($target ne 'tex')) { |
if ( &Apache::response::show_answer() && ($target ne 'tex')) { |
foreach my $name (@whichfoils) { |
foreach my $name (@whichfoils) { |
Line 835 sub start_foil {
|
Line 852 sub start_foil {
|
if ($$tagstack[-2] eq 'conceptgroup') { $level = '-3'; } |
if ($$tagstack[-2] eq 'conceptgroup') { $level = '-3'; } |
$result.=&Apache::edit::text_arg('Name:','name',$token); |
$result.=&Apache::edit::text_arg('Name:','name',$token); |
my @names; |
my @names; |
if (defined(@{ $Apache::response::itemgroup{'names'} })) { |
if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') { |
@names=@{ $Apache::response::itemgroup{'names'} }; |
if (@{ $Apache::response::itemgroup{'names'} }) { |
|
@names=@{ $Apache::response::itemgroup{'names'} }; |
|
} |
} |
} |
$result.= &Apache::edit::select_or_text_arg('Correct Option:','value',['unused',@names],$token,'15'); |
$result.= &Apache::edit::select_or_text_arg('Correct Option:','value',['unused',@names],$token,'15'); |
my $randomize=&Apache::lonxml::get_param('randomize',$parstack, |
my $randomize=&Apache::lonxml::get_param('randomize',$parstack, |