version 1.80, 2010/04/27 14:11:17
|
version 1.81.2.1, 2011/11/08 01:48:51
|
Line 131 sub end_itemgroup {
|
Line 131 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 252 sub start_foilgroup {
|
Line 256 sub start_foilgroup {
|
my $result; |
my $result; |
%Apache::response::foilgroup=(); |
%Apache::response::foilgroup=(); |
$Apache::matchresponse::conceptgroup=0; |
$Apache::matchresponse::conceptgroup=0; |
&Apache::response::pushrandomnumber(); |
&Apache::response::pushrandomnumber(undef,$target); |
if ($target eq 'edit') { |
if ($target eq 'edit') { |
$result.=&Apache::edit::start_table($token) |
$result.=&Apache::edit::start_table($token) |
.'<tr><td>'.&mt('Collection Of Foils').'</td>' |
.'<tr><td>'.&mt('Collection Of Foils').'</td>' |
Line 311 sub whichfoils {
|
Line 315 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 354 sub grade_response {
|
Line 364 sub grade_response {
|
if (!&Apache::response::submitted()) { return; } |
if (!&Apache::response::submitted()) { return; } |
my %responsehash; |
my %responsehash; |
my %grade; |
my %grade; |
|
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; |
foreach my $name (@whichfoils) { |
foreach my $name (@whichfoils) { |
Line 366 sub grade_response {
|
Line 379 sub grade_response {
|
push(@items,$response); |
push(@items,$response); |
my $responsename = $letter_name_map{$response}; |
my $responsename = $letter_name_map{$response}; |
my $value=$Apache::response::foilgroup{$name.'.value'}; |
my $value=$Apache::response::foilgroup{$name.'.value'}; |
|
if ($Apache::lonhomework::type eq 'randomizetry') { |
|
$answerhash{$name} = $value; |
|
} |
if ( $response =~ /[^\s]/) { |
if ( $response =~ /[^\s]/) { |
$responsehash{$name}=$responsename; |
$responsehash{$name}=$responsename; |
&Apache::lonxml::debug("submitted a $response($responsename) for $value<br />\n"); |
&Apache::lonxml::debug("submitted a $response($responsename) for $value<br />\n"); |
Line 392 sub grade_response {
|
Line 408 sub grade_response {
|
$itemstr; |
$itemstr; |
$Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}= |
$Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}= |
$gradestr; |
$gradestr; |
|
if ($Apache::lonhomework::type eq 'randomizetry') { |
|
$Apache::lonhomework::results{"resource.$part.$id.foilorder"} = &Apache::lonnet::array2str(@whichfoils); |
|
} |
if (($Apache::lonhomework::type eq 'survey') || |
if (($Apache::lonhomework::type eq 'survey') || |
($Apache::lonhomework::type eq 'surveycred') || |
($Apache::lonhomework::type eq 'surveycred') || |
($Apache::lonhomework::type eq 'anonsurvey') || |
($Apache::lonhomework::type eq 'anonsurvey') || |
Line 487 sub displayfoils {
|
Line 506 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 512 sub displayfoils {
|
Line 535 sub displayfoils {
|
my $temp=1; |
my $temp=1; |
my $id=$Apache::inputtags::response[-1]; |
my $id=$Apache::inputtags::response[-1]; |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
my $lastresponse; |
my ($lastresponse,$newvariation); |
unless ((($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) && (defined($env{'form.grade_symb'}))) { |
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"}; |
$lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; |
} |
} |
my %lastresponse=&Apache::lonnet::str2hash($lastresponse); |
my %lastresponse=&Apache::lonnet::str2hash($lastresponse); |
Line 542 sub displayfoils {
|
Line 573 sub displayfoils {
|
foreach $option (@used_letters) { |
foreach $option (@used_letters) { |
if ($option eq $last_letter) { |
if ($option eq $last_letter) { |
if ($target ne 'tex') { |
if ($target ne 'tex') { |
$optionlist.="<option selected=\"on\">$option</option>\n"; |
$optionlist.="<option selected=\"selected\">$option</option>\n"; |
} elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes' |
} elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes' |
&& $Apache::inputtags::status['-1'] eq 'CAN_ANSWER' |
&& $Apache::inputtags::status['-1'] eq 'CAN_ANSWER' |
&& $Apache::lonhomework::type ne 'exam') { |
&& $Apache::lonhomework::type ne 'exam') { |
Line 652 sub displayfoils {
|
Line 683 sub displayfoils {
|
} |
} |
} |
} |
if ($target eq 'web') { |
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, |
&Apache::response::setup_prior_tries_hash(\&format_prior_answer, |
[\@whichfoils, |
[\@whichfoils, |
'submissiongrading', |
'submissiongrading', |
'submissionitems']); |
'submissionitems'], |
|
$questiontype); |
} |
} |
if ($target ne 'tex') {$result.="<br />";} else {$result.=' \\\\ ';} |
if ($target ne 'tex') {$result.="<br />";} else {$result.=' \\\\ ';} |
return $result; |
return $result; |
Line 726 sub start_foil {
|
Line 762 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, |
$safeeval,'-3'); |
$safeeval,'-3'); |