--- loncom/homework/matchresponse.pm 2011/12/15 01:21:28 1.86
+++ loncom/homework/matchresponse.pm 2012/12/29 01:21:10 1.87
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.86 2011/12/15 01:21:28 raeburn Exp $
+# $Id: matchresponse.pm,v 1.87 2012/12/29 01:21:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,6 +34,7 @@ use Apache::optionresponse();
use Apache::lonlocal;
use Apache::lonnet;
use Apache::lonxml;
+use POSIX qw(ceil);
BEGIN {
&Apache::lonxml::register('Apache::matchresponse',('matchresponse'));
@@ -111,12 +112,17 @@ sub start_itemgroup {
$result.=&Apache::edit::select_arg('Items Display Direction:',
'direction',
['vertical','horizontal'],
- $token);
+ $token).' 'x 3;
+ $result.=&Apache::edit::select_arg('Items Columns:',
+ 'columns',
+ [['','default'],'1','2','3','4'],
+ $token);
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'randomize',
- 'location','direction');
+ 'location','direction',
+ 'columns');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
} elsif ($target eq 'web' or $target eq 'tex') {
$Apache::matchresponse::itemtable{'location'}=
@@ -158,19 +164,51 @@ sub end_itemgroup {
$Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map;
$Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map;
my $direction=&Apache::lonxml::get_param('direction',$parstack,$safeeval);
+ my $columns=&Apache::lonxml::get_param('columns',$parstack,$safeeval);
+
+ unless ($columns =~ /^\d+$/) {
+ undef($columns);
+ }
if ($target eq 'web') {
my $table='
'.$alphabet[$i].' | '. - $Apache::response::itemgroup{$name.'.text'}.' | '; - if ($direction ne 'horizontal') { $table.='|
'.$label.' | '.$item.' | '; + if ($columns > 1) { + $table .= ''; + } + if ( ! (($i+1) % $columns) ) { + $table.=' |