version 1.85, 2007/09/25 23:16:13
|
version 1.88, 2007/09/25 23:58:32
|
Line 62 sub start_imageresponse {
|
Line 62 sub start_imageresponse {
|
push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id); |
push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id); |
push (@{ $Apache::lonhomework::analyze{"$part_id.bubble_lines"} }, |
push (@{ $Apache::lonhomework::analyze{"$part_id.bubble_lines"} }, |
1); |
1); |
|
} elsif ( $target eq 'edit' ) { |
|
$result .= &Apache::edit::tag_start($target,$token). |
|
&Apache::edit::text_arg('Max Number Of Shown Foils:', |
|
'max',$token,'4'). |
|
&Apache::edit::end_row(). |
|
&Apache::edit::start_spanning_row(); |
|
} elsif ( $target eq 'modified' ) { |
|
my $constructtag= |
|
&Apache::edit::get_new_args($token,$parstack,$safeeval,'max'); |
|
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
} |
} |
return $result; |
return $result; |
} |
} |
Line 105 sub getfoilcounts {
|
Line 115 sub getfoilcounts {
|
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2'); |
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2'); |
# +1 since instructors will count from 1 |
# +1 since instructors will count from 1 |
my $count = $#{ $Apache::response::foilgroup{'names'} }+1; |
my $count = $#{ $Apache::response::foilgroup{'names'} }+1; |
#if (&Apache::response::showallfoils()) { $max=$count; } |
if (&Apache::response::showallfoils()) { $max=$count; } |
return ($count,$max); |
return ($count,$max); |
} |
} |
|
|
sub whichfoils { |
sub whichfoils { |
my ($max)=@_; |
my ($max)=@_; |
if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; } |
return if (!defined(@{ $Apache::response::foilgroup{'names'} })); |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @whichopt =(); |
my @whichopt; |
while ((($#whichopt+1) < $max) && ($#names > -1)) { |
while ((($#whichopt+1) < $max) && ($#names > -1)) { |
&Apache::lonxml::debug("Have $#whichopt max is $max"); |
&Apache::lonxml::debug("Have $#whichopt max is $max"); |
my $aopt; |
my $aopt; |
# if (&Apache::response::showallfoils()) { |
if (&Apache::response::showallfoils()) { |
# $aopt=0; |
$aopt=0; |
# } else { |
} else { |
$aopt=int(&Math::Random::random_uniform() * ($#names+1)); |
$aopt=int(&Math::Random::random_uniform() * ($#names+1)); |
# } |
} |
&Apache::lonxml::debug("From $#names elms, picking $aopt"); |
&Apache::lonxml::debug("From $#names elms, picking $aopt"); |
$aopt=splice(@names,$aopt,1); |
$aopt=splice(@names,$aopt,1); |
&Apache::lonxml::debug("Picked $aopt"); |
&Apache::lonxml::debug("Picked $aopt"); |
push (@whichopt,$aopt); |
push(@whichopt,$aopt); |
} |
} |
return @whichopt; |
return @whichopt; |
} |
} |
Line 237 sub displayfoils {
|
Line 247 sub displayfoils {
|
} else { |
} else { |
my $respid=$Apache::inputtags::response['-1']; |
my $respid=$Apache::inputtags::response['-1']; |
my $token=&prep_image($image,'submission',$name); |
my $token=&prep_image($image,'submission',$name); |
my $id = "HWVAL_$respid:$temp"; |
my $input_id = "HWVAL_$respid:$temp"; |
|
my $id = $env{'form.request.prefix'}.$input_id; |
$result.='<img onclick="image_response_click(\''.$id.'\',event);" |
$result.='<img onclick="image_response_click(\''.$id.'\',event);" |
src="/adm/randomlabel.png?token='.$token.'" |
src="/adm/randomlabel.png?token='.$token.'" |
id="imageresponse_'.$id.'" |
id="'.$id.'_imageresponse" |
/>'. |
/>'. |
'<br />'. |
'<br />'. |
'<input type="hidden" name="token_'.$id.'" value="'.$token.'" />'. |
'<input type="hidden" name="'.$input_id.'_token" value="'.$token.'" />'. |
'<input type="hidden" name="'.$id.'" value="'. |
'<input type="hidden" name="'.$input_id.'" value="'. |
join(':',&get_submission($name)).'" />'; |
join(':',&get_submission($name)).'" />'; |
} |
} |
} |
} |
Line 279 sub format_prior_response {
|
Line 290 sub format_prior_response {
|
sub display_answers { |
sub display_answers { |
my ($target,$whichopt)=@_; |
my ($target,$whichopt)=@_; |
|
|
my $result; |
my $result=&Apache::response::answer_header('imageresponse'); |
foreach my $name (@$whichopt) { |
foreach my $name (@$whichopt) { |
my $image=$Apache::response::foilgroup{"$name.image"}; |
my $image=$Apache::response::foilgroup{"$name.image"}; |
&Apache::lonxml::debug("image is $image"); |
&Apache::lonxml::debug("image is $image"); |
Line 288 sub display_answers {
|
Line 299 sub display_answers {
|
} |
} |
my $token=&prep_image($image,'answeronly',$name); |
my $token=&prep_image($image,'answeronly',$name); |
|
|
$result.=&Apache::response::answer_header('imageresponse'); |
|
$result.=&Apache::response::answer_part('imageresponse',"<img src=\"/adm/randomlabel.png?token=$token\" /><br />\n"); |
$result.=&Apache::response::answer_part('imageresponse',"<img src=\"/adm/randomlabel.png?token=$token\" /><br />\n"); |
$result.=&Apache::response::answer_footer('imageresponse'); |
|
} |
} |
|
$result.=&Apache::response::answer_footer('imageresponse'); |
return $result; |
return $result; |
} |
} |
|
|
Line 376 sub gradefoils {
|
Line 386 sub gradefoils {
|
|
|
sub stringify_submission { |
sub stringify_submission { |
my ($response) = @_; |
my ($response) = @_; |
return |
return &Apache::lonnet::hash2str(%{ $response }); |
join("\0",map {$_."\1".$response->{$_}} (sort(keys(%{ $response })))); |
|
|
|
} |
} |
|
|
Line 391 sub get_submission {
|
Line 401 sub get_submission {
|
$Apache::lonhomework::history{"resource.$part.$respid.submission"}; |
$Apache::lonhomework::history{"resource.$part.$respid.submission"}; |
} |
} |
|
|
if ($string !~ /\0/) { |
if ($string !~ /=/) { |
return split(':',$string); |
return split(':',$string); |
} else { |
} else { |
my %response = map { split("\1",$_,2) } (split("\0",$string)); |
my %response = &Apache::lonnet::str2hash($string); |
return split(':',$response{$name}); |
return split(':',$response{$name}); |
} |
} |
} |
} |
Line 481 sub start_foil {
|
Line 491 sub start_foil {
|
} |
} |
$Apache::response::foilnames{$name}++; |
$Apache::response::foilnames{$name}++; |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
#&& !&Apache::response::showallfoils() |
&& !&Apache::response::showallfoils() |
) { |
) { |
push(@{ $Apache::response::conceptgroup{'names'} }, $name); |
push(@{ $Apache::response::conceptgroup{'names'} }, $name); |
} else { |
} else { |
Line 534 sub end_text {
|
Line 544 sub end_text {
|
|| $target eq 'answer') { |
|| $target eq 'answer') { |
my $name = $Apache::imageresponse::curname; |
my $name = $Apache::imageresponse::curname; |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
#&& !&Apache::response::showallfoils() |
&& !&Apache::response::showallfoils() |
) { |
) { |
$Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection; |
$Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection; |
} else { |
} else { |
Line 577 sub end_image {
|
Line 587 sub end_image {
|
my $image = &Apache::lonxml::endredirection(); |
my $image = &Apache::lonxml::endredirection(); |
&Apache::lonxml::debug("original image is $image"); |
&Apache::lonxml::debug("original image is $image"); |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
#&& !&Apache::response::showallfoils() |
&& !&Apache::response::showallfoils() |
) { |
) { |
$Apache::response::conceptgroup{"$name.image"} = $image; |
$Apache::response::conceptgroup{"$name.image"} = $image; |
} else { |
} else { |
Line 586 sub end_image {
|
Line 596 sub end_image {
|
} elsif ($target eq 'analyze') { |
} elsif ($target eq 'analyze') { |
my $image = &Apache::lonxml::endredirection(); |
my $image = &Apache::lonxml::endredirection(); |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
#&& !&Apache::response::showallfoils() |
&& !&Apache::response::showallfoils() |
) { |
) { |
$Apache::response::conceptgroup{"$name.image"} = $image; |
$Apache::response::conceptgroup{"$name.image"} = $image; |
} else { |
} else { |
Line 666 sub end_rectangle {
|
Line 676 sub end_rectangle {
|
$area=~s/\s//g; |
$area=~s/\s//g; |
&Apache::lonxml::debug("out is $area for $name"); |
&Apache::lonxml::debug("out is $area for $name"); |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
#&& !&Apache::response::showallfoils() |
&& !&Apache::response::showallfoils() |
) { |
) { |
push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area"; |
push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area"; |
} else { |
} else { |
Line 747 sub end_polygon {
|
Line 757 sub end_polygon {
|
$area=~s/\s*//g; |
$area=~s/\s*//g; |
&Apache::lonxml::debug("out is $area for $name"); |
&Apache::lonxml::debug("out is $area for $name"); |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
#&& !&Apache::response::showallfoils() |
&& !&Apache::response::showallfoils() |
) { |
) { |
push @{ $Apache::response::conceptgroup{"$name.area"} },"polygon:$area"; |
push @{ $Apache::response::conceptgroup{"$name.area"} },"polygon:$area"; |
} else { |
} else { |