--- loncom/homework/radiobuttonresponse.pm 2007/06/20 21:43:59 1.117
+++ loncom/homework/radiobuttonresponse.pm 2008/12/11 02:16:46 1.140
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# mutliple choice style responses
#
-# $Id: radiobuttonresponse.pm,v 1.117 2007/06/20 21:43:59 foxr Exp $
+# $Id: radiobuttonresponse.pm,v 1.140 2008/12/11 02:16:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -18,14 +18,15 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with LON-CAPA; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# along with LON-CAPA; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
+
+
package Apache::radiobuttonresponse;
use strict;
use HTML::Entities();
@@ -33,12 +34,25 @@ use Apache::lonlocal;
use Apache::lonnet;
use Apache::response;
-my $bubbles_per_line = 10;
+my $default_bubbles_per_line = 10;
+
BEGIN {
&Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));
}
+sub bubble_line_count {
+ my ($numfoils, $bubbles_per_line) = @_;
+ my $bubble_lines;
+ $bubble_lines = int($numfoils / $bubbles_per_line);
+ if (($numfoils % $bubbles_per_line) != 0) {
+ $bubble_lines++;
+ }
+ return $bubble_lines;
+
+}
+
+
sub start_radiobuttonresponse {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
@@ -47,22 +61,25 @@ sub start_radiobuttonresponse {
&Apache::lonxml::register('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup'));
push (@Apache::lonxml::namespace,'radiobuttonresponse');
my $id = &Apache::response::start_response($parstack,$safeeval);
+
%Apache::hint::radiobutton=();
undef(%Apache::response::foilnames);
if ($target eq 'meta') {
$result=&Apache::response::meta_package_write('radiobuttonresponse');
} elsif ($target eq 'edit' ) {
- $result.=&Apache::edit::start_table($token).
- '
'; }
return $result;
}
+
sub whichfoils {
my ($max,$randomize)=@_;
@@ -402,7 +440,7 @@ sub whichfoils {
}
}
if (!$havetrue && $Apache::lonhomework::type ne 'survey') {
- &Apache::lonxml::error("There are no true statements available. ");
+ &Apache::lonxml::error(&mt('There are no true statements available.').' ');
}
} else {
my $current=0;
@@ -463,7 +501,7 @@ sub whichfoils {
my $dosplice=1;
if ($notrue && $Apache::lonhomework::type ne 'survey') {
$dosplice=0;
- &Apache::lonxml::error("There are no true statements available. ");
+ &Apache::lonxml::error(&mt('There are no true statements available.').' ');
}
#insert the true statement, keeping track of where it wants to be
if ($Apache::response::foilgroup{$truename.'.location'} eq 'top' && $dosplice) {
@@ -505,10 +543,9 @@ sub whichfoils {
}
sub displayfoils {
- my ($target,$max,$randomize,$direction)=@_;
+ my ($target,$answer,$whichfoils,$direction, $bubbles_per_line)=@_;
my $result;
- my ($answer,@whichfoils)=&whichfoils($max,$randomize);
my $part=$Apache::inputtags::part;
my $solved=$Apache::lonhomework::history{"resource.$part.solved"};
if ( ($target ne 'tex') &&
@@ -518,7 +555,7 @@ sub displayfoils {
$result.='
';
}
}
- foreach my $name (@whichfoils) {
+ foreach my $name (@{ $whichfoils }) {
if ($direction eq 'horizontal') {
if ($target ne 'tex') { $result.='
'; }
}
@@ -528,9 +565,13 @@ sub displayfoils {
$result.='\item \vskip -2 mm ';
}
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
- if ($target ne 'tex') { $result.='Correct:'; } else { $result.='Correct: \textbf{';}
+ if ($target ne 'tex') {
+ $result.=&mt('Correct:').'';
+ } else {
+ $result.=&mt('Correct:').' \textbf{';
+ }
} else {
- $result.='Incorrect:';
+ $result.=&mt('Incorrect:');
}
if ($target eq 'web') { $result.="