--- loncom/homework/optionresponse.pm 2003/10/24 17:56:42 1.91
+++ loncom/homework/optionresponse.pm 2004/02/12 15:50:01 1.99
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.91 2003/10/24 17:56:42 sakharuk Exp $
+# $Id: optionresponse.pm,v 1.99 2004/02/12 15:50:01 sakharuk 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;
@@ -45,7 +43,8 @@ sub start_optionresponse {
%Apache::hint::option=();
if ($target eq 'edit') {
$result.=&Apache::edit::start_table($token).
- "
Multiple Option Response Question ".
+ &Apache::loncommon::help_open_topic('Option_Response_Problems')." | Delete:".
&Apache::edit::deletelist($target,$token)
." | ".
&Apache::edit::end_row().
@@ -63,7 +62,7 @@ sub start_optionresponse {
} 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;
@@ -151,7 +150,8 @@ 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' || $target eq 'analyze') {
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
my $tex_option_switch=&Apache::lonxml::get_param('texoptions',$parstack,$safeeval);
my $name;
my @opt;
@@ -166,17 +166,11 @@ sub end_foilgroup {
} 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','location']);
+ 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);
@@ -191,8 +185,8 @@ sub end_foilgroup {
if ($ENV{'form.submitted'} eq 'scantron') {
$response = $opt[$response];
}
- $responsehash{$name}=$response;
if ( $response =~ /[^\s]/) {
+ $responsehash{$name}=$response;
my $value=$Apache::response::foilgroup{$name.'.value'};
&Apache::lonxml::debug("submitted a $response for $value \n");
if ($value eq $response) {
@@ -246,7 +240,7 @@ sub end_foilgroup {
}
}
}
- if ($target ne 'answer') {&Apache::lonxml::increment_counter(&getfoilcounts($max));}
+ &Apache::lonxml::increment_counter(&getfoilcounts($max));
} elsif ($target eq 'edit') {
$result.=&Apache::edit::end_table();
}
@@ -325,6 +319,8 @@ sub displayfoils {
} else {
$text=$value.': '.$text;
}
+ } else {
+ $text=''.$text;
}
$result.=$text."\n";
} elsif ($target eq 'tex') {
@@ -374,6 +370,8 @@ sub displayfoils {
my $text=$Apache::response::foilgroup{$name.'.text'};
if (!($text=~s||$optionlist|) && $Apache::lonhomework::type ne 'exam') {
$text=$optionlist.$text;
+ } else {
+ $text=''.$text;
}
$result.=$break.$text."\n";
if ($Apache::lonhomework::type eq 'exam') {
@@ -400,7 +398,7 @@ sub displayfoils {
}
}
if ($Apache::lonhomework::type eq 'exam') {
- $result.='\vskip -2 mm\parbox{\textwidth}{\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]\parbox{\textwidth - 5 mm}{'.&bubbles(\@alphabet,\@opt).'}\end{enumerate}} \vskip -9 mm \strut ';
+ $result.='\vskip -1 mm\noindent\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]'.&bubbles(\@alphabet,\@opt).'\end{enumerate} \vskip -9 mm \strut ';
$internal_counter++;
}
$displayoptionintex=1;
@@ -421,7 +419,7 @@ sub displayfoils {
}
}
if ($Apache::lonhomework::type eq 'exam') {
- $result.='\vskip -2 mm \parbox{\textwidth}{\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]\parbox{\textwidth - 5 mm}{'.&bubbles(\@alphabet,\@opt).'}\end{enumerate}} \vskip -9 mm \strut ';
+ $result.='\vskip -1 mm \noindent\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]'.&bubbles(\@alphabet,\@opt).'\end{enumerate} \vskip -9 mm \strut ';
$internal_counter++;
}
}
@@ -448,7 +446,7 @@ sub optionlist_correction {
$texoptionlist =~ s/>/\$>\$/g;
$texoptionlist =~ s/\$<\$/g;
$texoptionlist =~ s/=/\$=\$/g;
- $texoptionlist =~ s/\^(\d+)/\$$1\$<\/m>/g;
+ $texoptionlist =~ s/\^(\d+)/\$^{$1}\$/g;
} else {
$texoptionlist =~ s/ |