--- loncom/homework/optionresponse.pm 2004/02/19 19:06:35 1.101
+++ loncom/homework/optionresponse.pm 2004/03/15 22:09:52 1.104
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.101 2004/02/19 19:06:35 albertel Exp $
+# $Id: optionresponse.pm,v 1.104 2004/03/15 22:09:52 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,7 +27,8 @@
#
package Apache::optionresponse;
use strict;
-use Apache::response;
+use Apache::response();
+use Apache::lonlocal;
BEGIN {
&Apache::lonxml::register('Apache::optionresponse',('optionresponse'));
@@ -41,6 +42,7 @@ sub start_optionresponse {
push (@Apache::lonxml::namespace,'optionresponse');
my $id = &Apache::response::start_response($parstack,$safeeval);
%Apache::hint::option=();
+ undef(%Apache::response::foilnames);
if ($target eq 'edit') {
$result.=&Apache::edit::start_table($token).
"
Multiple Option Response Question ".
@@ -75,6 +77,7 @@ sub end_optionresponse {
&Apache::lonxml::deregister('Apache::optionresponse',('foilgroup','foil','conceptgroup'));
my $result;
if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
+ undef(%Apache::response::foilnames);
return $result;
}
@@ -460,14 +463,14 @@ sub bubbles {
$ENV{'form.textwidth'}=~/(\d+)/;
$textwidth=$1;
} else {
- $ENV{'textwidth'}=~/(\d+)/;
- $textwidth=$1;
+ $ENV{'textwidth'}=~/(\d*)\.?(\d*)/;
+ $textwidth=$1.'.'.$2;
}
for (my $ind=0;$ind<=$number_of_bubbles;$ind++) {
my $leftmargin;
$opt[$ind]=&Apache::lonxml::latex_special_symbols($opt[$ind]);
if ($ind==0) {$leftmargin=6;} else {$leftmargin=10;}
- $current_length += (length($opt[$ind])+length($alphabet[$ind])+3)*2;
+ $current_length += (length($opt[$ind])+length($alphabet[$ind])+4)*2;
if ($current_length<($textwidth-$leftmargin) and $ind!=$number_of_bubbles) {
$line.='\hskip -1 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';
$head.='lr';
@@ -565,10 +568,14 @@ sub end_foil {
my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
if ($value ne 'unused') {
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
- my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);
&Apache::lonxml::debug("Got a name of :$name:");
if (!$name) { $name=$Apache::lonxml::curdepth; }
&Apache::lonxml::debug("Using a name of :$name:");
+ if (defined($Apache::response::foilnames{$name})) {
+ &Apache::lonxml::error(&mt("Foil name [_1] appears more than once. Foil names need to be unique.",$name));
+ }
+ $Apache::response::foilnames{$name}++;
+ my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);
if ( $Apache::optionresponse::conceptgroup
&& !&Apache::response::showallfoils() ) {
push @{ $Apache::response::conceptgroup{'names'} }, $name;
|