version 1.102, 2005/06/22 12:03:23
|
version 1.107, 2006/11/27 11:42:40
|
Line 32 use HTML::Entities();
|
Line 32 use HTML::Entities();
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
|
my $exam_max_bubbles = 10; |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse')); |
&Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse')); |
} |
} |
Line 60 sub start_radiobuttonresponse {
|
Line 62 sub start_radiobuttonresponse {
|
$token,'4'). |
$token,'4'). |
&Apache::edit::select_arg('Randomize Foil Order','randomize', |
&Apache::edit::select_arg('Randomize Foil Order','randomize', |
['yes','no'],$token). |
['yes','no'],$token). |
|
&Apache::edit::select_arg('Display Direction','direction', |
|
['vertical','horizontal'],$token). |
&Apache::edit::end_row(). |
&Apache::edit::end_row(). |
&Apache::edit::start_spanning_row()."\n"; |
&Apache::edit::start_spanning_row()."\n"; |
} 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,'max', |
$safeeval,'max', |
'randomize'); |
'randomize','direction'); |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
my $type=&Apache::lonxml::get_param('TeXtype',$parstack,$safeeval, |
my $type=&Apache::lonxml::get_param('TeXtype',$parstack,$safeeval, |
Line 232 sub displayallfoils {
|
Line 236 sub displayallfoils {
|
my ($direction)=@_; |
my ($direction)=@_; |
my $result; |
my $result; |
&Apache::lonxml::debug("survey style display"); |
&Apache::lonxml::debug("survey style display"); |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names; |
|
if ( $Apache::response::foilgroup{'names'} ) { |
|
@names= @{ $Apache::response::foilgroup{'names'} }; |
|
} |
my $temp=0; |
my $temp=0; |
my $id=$Apache::inputtags::response['-1']; |
my $id=$Apache::inputtags::response['-1']; |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
Line 289 sub whichfoils {
|
Line 296 sub whichfoils {
|
my ($truecnt,$falsecnt) = &getfoilcounts(); |
my ($truecnt,$falsecnt) = &getfoilcounts(); |
my $count=0; |
my $count=0; |
# we will add in 1 of the true statements |
# we will add in 1 of the true statements |
if (($falsecnt+1)>$max) { $count=$max } else { $count=$falsecnt+1; } |
if ( $max>0 && ($falsecnt+1)>$max) { $count=$max } else { $count=$falsecnt+1; $max=$count; } |
my $answer=int(&Math::Random::random_uniform() * ($count)); |
my $answer=int(&Math::Random::random_uniform() * ($count)); |
&Apache::lonxml::debug("Count is $count, $answer is $answer"); |
&Apache::lonxml::debug("Count is $count, $answer is $answer"); |
my @names; |
my @names; |
Line 485 sub displayfoils {
|
Line 492 sub displayfoils {
|
$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</label>"; |
$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</label>"; |
} else { |
} else { |
if ($Apache::lonhomework::type eq 'exam') { |
if ($Apache::lonhomework::type eq 'exam') { |
|
|
|
# If necessary, start a new group of bubbles |
|
# in the next row on the scantron sheet: |
|
# |
|
if ($i >= $exam_max_bubbles) { |
|
$i = 0; # Back to A. |
|
$Apache::lonxml::counter++; # Next row of bubbles... |
|
$result .= '\item[\textbf{'.$Apache::lonxml::counter.'}.]'; |
|
} |
|
|
$result .= '{\small \textbf{'.$alphabet[$i].'}}$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\'; #' stupid emacs |
$result .= '{\small \textbf{'.$alphabet[$i].'}}$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\'; #' stupid emacs |
$i++; |
$i++; |
|
|
} else { |
} else { |
$result .= '\vspace*{-2 mm}\item '.$Apache::response::foilgroup{$name.'.text'}; |
$result .= '\vspace*{-2 mm}\item '.$Apache::response::foilgroup{$name.'.text'}; |
} |
} |
Line 505 sub displayfoils {
|
Line 523 sub displayfoils {
|
} |
} |
|
|
sub displayallanswers { |
sub displayallanswers { |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names; |
|
if ( $Apache::response::foilgroup{'names'} ) { |
|
@names= @{ $Apache::response::foilgroup{'names'} }; |
|
} |
|
|
my $result=&Apache::response::answer_header('radiobuttonresponse'); |
my $result=&Apache::response::answer_header('radiobuttonresponse'); |
foreach my $name (@names) { |
foreach my $name (@names) { |
Line 520 sub displayanswers {
|
Line 541 sub displayanswers {
|
my ($max,$randomize)=@_; |
my ($max,$randomize)=@_; |
my ($answer,@whichopt) = &whichfoils($max,$randomize); |
my ($answer,@whichopt) = &whichfoils($max,$randomize); |
my $result=&Apache::response::answer_header('radiobuttonresponse'); |
my $result=&Apache::response::answer_header('radiobuttonresponse'); |
|
if ($Apache::lonhomework::type eq 'exam') { |
|
my $correct = ('A'..'Z')[$answer]; |
|
$result.=&Apache::response::answer_part('radiobuttonresponse', |
|
$correct); |
|
} |
foreach my $name (@whichopt) { |
foreach my $name (@whichopt) { |
$result.=&Apache::response::answer_part('radiobuttonresponse', |
$result.=&Apache::response::answer_part('radiobuttonresponse', |
$Apache::response::foilgroup{$name.'.value'}) |
$Apache::response::foilgroup{$name.'.value'}); |
} |
} |
$result.=&Apache::response::answer_footer('radiobuttonresponse'); |
$result.=&Apache::response::answer_footer('radiobuttonresponse'); |
return $result; |
return $result; |
} |
} |