[LON-CAPA-cvs] cvs: loncom /homework imageresponse.pm matchresponse.pm optionresponse.pm radiobuttonresponse.pm rankresponse.pm response.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 27 Oct 2003 19:27:09 -0000
This is a MIME encoded message
--albertel1067282829
Content-Type: text/plain
albertel Mon Oct 27 14:27:09 2003 EDT
Modified files:
/loncom/homework imageresponse.pm matchresponse.pm
optionresponse.pm radiobuttonresponse.pm
rankresponse.pm response.pm
Log:
- fixing up analyze mode for radiobutton/option/rank/match/image to all use the smae code
--albertel1067282829
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20031027142709.txt"
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.36 loncom/homework/imageresponse.pm:1.37
--- loncom/homework/imageresponse.pm:1.36 Wed Sep 24 15:20:58 2003
+++ loncom/homework/imageresponse.pm Mon Oct 27 14:27:09 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.36 2003/09/24 19:20:58 albertel Exp $
+# $Id: imageresponse.pm,v 1.37 2003/10/27 19:27:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,8 +25,6 @@
#
# http://www.lon-capa.org/
#
-# July,August 2003 H. K. Ng
-#
#FIXME LATER assumes multiple possible submissions but only one is possible
#currently
@@ -49,6 +47,9 @@
my $id = &Apache::response::start_response($parstack,$safeeval);
if ($target eq 'meta') {
$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;
}
@@ -183,7 +184,10 @@
$result=&displayfoils($target,@whichopt);
} elsif ($target eq 'grade') {
if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); }
- }
+ } elsif ( $target eq 'analyze') {
+ &Apache::response::analyze_store_foilgroup(\@whichopt,
+ ['text','image','area']);
+ }
} elsif ($target eq 'edit') {
$result=&Apache::edit::end_table();
}
@@ -200,21 +204,12 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
$Apache::imageresponse::conceptgroup=0;
my $result;
- if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') {
- if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
- my @names = @{ $Apache::response::conceptgroup{'names'} };
- my $pick=int(&Math::Random::random_uniform() * ($#names+1));
- my $name=$names[$pick];
- if (defined(@{ $Apache::response::conceptgroup{"$name.area"} })) {
- 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");
- }
- }
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' ||
+ $target eq 'analyze') {
+ &Apache::response::pick_foil_for_concept($target,
+ ['area','text','image'],
+ \%Apache::hint::image,
+ $parstack,$safeeval);
} elsif ($target eq 'edit') {
$result=&Apache::edit::end_table();
}
@@ -234,7 +229,8 @@
$Apache::imageresponse::curname='';
sub start_foil {
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);
if ($name eq '') { $name=$Apache::lonxml::curdepth; }
if ( $Apache::imageresponse::conceptgroup
@@ -260,7 +256,7 @@
sub start_text {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
&Apache::lonxml::startredirection;
} elsif ($target eq 'edit') {
my $descr=&Apache::lonxml::get_all_text('/text',$parser);
@@ -278,7 +274,7 @@
sub end_text {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
my $name = $Apache::imageresponse::curname;
if ( $Apache::imageresponse::conceptgroup
&& !&Apache::response::showallfoils() ) {
@@ -295,7 +291,7 @@
sub start_image {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
&Apache::lonxml::startredirection;
} elsif ($target eq 'edit') {
my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);
@@ -352,6 +348,14 @@
$image = $webImageName;
}
&Apache::lonxml::debug("out image is $image");
+ if ( $Apache::imageresponse::conceptgroup
+ && !&Apache::response::showallfoils()) {
+ $Apache::response::conceptgroup{"$name.image"} = $image;
+ } else {
+ $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;
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.27 loncom/homework/matchresponse.pm:1.28
--- loncom/homework/matchresponse.pm:1.27 Wed Oct 15 15:40:42 2003
+++ loncom/homework/matchresponse.pm Mon Oct 27 14:27:09 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.27 2003/10/15 19:40:42 albertel Exp $
+# $Id: matchresponse.pm,v 1.28 2003/10/27 19:27:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,7 +25,6 @@
#
# http://www.lon-capa.org/
#
-# 2/21 Guy
package Apache::matchresponse;
use strict;
@@ -66,6 +65,9 @@
$safeeval,'max',
'randomize');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
+ } elsif ($target eq 'analyze') {
+ my $part_id="$Apache::inputtags::part.$id";
+ push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
}
return $result;
}
@@ -236,7 +238,7 @@
sub end_foilgroup {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
- if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') {
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') {
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
$safeeval,'-2');
@@ -246,6 +248,11 @@
$result=&displayanswers($max,$randomize);
} elsif ( $target eq 'grade') {
&grade_response($max,$randomize);
+ } elsif ( $target eq 'analyze') {
+ my @shown=&whichfoils($max,$randomize);
+ &Apache::response::analyze_store_foilgroup(\@shown,
+ ['text','value']);
+ #FIXME need to store options in some way
}
&Apache::lonxml::increment_counter(&getfoilcounts($max));
} elsif ($target eq 'edit') {
@@ -486,31 +493,12 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
$Apache::matchresponse::conceptgroup=0;
my $result='';
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
- #if not there aren't any foils to display and thus no question
- if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
- my @names = @{ $Apache::response::conceptgroup{'names'} };
- my $pick=int(&Math::Random::random_uniform() * ($#names+1));
- my $name=$names[$pick];
- push @{ $Apache::response::foilgroup{'names'} }, $name;
- $Apache::response::foilgroup{"$name.value"} =
- $Apache::response::conceptgroup{"$name.value"};
- $Apache::response::foilgroup{"$name.text"} =
- $Apache::response::conceptgroup{"$name.text"};
- $Apache::response::foilgroup{"$name.location"} =
- $Apache::response::conceptgroup{"$name.location"};
- my $concept = &Apache::lonxml::get_param('concept',$parstack,
- $safeeval);
- $Apache::response::foilgroup{"$name.concept"} = $concept;
- &Apache::lonxml::debug("Selecting $name in $concept");
- if ($target eq 'web') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- push(@{ $Apache::hint::match{"$part_id.concepts"} },
- $concept);
- $Apache::hint::match{"$part_id.concept.$concept"}=
- $Apache::response::conceptgroup{'names'};
- }
- }
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
+ &Apache::response::pick_foil_for_concept($target,
+ ['value','text','location'],
+ \%Apache::hint::match,
+ $parstack,$safeeval);
} elsif ($target eq 'edit') {
$result=&Apache::edit::end_table();
}
@@ -525,7 +513,7 @@
sub start_foil {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
&Apache::lonxml::startredirection;
} elsif ($target eq 'edit') {
$result=&Apache::edit::tag_start($target,$token,"Foil");
@@ -557,10 +545,11 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $text ='';
my $result = '';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
$text=&Apache::lonxml::endredirection;
}
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
if ($value ne 'unused') {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.92 loncom/homework/optionresponse.pm:1.93
--- loncom/homework/optionresponse.pm:1.92 Fri Oct 24 14:07:04 2003
+++ loncom/homework/optionresponse.pm Mon Oct 27 14:27:09 2003
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.92 2003/10/24 18:07:04 sakharuk Exp $
+# $Id: optionresponse.pm,v 1.93 2003/10/27 19:27:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,8 +25,6 @@
#
# http://www.lon-capa.org/
#
-# 2/21 Guy
-# 01/18 Alex
package Apache::optionresponse;
use strict;
use Apache::response;
@@ -63,7 +61,7 @@
} elsif ($target eq 'meta') {
$result=&Apache::response::meta_package_write('optionresponse');
} elsif ($target eq 'analyze') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+ my $part_id="$Apache::inputtags::part.$id";
push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
}
return $result;
@@ -166,17 +164,10 @@
} elsif ( $target eq 'answer') {
$result.=&displayanswers($max,$randomize,@opt);
} elsif ( $target eq 'analyze') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- foreach my $name (@{ $Apache::response::foilgroup{'names'} }) {
- if (defined($Apache::lonhomework::analyze{"$part_id.foil.value.$name"})) { next; }
- push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },$name);
- $Apache::lonhomework::analyze{"$part_id.foil.value.$name"} =
- $Apache::response::foilgroup{"$name.value"};
- $Apache::lonhomework::analyze{"$part_id.foil.text.$name"} =
- $Apache::response::foilgroup{"$name.text"};
- }
- push (@{ $Apache::lonhomework::analyze{"$part_id.options"} },@opt);
- push (@{ $Apache::lonhomework::analyze{"$part_id.shown"} },&whichfoils($max,$randomize));
+ my @shown = &whichfoils($max,$randomize);
+ &Apache::response::analyze_store_foilgroup(\@shown,['text','value']);
+ my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+ push (@{ $Apache::lonhomework::analyze{"$part_id.options"} },@opt);
} elsif ( $target eq 'grade') {
if ( defined $ENV{'form.submitted'}) {
my @whichopt = &whichfoils($max,$randomize);
@@ -526,47 +517,13 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
$Apache::optionresponse::conceptgroup=0;
my $result='';
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'
- || $target eq 'tex' || $target eq 'analyze') {
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
#if not there aren't any foils to display and thus no question
- if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
- my @names = @{ $Apache::response::conceptgroup{'names'} };
- my $pick=int(&Math::Random::random_uniform() * ($#names+1));
- my $name=$names[$pick];
- push @{ $Apache::response::foilgroup{'names'} }, $name;
- $Apache::response::foilgroup{"$name.value"} =
- $Apache::response::conceptgroup{"$name.value"};
- $Apache::response::foilgroup{"$name.text"} =
- $Apache::response::conceptgroup{"$name.text"};
- $Apache::response::foilgroup{"$name.location"} =
- $Apache::response::conceptgroup{"$name.location"};
- my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);
- $Apache::response::foilgroup{"$name.concept"} = $concept;
- &Apache::lonxml::debug("Selecting $name in $concept");
- if ($target eq 'analyze') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- push (@{ $Apache::lonhomework::analyze{"$part_id.concepts"} },
- $concept);
- $Apache::lonhomework::analyze{"$part_id.concept.$concept"}=
- $Apache::response::conceptgroup{'names'};
- foreach my $name (@{ $Apache::response::conceptgroup{'names'} }) {
- push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },
- $name);
- $Apache::lonhomework::analyze{"$part_id.foil.value.$name"} =
- $Apache::response::conceptgroup{"$name.value"};
- $Apache::lonhomework::analyze{"$part_id.foil.text.$name"} =
- $Apache::response::conceptgroup{"$name.text"};
- $Apache::lonhomework::analyze{"$part_id.foil.location.$name"} =
- $Apache::response::conceptgroup{"$name.location"};
- }
- } elsif ($target eq 'web') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- push(@{ $Apache::hint::option{"$part_id.concepts"} },
- $concept);
- $Apache::hint::option{"$part_id.concept.$concept"}=
- $Apache::response::conceptgroup{'names'};
- }
- }
+ &Apache::response::pick_foil_for_concept($target,
+ ['value','text','location'],
+ \%Apache::hint::option,
+ $parstack,$safeeval);
} elsif ($target eq 'edit') {
$result=&Apache::edit::end_table();
}
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.77 loncom/homework/radiobuttonresponse.pm:1.78
--- loncom/homework/radiobuttonresponse.pm:1.77 Mon Oct 27 13:26:15 2003
+++ loncom/homework/radiobuttonresponse.pm Mon Oct 27 14:27:09 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# mutliple choice style responses
#
-# $Id: radiobuttonresponse.pm,v 1.77 2003/10/27 18:26:15 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.78 2003/10/27 19:27:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,7 +25,6 @@
#
# http://www.lon-capa.org/
#
-# 2/21 Guy
package Apache::radiobuttonresponse;
use strict;
@@ -74,7 +73,7 @@
}
$result .= '\begin{enumerate}';
} elsif ($target eq 'analyze') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+ my $part_id="$Apache::inputtags::part.$id";
push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
}
return $result;
@@ -175,16 +174,8 @@
} elsif ( $target eq 'grade') {
&grade_response($max,$randomize);
} elsif ( $target eq 'analyze') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- foreach my $name (@{ $Apache::response::foilgroup{'names'} }) {
- if (defined($Apache::lonhomework::analyze{"$part_id.foil.value.$name"})) { next; }
- push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },$name);
- $Apache::lonhomework::analyze{"$part_id.foil.value.$name"} =
- $Apache::response::foilgroup{"$name.value"};
- $Apache::lonhomework::analyze{"$part_id.foil.text.$name"} =
- $Apache::response::foilgroup{"$name.text"};
- }
- push (@{ $Apache::lonhomework::analyze{"$part_id.shown"} },&whichfoils($max,$randomize));
+ my @shown = &whichfoils($max,$randomize);
+ &Apache::response::analyze_store_foilgroup(\@shown,['text','value']);
}
}
}
@@ -468,39 +459,12 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
$Apache::radiobuttonresponse::conceptgroup=0;
my $result;
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') {
- if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
- my @names = @{ $Apache::response::conceptgroup{'names'} };
- my $pick=int(&Math::Random::random_uniform() * ($#names+1));
- my $name=$names[$pick];
- push @{ $Apache::response::foilgroup{'names'} }, $name;
- $Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"};
- $Apache::response::foilgroup{"$name.value"} = $Apache::response::conceptgroup{"$name.value"};
- $Apache::response::foilgroup{"$name.location"} = $Apache::response::conceptgroup{"$name.location"};
- my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);
- $Apache::response::foilgroup{"$name.concept"} = $concept;
- &Apache::lonxml::debug("Selecting $name in $concept");
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- push(@{ $Apache::hint::radiobutton{"$part_id.concepts"} },$concept);
- $Apache::hint::radiobutton{"$part_id.concept.$concept"}=
- $Apache::response::conceptgroup{'names'};
- if ($target eq 'analyze') {
- push (@{ $Apache::lonhomework::analyze{"$part_id.concepts"} },
- $concept);
- $Apache::lonhomework::analyze{"$part_id.concept.$concept"}=
- $Apache::response::conceptgroup{'names'};
- foreach my $name (@{ $Apache::response::conceptgroup{'names'} }) {
- push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },
- $name);
- $Apache::lonhomework::analyze{"$part_id.foil.value.$name"} =
- $Apache::response::conceptgroup{"$name.value"};
- $Apache::lonhomework::analyze{"$part_id.foil.text.$name"} =
- $Apache::response::conceptgroup{"$name.text"};
- $Apache::lonhomework::analyze{"$part_id.foil.location.$name"} =
- $Apache::response::conceptgroup{"$name.location"};
- }
- }
- }
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
+ &Apache::response::pick_foil_for_concept($target,
+ ['value','text','location'],
+ \%Apache::hint::radiobutton,
+ $parstack,$safeeval);
} elsif ($target eq 'edit') {
$result=&Apache::edit::end_table();
}
Index: loncom/homework/rankresponse.pm
diff -u loncom/homework/rankresponse.pm:1.24 loncom/homework/rankresponse.pm:1.25
--- loncom/homework/rankresponse.pm:1.24 Fri Oct 24 14:04:55 2003
+++ loncom/homework/rankresponse.pm Mon Oct 27 14:27:09 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# rank style response
#
-# $Id: rankresponse.pm,v 1.24 2003/10/24 18:04:55 sakharuk Exp $
+# $Id: rankresponse.pm,v 1.25 2003/10/27 19:27:09 albertel Exp $
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -24,7 +24,6 @@
#
# http://www.lon-capa.org/
#
-# 2/21 Guy
package Apache::rankresponse;
use strict;
@@ -63,6 +62,9 @@
$safeeval,'max',
'randomize');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
+ } elsif ($target eq 'analyze') {
+ my $part_id="$Apache::inputtags::part.$id";
+ push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
}
return $result;
}
@@ -103,6 +105,10 @@
$result=&displayanswers($max,$randomize,$tol);
} elsif ( $target eq 'grade') {
&grade_response($max,$randomize,$tol);
+ } elsif ( $target eq 'analyze') {
+ my @shown = &whichfoils($max,$randomize);
+ &Apache::response::analyze_store_foilgroup(\@shown,
+ ['text','value']);
}
&Apache::lonxml::increment_counter(&getfoilcounts($max));
} elsif ($target eq 'edit') {
@@ -342,31 +348,13 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
$Apache::rankresponse::conceptgroup=0;
my $result='';
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
#if not there aren't any foils to display and thus no question
- if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
- my @names = @{ $Apache::response::conceptgroup{'names'} };
- my $pick=int(&Math::Random::random_uniform() * ($#names+1));
- my $name=$names[$pick];
- push @{ $Apache::response::foilgroup{'names'} }, $name;
- $Apache::response::foilgroup{"$name.value"} =
- $Apache::response::conceptgroup{"$name.value"};
- $Apache::response::foilgroup{"$name.text"} =
- $Apache::response::conceptgroup{"$name.text"};
- $Apache::response::foilgroup{"$name.location"} =
- $Apache::response::conceptgroup{"$name.location"};
- my $concept = &Apache::lonxml::get_param('concept',$parstack,
- $safeeval);
- $Apache::response::foilgroup{"$name.concept"} = $concept;
- &Apache::lonxml::debug("Selecting $name in $concept");
- if ($target eq 'web' || $target eq 'tex') {
- my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
- push(@{ $Apache::hint::rank{"$part_id.concepts"} },
- $concept);
- $Apache::hint::rank{"$part_id.concept.$concept"}=
- $Apache::response::conceptgroup{'names'};
- }
- }
+ &Apache::response::pick_foil_for_concept($target,
+ ['value','text','location'],
+ \%Apache::hint::rank,
+ $parstack,$safeeval);
} elsif ($target eq 'edit') {
$result=&Apache::edit::end_table();
}
@@ -381,7 +369,7 @@
sub start_foil {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
&Apache::lonxml::startredirection;
} elsif ($target eq 'edit') {
$result=&Apache::edit::tag_start($target,$token,"Foil");
@@ -409,10 +397,11 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $text ='';
my $result = '';
- if ($target eq 'web' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
$text=&Apache::lonxml::endredirection;
}
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
if ($value ne 'unused') {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.86 loncom/homework/response.pm:1.87
--- loncom/homework/response.pm:1.86 Mon Oct 6 17:57:54 2003
+++ loncom/homework/response.pm Mon Oct 27 14:27:09 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.86 2003/10/06 21:57:54 albertel Exp $
+# $Id: response.pm,v 1.87 2003/10/27 19:27:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,9 +25,6 @@
#
# http://www.lon-capa.org/
#
-# 11/23,11/24,11/28 Gerd Kortemeyer
-# Guy Albertelli
-# 08/04,08/07 Gerd Kortemeyer
package Apache::response;
use strict;
@@ -574,6 +571,57 @@
&& lc($Apache::lonhomework::problemstatus) ne 'no')
|| $status eq "SHOW_ANSWER");
}
+
+sub analyze_store_foilgroup {
+ my ($shown,$attrs)=@_;
+ my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+ foreach my $name (@{ $Apache::response::foilgroup{'names'} }) {
+ if (defined($Apache::lonhomework::analyze{"$part_id.foil.value.$name"})) { next; }
+ push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },$name);
+ foreach my $attr (@$attrs) {
+ $Apache::lonhomework::analyze{"$part_id.foil.".$attr.".$name"} =
+ $Apache::response::foilgroup{"$name.".$attr};
+ }
+ }
+ push (@{ $Apache::lonhomework::analyze{"$part_id.shown"} }, @{ $shown });
+}
+
+sub pick_foil_for_concept {
+ my ($target,$attrs,$hinthash,$parstack,$safeeval)=@_;
+ if (not defined(@{ $Apache::response::conceptgroup{'names'} })) { return; }
+ my @names = @{ $Apache::response::conceptgroup{'names'} };
+ my $pick=int(&Math::Random::random_uniform() * ($#names+1));
+ my $name=$names[$pick];
+ push @{ $Apache::response::foilgroup{'names'} }, $name;
+ foreach my $attr (@$attrs) {
+ $Apache::response::foilgroup{"$name.".$attr} =
+ $Apache::response::conceptgroup{"$name.".$attr};
+ }
+ my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);
+ $Apache::response::foilgroup{"$name.concept"} = $concept;
+ &Apache::lonxml::debug("Selecting $name in $concept");
+ my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+ if ($target eq 'analyze') {
+ push (@{ $Apache::lonhomework::analyze{"$part_id.concepts"} },
+ $concept);
+ $Apache::lonhomework::analyze{"$part_id.concept.$concept"}=
+ $Apache::response::conceptgroup{'names'};
+ foreach my $name (@{ $Apache::response::conceptgroup{'names'} }) {
+ push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },
+ $name);
+ foreach my $attr (@$attrs) {
+ $Apache::lonhomework::analyze{"$part_id.foil.$attr.$name"}=
+ $Apache::response::conceptgroup{"$name.$attr"};
+ }
+ }
+ }
+ push(@{ $hinthash->{"$part_id.concepts"} },$concept);
+ $hinthash->{"$part_id.concept.$concept"}=
+ $Apache::response::conceptgroup{'names'};
+
+}
+
+
1;
__END__
--albertel1067282829--