[LON-CAPA-cvs] cvs: loncom /homework optionresponse.pm
www
www@source.lon-capa.org
Sun, 05 Sep 2010 20:46:58 -0000
www Sun Sep 5 20:46:58 2010 EDT
Modified files:
/loncom/homework optionresponse.pm
Log:
Bug #6329: can switch off checkbox choices
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.171 loncom/homework/optionresponse.pm:1.172
--- loncom/homework/optionresponse.pm:1.171 Wed Sep 1 21:29:51 2010
+++ loncom/homework/optionresponse.pm Sun Sep 5 20:46:58 2010
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.171 2010/09/01 21:29:51 raeburn Exp $
+# $Id: optionresponse.pm,v 1.172 2010/09/05 20:46:58 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -137,7 +137,10 @@
}
$result.='>'.$option.'</option>';
}
- $result.='</select></label>';
+ $result.='</select></label>';
+ $result.=&Apache::edit::checked_arg('Checkbox options:','checkboxoptions',
+ [ ['nochoice','Don\'t show option list'] ]
+ ,$token).'</td>';
$result.= &Apache::edit::end_row();
$result.= &Apache::edit::start_spanning_row();
$result.= $insertlist.'<br />';
@@ -162,7 +165,7 @@
$optchanged=1;
}
my $rebuildtag = &Apache::edit::get_new_args($token,$parstack,$safeeval,
- 'texoptions','checkboxvalue');
+ 'texoptions','checkboxvalue','checkboxoptions');
if ($optchanged || $rebuildtag ) {
$result = "<foilgroup options=\"(";
foreach my $option (@options) {
@@ -173,6 +176,7 @@
chop $result;
$result.=')" ';
$result .= 'texoptions="'.$token->[2]{'texoptions'}.'" ';
+ $result .= 'checkboxoptions="'.$token->[2]{'checkboxoptions'}.'" ';
$result .= 'checkboxvalue="'.$token->[2]{'checkboxvalue'}.'"';
$result .= '>';
} # else nothing changed so just use the default mechanism
@@ -202,13 +206,14 @@
my $TeXlayout=&Apache::lonxml::get_param('TeXlayout',$parstack,$safeeval,
-2,0);
my $checkboxvalue=&Apache::lonxml::get_param('checkboxvalue',$parstack,$safeeval);
+ my $checkboxchoices=(&Apache::lonxml::get_param('checkboxoptions',$parstack,$safeeval) ne 'nochoice');
if ($target eq 'tex' && $tex_option_switch eq 'nochoice') {@opt=();}
&Apache::lonxml::debug("Options are $#opt");
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
$safeeval,'-2');
if ($target eq 'web' || $target eq 'tex') {
- $result.=&displayfoils($target,$max,$randomize,$TeXlayout,$checkboxvalue,@opt);
+ $result.=&displayfoils($target,$max,$randomize,$TeXlayout,$checkboxvalue,$checkboxchoices,@opt);
$Apache::lonxml::post_evaluate=0;
} elsif ( $target eq 'answer') {
$result.=&displayanswers($max,$randomize,@opt);
@@ -414,7 +419,7 @@
}
sub displayfoils {
- my ($target,$max,$randomize,$TeXlayout,$checkboxvalue,@opt)=@_;
+ my ($target,$max,$randomize,$TeXlayout,$checkboxvalue,$checkboxchoices,@opt)=@_;
if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
my @names = @{ $Apache::response::foilgroup{'names'} };
my @truelist;
@@ -468,7 +473,8 @@
my $internal_counter=$Apache::lonxml::counter;
my $checkboxopt=&check_box_opt($target,$checkboxvalue,@opt);
if ($checkboxopt) {
- $result.='<br />'.&mt('Choices: ').'<b>'.$opt[0].','.$opt[1].'</b>. '.
+ $result.='<br />'.
+ ($checkboxchoices?&mt('Choices: ').'<b>'.$opt[0].','.$opt[1].'</b>. ':'').
&mt('Select all that are <b>[_1]</b>.',$checkboxopt);
}
foreach $name (@whichopt) {