version 1.84, 2011/11/08 01:33:14
|
version 1.87, 2012/12/29 01:21:10
|
Line 34 use Apache::optionresponse();
|
Line 34 use Apache::optionresponse();
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonxml; |
use Apache::lonxml; |
|
use POSIX qw(ceil); |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::matchresponse',('matchresponse')); |
&Apache::lonxml::register('Apache::matchresponse',('matchresponse')); |
Line 111 sub start_itemgroup {
|
Line 112 sub start_itemgroup {
|
$result.=&Apache::edit::select_arg('Items Display Direction:', |
$result.=&Apache::edit::select_arg('Items Display Direction:', |
'direction', |
'direction', |
['vertical','horizontal'], |
['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(); |
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'randomize', |
$safeeval,'randomize', |
'location','direction'); |
'location','direction', |
|
'columns'); |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
} elsif ($target eq 'web' or $target eq 'tex') { |
} elsif ($target eq 'web' or $target eq 'tex') { |
$Apache::matchresponse::itemtable{'location'}= |
$Apache::matchresponse::itemtable{'location'}= |
Line 158 sub end_itemgroup {
|
Line 164 sub end_itemgroup {
|
$Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map; |
$Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map; |
$Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map; |
$Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map; |
my $direction=&Apache::lonxml::get_param('direction',$parstack,$safeeval); |
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') { |
if ($target eq 'web') { |
|
|
my $table='<br /><table>'; # extra space to match what latex does. |
my $table='<br /><table>'; # extra space to match what latex does. |
my $i=0; |
if ((!$columns) || ($columns < 0)) { |
if ($direction eq 'horizontal') { $table .='<tr>';} |
if ($direction eq 'horizontal') { |
foreach my $name (@names) { |
if (@names > 0) { |
if ($direction ne 'horizontal') { $table.='<tr>'; } |
$columns = scalar(@names); |
$table.='<td>'.$alphabet[$i].'</td><td>'. |
} else { |
$Apache::response::itemgroup{$name.'.text'}.'</td>'; |
$columns = 1; |
if ($direction ne 'horizontal') { $table.='</tr>'; } |
} |
$i++; |
} else { |
} |
$columns = 1; |
if ($direction eq 'horizontal') { $table .='</tr>';} |
} |
|
} |
|
my $rows=ceil(scalar(@names)/$columns); |
|
my $endloop = $columns*$rows; |
|
for (my $i=0; $i<$endloop; $i++) { |
|
my $label = ' '; |
|
my $item = ' '; |
|
my $index; |
|
if ($direction eq 'horizontal') { |
|
$index = $i; |
|
} else { |
|
$index = ($i % $columns)*$rows+int($i/$columns); |
|
} |
|
if ($index < scalar(@names)) { |
|
$label = $alphabet[$index]; |
|
$item = $Apache::response::itemgroup{$names[$index].'.text'}; |
|
} |
|
if ($i % $columns == 0) { |
|
$table.='<tr>'; |
|
} |
|
$table.= '<td>'.$label.'</td><td>'.$item.'</td>'; |
|
if ($columns > 1) { |
|
$table .= '<td> </td>'; |
|
} |
|
if ( ! (($i+1) % $columns) ) { |
|
$table.='</tr>'; |
|
} |
|
} |
$table.='</table>'; |
$table.='</table>'; |
$Apache::matchresponse::itemtable{'display'}=$table; |
$Apache::matchresponse::itemtable{'display'}=$table; |
$Apache::lonxml::post_evaluate=0; |
$Apache::lonxml::post_evaluate=0; |
Line 462 sub grade_response {
|
Line 500 sub grade_response {
|
} |
} |
} |
} |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
my $nonlenient=&Apache::optionresponse::is_nonlenient($part); |
my $nonlenient=&Apache::optionresponse::grading_is_nonlenient($part); |
my $id = $Apache::inputtags::response['-1']; |
my $id = $Apache::inputtags::response['-1']; |
my $responsestr=&Apache::lonnet::hash2str(%responsehash); |
my $responsestr=&Apache::lonnet::hash2str(%responsehash); |
my $itemstr =&Apache::lonnet::array2str(@items); |
my $itemstr =&Apache::lonnet::array2str(@items); |