version 1.36, 2003/09/24 19:20:58
|
version 1.38, 2003/10/27 20:04:34
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# July,August 2003 H. K. Ng |
|
# |
|
#FIXME LATER assumes multiple possible submissions but only one is possible |
#FIXME LATER assumes multiple possible submissions but only one is possible |
#currently |
#currently |
|
|
Line 49 sub start_imageresponse {
|
Line 47 sub start_imageresponse {
|
my $id = &Apache::response::start_response($parstack,$safeeval); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
if ($target eq 'meta') { |
if ($target eq 'meta') { |
$result=&Apache::response::meta_package_write('imageresponse'); |
$result=&Apache::response::meta_package_write('imageresponse'); |
|
} elsif ($target eq 'analyze') { |
|
my $part_id="$Apache::inputtags::part.$id"; |
|
push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id); |
} |
} |
return $result; |
return $result; |
} |
} |
Line 174 sub end_foilgroup {
|
Line 175 sub end_foilgroup {
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |
my @whichopt; |
my @whichopt; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || |
|
$target eq 'analyze') { |
my ($count,$max) = &getfoilcounts($parstack,$safeeval); |
my ($count,$max) = &getfoilcounts($parstack,$safeeval); |
if ($count>$max) { $count=$max } |
if ($count>$max) { $count=$max } |
&Apache::lonxml::debug("Count is $count from $max"); |
&Apache::lonxml::debug("Count is $count from $max"); |
Line 183 sub end_foilgroup {
|
Line 185 sub end_foilgroup {
|
$result=&displayfoils($target,@whichopt); |
$result=&displayfoils($target,@whichopt); |
} elsif ($target eq 'grade') { |
} elsif ($target eq 'grade') { |
if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); } |
if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); } |
} |
} elsif ( $target eq 'analyze') { |
|
&Apache::response::analyze_store_foilgroup(\@whichopt, |
|
['text','image','area']); |
|
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result=&Apache::edit::end_table(); |
$result=&Apache::edit::end_table(); |
} |
} |
Line 200 sub end_conceptgroup {
|
Line 205 sub end_conceptgroup {
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
$Apache::imageresponse::conceptgroup=0; |
$Apache::imageresponse::conceptgroup=0; |
my $result; |
my $result; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || |
if (defined(@{ $Apache::response::conceptgroup{'names'} })) { |
$target eq 'analyze') { |
my @names = @{ $Apache::response::conceptgroup{'names'} }; |
&Apache::response::pick_foil_for_concept($target, |
my $pick=int(&Math::Random::random_uniform() * ($#names+1)); |
['area','text','image'], |
my $name=$names[$pick]; |
\%Apache::hint::image, |
if (defined(@{ $Apache::response::conceptgroup{"$name.area"} })) { |
$parstack,$safeeval); |
push @{ $Apache::response::foilgroup{'names'} }, $name; |
|
$Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"}; |
|
$Apache::response::foilgroup{"$name.image"} = $Apache::response::conceptgroup{"$name.image"}; |
|
push(@{ $Apache::response::foilgroup{"$name.area"} }, @{ $Apache::response::conceptgroup{"$name.area"} }); |
|
my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval); |
|
$Apache::response::foilgroup{"$name.concept"} = $concept; |
|
&Apache::lonxml::debug("Selecting $name in $concept"); |
|
} |
|
} |
|
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result=&Apache::edit::end_table(); |
$result=&Apache::edit::end_table(); |
} |
} |
Line 234 sub insert_foil {
|
Line 230 sub insert_foil {
|
$Apache::imageresponse::curname=''; |
$Apache::imageresponse::curname=''; |
sub start_foil { |
sub start_foil { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || |
|
$target eq 'analyze') { |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
if ($name eq '') { $name=$Apache::lonxml::curdepth; } |
if ($name eq '') { $name=$Apache::lonxml::curdepth; } |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
Line 260 sub end_foil {
|
Line 257 sub end_foil {
|
sub start_text { |
sub start_text { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |
if ($target eq 'web' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { |
&Apache::lonxml::startredirection; |
&Apache::lonxml::startredirection; |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
my $descr=&Apache::lonxml::get_all_text('/text',$parser); |
my $descr=&Apache::lonxml::get_all_text('/text',$parser); |
Line 278 sub start_text {
|
Line 275 sub start_text {
|
sub end_text { |
sub end_text { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result; |
my $result; |
if ($target eq 'web' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { |
my $name = $Apache::imageresponse::curname; |
my $name = $Apache::imageresponse::curname; |
if ( $Apache::imageresponse::conceptgroup |
if ( $Apache::imageresponse::conceptgroup |
&& !&Apache::response::showallfoils() ) { |
&& !&Apache::response::showallfoils() ) { |
Line 295 sub end_text {
|
Line 292 sub end_text {
|
sub start_image { |
sub start_image { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |
if ($target eq 'web' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { |
&Apache::lonxml::startredirection; |
&Apache::lonxml::startredirection; |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
my $bgimg=&Apache::lonxml::get_all_text('/image',$parser); |
my $bgimg=&Apache::lonxml::get_all_text('/image',$parser); |
Line 358 sub end_image {
|
Line 355 sub end_image {
|
} else { |
} else { |
$Apache::response::foilgroup{"$name.image"} = $image; |
$Apache::response::foilgroup{"$name.image"} = $image; |
} |
} |
|
} elsif ($target eq 'analyze') { |
|
my $image = &Apache::lonxml::endredirection; |
|
if ( $Apache::imageresponse::conceptgroup |
|
&& !&Apache::response::showallfoils()) { |
|
$Apache::response::conceptgroup{"$name.image"} = $image; |
|
} else { |
|
$Apache::response::foilgroup{"$name.image"} = $image; |
|
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result=&Apache::edit::end_table(); |
$result=&Apache::edit::end_table(); |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
Line 439 sub end_image {
|
Line 444 sub end_image {
|
sub start_rectangle { |
sub start_rectangle { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || |
|
$target eq 'analyze') { |
&Apache::lonxml::startredirection; |
&Apache::lonxml::startredirection; |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser); |
my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser); |
Line 475 sub grade_rectangle {
|
Line 481 sub grade_rectangle {
|
sub end_rectangle { |
sub end_rectangle { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result; |
my $result; |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || |
|
$target eq 'analyze') { |
my $name = $Apache::imageresponse::curname; |
my $name = $Apache::imageresponse::curname; |
my $area = &Apache::lonxml::endredirection; |
my $area = &Apache::lonxml::endredirection; |
&Apache::lonxml::debug("out is $area for $name"); |
&Apache::lonxml::debug("out is $area for $name"); |